From 6e6a26b0d2a2059e194339e31947c7ef977fb546 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Sun, 23 Oct 2011 13:11:03 +0000 Subject: [PATCH] Rod of Recall and Transmogrification Chest can not be dropped Overhauled transmogrification chest:<ul> <li>A new inventory tabs appears for the chest</li> <li>All items are automatically pickedup and put in the chest</li> <li>Items in the chest are weightless</li> <li>You can still transmogrify from the inventory menu</li> <li>When you leave the current level all items in the chest are transmogrified automatically</li> <li>In the inventory chest tab you can move an item out of the chest, it will then act as any other item, with an encumberance and be useable (and will not be transmogrified)</li> </ul> git-svn-id: http://svn.net-core.org/repos/t-engine4@4585 51575b47-30f0-44d4-a5cc-537603b46e54 --- .../engine/interface/ActorInventory.lua | 7 +++ game/modules/tome/class/Actor.lua | 41 ++++++++++++--- game/modules/tome/class/Game.lua | 16 +++++- game/modules/tome/class/Object.lua | 3 ++ game/modules/tome/class/Player.lua | 12 ++++- .../data/general/objects/quest-artifacts.lua | 7 +++ .../data/gfx/metal-ui/inven_tabs/chest.png | Bin 0 -> 4802 bytes .../data/zones/shertul-fortress/objects.lua | 47 ++++++------------ game/modules/tome/dialogs/ShowEquipInven.lua | 27 ++++++---- game/modules/tome/dialogs/UseItemDialog.lua | 19 ++++--- 10 files changed, 122 insertions(+), 57 deletions(-) create mode 100644 game/modules/tome/data/gfx/metal-ui/inven_tabs/chest.png diff --git a/game/engines/default/engine/interface/ActorInventory.lua b/game/engines/default/engine/interface/ActorInventory.lua index f53228efa6..49b92a5a08 100644 --- a/game/engines/default/engine/interface/ActorInventory.lua +++ b/game/engines/default/engine/interface/ActorInventory.lua @@ -219,6 +219,10 @@ function _M:onRemoveObject(o) o.carried = nil end +--- Called upon dropping an object +function _M:onDropObject(o) +end + --- Drop an object on the floor -- @param inven the inventory to drop from -- @param item the item id to drop @@ -232,6 +236,9 @@ function _M:dropFloor(inven, item, vocal, all) if o:check("on_drop", self) then return false end o = self:removeObject(inven, item, all) + + self:onDropObject(o) + local ok, idx = game.level.map:addObject(self.x, self.y, o) if vocal then game.logSeen(self, "%s drops on the floor: %s.", self.name:capitalize(), o:getName{do_color=true}) end diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index ce38ef4bc0..aeac534524 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -252,7 +252,7 @@ function _M:useEnergy(val) stalk.hit_turns = 0 end end - + -- Curse of Shrouds: turn shroud of passing on or off local eff = self:hasEffect(self.EFF_CURSE_OF_SHROUDS) if eff then self.tempeffect_def[self.EFF_CURSE_OF_SHROUDS].doShroudOfPassing(self, eff) end @@ -631,7 +631,7 @@ function _M:move(x, y, force) if not force and moved and (self.x ~= ox or self.y ~= oy) and not self.did_energy then local eff = self:hasEffect(self.EFF_CURSE_OF_SHROUDS) if eff then eff.moved = true end - + self:useEnergy(game.energy_to_act * self:combatMovementSpeed()) end end @@ -659,7 +659,7 @@ function _M:move(x, y, force) t.chooseCursedAuraTree(self, t) end end - + if moved and self:knowTalent(self.T_DEFILING_TOUCH) then local t = self:getTalentFromId(self.T_DEFILING_TOUCH) t.curseFloor(self, t, x, y) @@ -1662,7 +1662,7 @@ function _M:die(src, death_note) end end) end - + -- Curse of Corpses: Corpselight -- Curse of Corpses: Reprieve from Death if src and src.hasEffect and src:hasEffect(src.EFF_CURSE_OF_CORPSES) then @@ -1672,7 +1672,7 @@ function _M:die(src, death_note) def.doCorpselight(src, eff, self) end end - + -- Curse of Shrouds: Shroud of Death if src and src.hasEffect and src:hasEffect(src.EFF_CURSE_OF_SHROUDS) then local eff = src:hasEffect(src.EFF_CURSE_OF_SHROUDS) @@ -1917,7 +1917,9 @@ function _M:getEncumbrance() -- Compute encumbrance for inven_id, inven in pairs(self.inven) do for item, o in ipairs(inven) do - o:forAllStack(fct) + if not o.__transmo then + o:forAllStack(fct) + end end end -- print("Total encumbrance", enc) @@ -3182,3 +3184,30 @@ function _M:addedToLevel(level, x, y) self:check("on_added_to_level", level, x, y) end +--- Called upon dropping an object +function _M:onDropObject(o) + if self:attr("has_transmo") then o.__transmo = false end +end + +function _M:transmoPricemod(o) if o.type == "gem" then return 0.40 else return 0.05 end end +function _M:transmoFilter(o) if o:getPrice() <= 0 or o.quest then return false end return true end +function _M:transmoInven(inven, idx, o) + local price = math.min(o:getPrice() * self:transmoPricemod(o), 25) * o:getNumber() + local price = math.min(o:getPrice() * self:transmoPricemod(o), 25) * o:getNumber() + price = math.floor(price * 100) / 100 -- Make sure we get at most 2 digit precision + if price ~= price or not tostring(price):find("^[0-9]") then price = 1 end -- NaN is the only value that does not equals itself, this is the way to check it since we do not have a math.isnan method + self:removeObject(self:getInven("INVEN"), idx, true) + self:sortInven() + self:incMoney(price) + if self.hasQuest and self:hasQuest("shertul-fortress") then self:hasQuest("shertul-fortress"):gain_energy(price/10) end + game.log("You gain %0.2f gold from the transmogrification of %s.", price, o:getName{do_count=true, do_color=true}) +end + +function _M:transmo() + local d = require("mod.dialogs.ShowInventory").new("Transmogrify", self:getInven("INVEN"), function(o) return self:transmoFilter(o) end, function(o, idx) + self:transmoInven(self, inven, idx, o) + end, self) + game:registerDialog(d) + + return {id=true, used=true} +end diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index 83172ce54c..7f86b28b2d 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -563,6 +563,18 @@ function _M:changeLevel(lev, zone, keep_old_lev, force_down, auto_zone_stair) return end + -- Transmo! + local p = self:getPlayer(true) + if p:attr("has_transmo") then + local inven = p:getInven("INVEN") + for i = #inven, 1, -1 do + local o = inven[i] + if o.__transmo then + p:transmoInven(inven, i, o) + end + end + end + -- Finish stuff registered for the previous level self:onTickEndExecute() @@ -1392,7 +1404,7 @@ function _M:setupCommands() USERCHAT_SHOW_TALK = function() self.show_userchat = not self.show_userchat end, - + TOGGLE_BUMP_ATTACK = function() if (self.bump_attack_disabled) then self.log("Movement Mode: #LIGHT_GREEN#Default#LAST#.") @@ -1401,7 +1413,7 @@ function _M:setupCommands() self.log("Movement Mode: #LIGHT_RED#Passive#LAST#.") self.bump_attack_disabled = true end - + -- Update tooltip display if we're hovering over the icon. local mx, my = core.mouse.get() if (mx < self.icons.w and my > self.icons.display_y) then diff --git a/game/modules/tome/class/Object.lua b/game/modules/tome/class/Object.lua index b6718e9a0a..66cabae4ad 100644 --- a/game/modules/tome/class/Object.lua +++ b/game/modules/tome/class/Object.lua @@ -957,6 +957,9 @@ function _M:getDesc(name_param, compare_with, never_compare) if self.__new_pickup then desc:add({"font","bold"},{"color","LIGHT_BLUE"},"Newly picked up",{"font","normal"},{"color","LAST"},true) end + if self.__transmo then + desc:add({"font","bold"},{"color","YELLOW"},"This item will automatically be transmogrified when you leave the level.",{"font","normal"},{"color","LAST"},true) + end name_param = name_param or {} name_param.do_color = true diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index a4c6bdad43..19a499a92b 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -159,7 +159,15 @@ function _M:describeFloor(x, y) local i, nb = 1, 0 local obj = game.level.map:getObject(x, y, i) while obj do - if not ((obj.auto_pickup and not obj.unique) and self:pickupFloor(i, true)) then + local desc = true + if (obj.auto_pickup and not obj.unique) and self:pickupFloor(i, true) then desc = false end + if self:attr("has_transmo") and obj.__transmo == nil then + if self:pickupFloor(i, true) then + desc = false + obj.__transmo = true + end + end + if desc then if self:attr("auto_id") and obj:getPowerRank() <= self.auto_id then obj:identify(true) end nb = nb + 1 i = i + 1 @@ -1048,7 +1056,7 @@ end function _M:attackOrMoveDir(dir) local tmp = game.bump_attack_disabled - + game.bump_attack_disabled = false self:moveDir(dir) game.bump_attack_disabled = tmp diff --git a/game/modules/tome/data/general/objects/quest-artifacts.lua b/game/modules/tome/data/general/objects/quest-artifacts.lua index fe8e8808ad..1afa38af9f 100644 --- a/game/modules/tome/data/general/objects/quest-artifacts.lua +++ b/game/modules/tome/data/general/objects/quest-artifacts.lua @@ -339,4 +339,11 @@ You have heard of such items before. They are very useful to adventurers, allowi return {id=true, used=true} end }, + + on_drop = function(self, who) + if who == game.player then + game.logPlayer(who, "You cannot bring yourself to drop the %s", self:getName()) + return true + end + end, } diff --git a/game/modules/tome/data/gfx/metal-ui/inven_tabs/chest.png b/game/modules/tome/data/gfx/metal-ui/inven_tabs/chest.png new file mode 100644 index 0000000000000000000000000000000000000000..570a71d7cfe771049aae7d0a4a8b222110933bb6 GIT binary patch literal 4802 zcmV;z5<TsSP)<h;3K|Lk000e1NJLTq002M$002M;1^@s6s%dfF00009a7bBm000d- z000d-0Rti)g#Z8m1ZP1_K>z@;o?%Qu_W%F@AY({UO#lFY3;+OyYXAWQNdN$VivR#n zwEzJI{{R3x-2ea_2y$;MKmY&|I7vi7RCwC#n|X{RXLZ1Tb@qK<(=$Ei&R*Wj>$S1H z-q;4?1#Ck&9Y6$<5C?%26i~uHLE*@SLL@{82oWI}fk;9y#8|em0ULXLuI;@%JKmjR z=jiF_p6;2RzPq}vFMoK}F^*AWlQEGzPx@4!O8r&U`}KSEj;fM`5WJp6=5;Px0JZ>Z z0oVet1z-!n7Jw}PTL88IYysE;umxZXz!relpQx{NK{OhDVJ?I~*LAYlEcJRFP1A|S z;`&WD-+b8T^Nsa-y<RXBp1Aj(d!Kvav16v9YDkiV>pDo1gb)Hv_o92eIF^ZFbU?Uh znuf>Yq0{Lg%g_Hup->1}mht&~v|23yT-W^{*H<VMHW$FJ6Wej|`SpXUrhWdQhaNgw zt*&dWPFHHTTB|+7n9+1^RX|sg<c6kdYp!FT7eY+iwp~^fd(Czn!*QGz!bMfp|GyUS za^kq)^9SGEKREQYNHo#EwpPQUMKGulkH^!7(Mv0`gra#6iVwx@U|S}Nq96n{$8l!5 z-R`Q<?c{q#cM9PYEX!JU9A`z6q$SsN+qP|IWmz_b5Uc;M0JuUz_xRp7wtd&P$95kK zoqhH+t#%uqu98fpgyv78>AK{0E9|-QEv#3{O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5g2&wCpwwz^jpTI!ihkmrTo)!?B1ocVR}UueVfLMUh+~flMNmmM+<|S43kG zbEQ-?jy-%#Y_#Dq41<x8VUE7}DE$Ki-2b!tdF-*re&rmu+;R(d-F4S%_kzSLqAba% zswxy&c2rHZB}wW5?TwpU!?Nwh-o5+kAN}ZU4Ub3fYO3~{ea$IteL4C%mn{HW0JZ?U czU99L0Jasej)=(WmH+?%07*qoM6N<$f(Fl8PXGV_ literal 0 HcmV?d00001 diff --git a/game/modules/tome/data/zones/shertul-fortress/objects.lua b/game/modules/tome/data/zones/shertul-fortress/objects.lua index 737e801a7b..1133bc9bdf 100644 --- a/game/modules/tome/data/zones/shertul-fortress/objects.lua +++ b/game/modules/tome/data/zones/shertul-fortress/objects.lua @@ -29,45 +29,30 @@ newEntity{ base = "BASE_WAND", desc = [[This chest is an extension of Yiilkgur, any items dropped inside is transported to the Fortress, processed by the core and destroyed to extract energy. The byproduct of this effect is the creation of gold, which is useless to the Fortress, so it is sent back to you. -When activated it will prompt to destroy items on the floor, if there are none it prompts for your inventory.]], +When you possess the chest all items you walk upon will automatically be put inside and transmogrified when you leave the level. +Simply go to your inventory to move them out of the chest if you wish to keep them. +Items in the chest will not encumber you.]], cost = 0, quest=true, + carrier = { + has_transmo = 1, + }, +--[[ max_power = 1000, power_regen = 1, - pricemod = function(o) if o.type == "gem" then return 0.40 else return 0.05 end end, - transmo_filter = function(o) if o:getPrice() <= 0 or o.quest then return false end return true end, - transmo_inven = function(self, who, inven, idx, o) - local price = math.min(o:getPrice() * self.pricemod(o), 25) * o:getNumber() - local price = math.min(o:getPrice() * self.pricemod(o), 25) * o:getNumber() - price = math.floor(price * 100) / 100 -- Make sure we get at most 2 digit precision - if price ~= price or not tostring(price):find("^[0-9]") then price = 1 end -- NaN is the only value that does not equals itself, this is the way to check it since we do not have a math.isnan method - who:removeObject(who:getInven("INVEN"), idx, true) - who:sortInven() - who:incMoney(price) - who:hasQuest("shertul-fortress"):gain_energy(price/10) - game.log("You gain %0.2f gold from the transmogrification of %s.", price, o:getName{do_count=true, do_color=true}) - end, use_power = { name = "open a portal to send items to the Fortress core, extracting energies from it for the Fortress and sending back useless gold.", power = 0, use = function(self, who) - -- On the floor or inventory - if game.level.map:getObjectTotal(who.x, who.y) > 0 then - local x, y = who.x, who.y - local d = require("mod.dialogs.ShowPickupFloor").new("Transmogrify", x, y, self.transmo_filter, function(o, idx) - local price = math.min(o:getPrice() * self.pricemod(o), 25) * o:getNumber() - game.level.map:removeObject(x, y, idx) - who:incMoney(price) - who:hasQuest("shertul-fortress"):gain_energy(price/10) - game.log("You gain %0.2f gold from the transmogrification of %s.", price, o:getName{do_count=true, do_color=true}) - end, "Transmogrify all", who) - game:registerDialog(d) - else - local d = require("mod.dialogs.ShowInventory").new("Transmogrify", who:getInven("INVEN"), self.transmo_filter, function(o, idx) - self:transmo_inven(who, inven, idx, o) - end, who) - game:registerDialog(d) - end + who:transmo() return {id=true, used=true} end }, +]] + + on_drop = function(self, who) + if who == game.player then + game.logPlayer(who, "You cannot bring yourself to drop the %s", self:getName()) + return true + end + end, } newEntity{ base = "BASE_CLOTH_ARMOR", diff --git a/game/modules/tome/dialogs/ShowEquipInven.lua b/game/modules/tome/dialogs/ShowEquipInven.lua index bee368ee98..6514e06326 100644 --- a/game/modules/tome/dialogs/ShowEquipInven.lua +++ b/game/modules/tome/dialogs/ShowEquipInven.lua @@ -50,7 +50,7 @@ function _M:init(title, actor, filter, action, on_select) end } - self.c_tabs = ImageList.new{width=self.iw - 20 - self.c_doll.w, height=36, tile_w=32, tile_h=32, padding=5, force_size=true, selection="ctrl-multiple", list={ + local tabslist = { {image="metal-ui/inven_tabs/weapons.png", kind="weapons", desc="All kinds of weapons"}, {image="metal-ui/inven_tabs/armors.png", kind="armors", desc="All kinds of armours"}, {image="metal-ui/inven_tabs/jewelry.png", kind="jewelry", desc="Rings and Amulets"}, @@ -58,7 +58,10 @@ function _M:init(title, actor, filter, action, on_select) {image="metal-ui/inven_tabs/inscriptions.png", kind="inscriptions", desc="Infusions, Runes, ..."}, {image="metal-ui/inven_tabs/misc.png", kind="misc", desc="Miscellaneous"}, {image="metal-ui/inven_tabs/quests.png", kind="quests", desc="Quest and plot related items"}, - }, fct=function() self:generateList() end, on_select=function(item) self:select(item) end} + } + if actor:attr("has_transmo") then tabslist[#tabslist+1] = {image="metal-ui/inven_tabs/chest.png", kind="transmo", desc="Transmogrification Chest"} end + + self.c_tabs = ImageList.new{width=self.iw - 20 - self.c_doll.w, height=36, tile_w=32, tile_h=32, padding=5, force_size=true, selection="ctrl-multiple", list=tabslist, fct=function() self:generateList() end, on_select=function(item) self:select(item) end} self.c_tabs.dlist[1][1].selected = true self.c_tabs.no_keyboard_focus = true @@ -91,8 +94,8 @@ function _M:init(title, actor, filter, action, on_select) self:use(list[list.chars[c]]) end end, - _TAB = function() self.c_tabs.sel_j = 1 self.c_tabs.sel_i = util.boundWrap(self.c_tabs.sel_i+1, 1, 7) self.c_tabs:onUse("left") end, - [{"_TAB","ctrl"}] = function() self.c_tabs.sel_j = 1 self.c_tabs.sel_i = util.boundWrap(self.c_tabs.sel_i-1, 1, 7) self.c_tabs:onUse("left", false) end, + _TAB = function() self.c_tabs.sel_j = 1 self.c_tabs.sel_i = util.boundWrap(self.c_tabs.sel_i+1, 1, 8) self.c_tabs:onUse("left") end, + [{"_TAB","ctrl"}] = function() self.c_tabs.sel_j = 1 self.c_tabs.sel_i = util.boundWrap(self.c_tabs.sel_i-1, 1, 8) self.c_tabs:onUse("left", false) end, } self.key:addBinds{ HOTKEY_1 = function() self:defineHotkey(1) end, @@ -157,6 +160,7 @@ function _M:init(title, actor, filter, action, on_select) SWITCH_PARTY_5 = function() self.c_tabs.sel_j = 1 self.c_tabs.sel_i = 5 self.c_tabs:onUse("left") end, SWITCH_PARTY_6 = function() self.c_tabs.sel_j = 1 self.c_tabs.sel_i = 6 self.c_tabs:onUse("left") end, SWITCH_PARTY_7 = function() self.c_tabs.sel_j = 1 self.c_tabs.sel_i = 7 self.c_tabs:onUse("left") end, + SWITCH_PARTY_8 = function() self.c_tabs.sel_j = 1 self.c_tabs.sel_i = 8 self.c_tabs:onUse("left") end, ORDER_PARTY_1 = function() self.c_tabs.sel_j = 1 self.c_tabs.sel_i = 1 self.c_tabs:onUse("left", true) end, ORDER_PARTY_2 = function() self.c_tabs.sel_j = 1 self.c_tabs.sel_i = 2 self.c_tabs:onUse("left", true) end, ORDER_PARTY_3 = function() self.c_tabs.sel_j = 1 self.c_tabs.sel_i = 3 self.c_tabs:onUse("left", true) end, @@ -164,6 +168,7 @@ function _M:init(title, actor, filter, action, on_select) ORDER_PARTY_5 = function() self.c_tabs.sel_j = 1 self.c_tabs.sel_i = 5 self.c_tabs:onUse("left", true) end, ORDER_PARTY_6 = function() self.c_tabs.sel_j = 1 self.c_tabs.sel_i = 6 self.c_tabs:onUse("left", true) end, ORDER_PARTY_7 = function() self.c_tabs.sel_j = 1 self.c_tabs.sel_i = 7 self.c_tabs:onUse("left", true) end, + ORDER_PARTY_8 = function() self.c_tabs.sel_j = 1 self.c_tabs.sel_i = 87 self.c_tabs:onUse("left", true) end, } -- Add tooltips @@ -226,12 +231,13 @@ function _M:use(item, button, event) end local tab_filters = { - weapons = function(o) return o.type == "weapon" end, - armors = function(o) return o.type == "armor" end, - gems = function(o) return o.type == "gem" or o.type == "alchemist-gem" end, - jewelry = function(o) return o.type == "jewelry" end, - inscriptions = function(o) return o.type == "scroll" end, - quests = function(o) return o.plot or o.quest end, + weapons = function(o) return not o.__transmo and (o.type == "weapon") end, + armors = function(o) return not o.__transmo and (o.type == "armor") end, + gems = function(o) return not o.__transmo and (o.type == "gem" or o.type == "alchemist-gem") end, + jewelry = function(o) return not o.__transmo and (o.type == "jewelry") end, + inscriptions = function(o) return not o.__transmo and (o.type == "scroll") end, + quests = function(o) return not o.__transmo and (o.plot or o.quest) end, + transmo = function(o) return o.__transmo end, } function _M:updateTabFilter() @@ -245,6 +251,7 @@ function _M:updateTabFilter() elseif item.data.kind == "jewelry" then checks[#checks+1] = tab_filters.jewelry elseif item.data.kind == "inscriptions" then checks[#checks+1] = tab_filters.inscriptions elseif item.data.kind == "quests" then checks[#checks+1] = tab_filters.quests + elseif item.data.kind == "transmo" then checks[#checks+1] = tab_filters.transmo elseif item.data.kind == "misc" then local misc misc = function(o) diff --git a/game/modules/tome/dialogs/UseItemDialog.lua b/game/modules/tome/dialogs/UseItemDialog.lua index b2de7bea0a..f5e8041c5c 100644 --- a/game/modules/tome/dialogs/UseItemDialog.lua +++ b/game/modules/tome/dialogs/UseItemDialog.lua @@ -77,9 +77,12 @@ function _M:use(item) elseif act == "transmo" then self:yesnoPopup("Transmogrify", "Really transmogrify "..self.object:getName{}, function(ret) if not ret then return end - item.transmo:transmo_inven(self.actor, self.inven, self.item, self.object) + self.actor:transmoInven(self.inven, self.item, self.object) self.onuse(self.inven, self.item, self.object, false) end) + elseif act == "toinven" then + self.object.__transmo = false + self.onuse(self.inven, self.item, self.object, false) elseif act == "chat-link" then profile.chat.uc_ext:sendObjectLink(self.object) end @@ -88,13 +91,17 @@ end function _M:generateList() local list = {} - local transmo_chest = self.actor:findInAllInventoriesBy("define_as", "TRANSMO_CHEST") + local transmo_chest = self.actor:attr("has_transmo") - if self.object:canUseObject() then list[#list+1] = {name="Use", action="use"} 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 self.inven ~= self.actor.INVEN_INVEN and self.object:wornInven() then list[#list+1] = {name="Take off", action="takeoff"} end + if not self.object.__transmo then + if self.object:canUseObject() then list[#list+1] = {name="Use", action="use"} 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 self.inven ~= self.actor.INVEN_INVEN and self.object:wornInven() then list[#list+1] = {name="Take off", action="takeoff"} end + else + list[#list+1] = {name="Move to normal inventory", action="toinven"} + end if self.inven == self.actor.INVEN_INVEN then list[#list+1] = {name="Drop", action="drop"} end - if self.inven == self.actor.INVEN_INVEN and transmo_chest and transmo_chest.transmo_filter(self.object) then list[#list+1] = {name="Transmogrify", action="transmo", transmo=transmo_chest} end + if self.inven == self.actor.INVEN_INVEN and transmo_chest and self.actor:transmoFilter(self.object) then list[#list+1] = {name="Transmogrify now", action="transmo"} end if profile.auth and profile.hash_valid then list[#list+1] = {name="Link item in chat", action="chat-link"} end self.max = 0 -- GitLab