Inventory .max=0 chokes on wield
Posted: Sat May 31, 2025 3:39 pm
Admittedly, this is kind of a corner case; I ran into it while playing a Mekurabe character from mannendake's Youkai Pack addon, which, among other things, has its inventory defined with CLOAK=0. I was testing whether Enhanced Wield Replace handles this case properly, and I tripped over this error in the base game:
The relevant code in ActorInventory:takeoffObject() is:
This is called with item=1 and an empty inventory, resulting in a nil value for o, so that the o:check() call chokes.
(For now I'm papering over this bug in Enhanced Wield Replace.)
Code: Select all
Lua Error: /engine/interface/ActorInventory.lua:575: attempt to index local 'o' (a nil value)
At [C]:-1 __index
At /engine/interface/ActorInventory.lua:575 takeoffObject
At /engine/interface/ActorInventory.lua:545 wearObject
At /mod/class/Actor.lua:8020 doWear
At /mod/dialogs/UseItemDialog.lua:86 use
At /mod/dialogs/UseItemDialog.lua:44 fct
At /engine/ui/List.lua:155 onUse
At /engine/ui/List.lua:86
At /engine/KeyBind.lua:231 receiveKey
At /engine/ui/Dialog.lua:825 keyEvent
At /engine/ui/Dialog.lua:512
Code: Select all
function _M:takeoffObject(inven_id, item)
inven = self:getInven(inven_id)
if not inven then return false end
local o = inven[item]
if o:check("on_cantakeoff", self, inven) then return false end
(For now I'm papering over this bug in Enhanced Wield Replace.)