I'm using your useful spawn_in_pack function in util.lua to add an item to my backpack. I thought I'd test it for when we have the case that the back pack is already full and get the following exception.
Code: Select all
LUA ERROR: base/util.lua:17: dsb_fetch: Invalid inventory index 30
FATAL LUA ERROR: Lua Function FLAME: base/util.lua:21: dsb_spawn: Invalid inventory index 30
Code: Select all
function spawn_in_pack(arch, whose_pack)
local slot = INV_PACK
while(dsb_fetch(CHARACTER, whose_pack, slot, 0)) do
slot = slot + 1
end
return (dsb_spawn(arch, CHARACTER, whose_pack, slot, 0))
end
Code: Select all
function spawn_in_pack(arch, whose_pack)
local slot = INV_PACK
while(dsb_fetch(CHARACTER, whose_pack, slot, 0)) do
slot = slot + 1
-- Backpack full? 30 Slots by default
if (slot >= MAX_INV_SLOTS) then return nil end
end
return (dsb_spawn(arch, CHARACTER, whose_pack, slot, 0))
end