From 1251f19ebcaa07ce5e0c341ae2e2fdd4172d07a7 Mon Sep 17 00:00:00 2001 From: DarkGod <darkgod@net-core.org> Date: Sat, 19 Oct 2013 18:28:50 +0200 Subject: [PATCH] Player can now tag objects with a name; tagged objects can not be dropped, destroyed or transmogrified until the tag is removed --- game/modules/tome/class/Object.lua | 4 ++++ game/modules/tome/class/Player.lua | 9 +++++++-- game/modules/tome/dialogs/UseItemDialog.lua | 16 ++++++++++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/game/modules/tome/class/Object.lua b/game/modules/tome/class/Object.lua index 10319a52b6..fa0282ae2f 100644 --- a/game/modules/tome/class/Object.lua +++ b/game/modules/tome/class/Object.lua @@ -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 diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index 116e130c83..cacf9364f9 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -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 diff --git a/game/modules/tome/dialogs/UseItemDialog.lua b/game/modules/tome/dialogs/UseItemDialog.lua index 709248497b..9949d65ecf 100644 --- a/game/modules/tome/dialogs/UseItemDialog.lua +++ b/game/modules/tome/dialogs/UseItemDialog.lua @@ -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} -- GitLab