Skip to content
Snippets Groups Projects
Commit 1251f19e authored by DarkGod's avatar DarkGod
Browse files

Player can now tag objects with a name; tagged objects can not be dropped,...

Player can now tag objects with a name; tagged objects can not be dropped, destroyed or transmogrified until the tag is removed
parent 1fa2bfed
No related branches found
No related tags found
No related merge requests found
......@@ -269,6 +269,10 @@ function _M:getName(t)
end)
end
if not t.no_add_name and self.__tagged then
name = name .. " #ORANGE#="..self.__tagged.."=#LAST#"
end
if not t.do_color then
if qty == 1 or t.no_count then return name
else return qty.." "..name
......
......@@ -1049,7 +1049,12 @@ function _M:doDrop(inven, item, on_done, nb)
local o = self:getInven(inven) and self:getInven(inven)[item]
if o and o.plot then
game.logPlayer(self, "You can not drop %s.", o:getName{do_colour=true})
game.logPlayer(self, "You can not drop %s (plot item).", o:getName{do_colour=true})
return
end
if o and o.__tagged then
game.logPlayer(self, "You can not drop %s (tagged).", o:getName{do_colour=true})
return
end
......@@ -1069,7 +1074,7 @@ function _M:doDrop(inven, item, on_done, nb)
game.logPlayer(self, "You can not destroy %s.", o:getName{do_colour=true})
end
end
end, "Cancel", "Destroy")
end, "Cancel", "Destroy", true)
return
end
if nb == nil or nb >= self:getInven(inven)[item]:getNumber() then
......
......@@ -100,6 +100,16 @@ function _M:use(item)
elseif act == "toinven" then
self.object.__transmo = false
self.onuse(self.inven, self.item, self.object, false)
elseif act == "untag" then
self.object.__tagged = nil
self.onuse(self.inven, self.item, self.object, false)
elseif act == "tag" then
local d = require("engine.dialogs.GetText").new("Tag object (tagged objects can not be destroyed or dropped)", "Tag:", 2, 25, function(tag) if tag then
self.object.__tagged = tag
self.object.__transmo = false
self.onuse(self.inven, self.item, self.object, false)
end end)
game:registerDialog(d)
elseif act == "chat-link" then
profile.chat.uc_ext:sendObjectLink(self.object)
elseif act == "debug-inspect" then
......@@ -124,11 +134,13 @@ function _M:generateList()
if not self.object.__transmo and not self.no_use_allowed then if self.object:canUseObject() then list[#list+1] = {name="Use", action="use"} end end
if self.inven == self.actor.INVEN_INVEN and self.object:wornInven() and self.actor:getInven(self.object:wornInven()) then list[#list+1] = {name="Wield/Wear", action="wear"} end
if not self.object.__transmo then if self.inven ~= self.actor.INVEN_INVEN and self.object:wornInven() then list[#list+1] = {name="Take off", action="takeoff"} end end
if self.inven == self.actor.INVEN_INVEN then list[#list+1] = {name="Drop", action="drop"} end
if not self.object.__tagged and self.inven == self.actor.INVEN_INVEN then list[#list+1] = {name="Drop", action="drop"} end
if self.inven == self.actor.INVEN_INVEN and game.party:countInventoryAble() >= 2 then list[#list+1] = {name="Transfer to party", action="transfer"} end
if self.inven == self.actor.INVEN_INVEN and transmo_chest and self.actor:transmoFilter(self.object) then list[#list+1] = {name=self.actor:transmoGetWord():capitalize().." now", action="transmo"} end
if not self.object.__tagged and self.inven == self.actor.INVEN_INVEN and transmo_chest and self.actor:transmoFilter(self.object) then list[#list+1] = {name=self.actor:transmoGetWord():capitalize().." now", action="transmo"} end
if profile.auth and profile.hash_valid then list[#list+1] = {name="Link item in chat", action="chat-link"} end
if config.settings.cheat then list[#list+1] = {name="Lua inspect", action="debug-inspect", color=colors.simple(colors.LIGHT_BLUE)} end
if not self.object.__tagged then list[#list+1] = {name="Tag", action="tag"} end
if self.object.__tagged then list[#list+1] = {name="Untag", action="untag"} end
self:triggerHook{"UseItemMenu:generate", actor=self.actor, object=self.object, inven=self.inven, item=self.item, menu=list}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment