This is how I'm doing it - first, I iterate through all the inventory slots, and delete any instances found:
Code: Select all
--clear inventory
for i_slot = 0, 29, 1 do
local id = dsb_fetch(PARTY, 0, i_slot, 0)
if (id) then destroy_instance(id) end
end
Code: Select all
function destroy_instance(id)
inv, count = dsb_fetch(IN_OBJ, id, -1, 0)
if(count) and (count > 0) then
for k, v in pairs(inv) do
destroy_instance(v)
end
end
dsb_delete(id)
end
The next part is the part that's giving me problems.
I do a set of dsb_spawns, but it seems to not quite process in order. The newly spawned items get destroyed along with everything else (except when the slot I'm spawning to was empty to start with - in other words, if I spawn to right hand, and the right hand was empty to start with, it works. If there was something there, both are deleted). I'm not quite sure why, but it may be because the function wrapping this inventory reset is immediately followed by a dsb_fullscreen call.
But, if I put the spawns in a delayed function, it works - that's the part I dislike. Once the fullscreen returns, there's a fraction of a second before the inventory blinks into existance. It's not horrible, I'm just wondering if there's a better way.