rock5 wrote:Yeah, I'd do it Lisas way because if a move fails, for whatever reason, it will try to move it again. But you don't need inventory:update() because inventory:findItem does an update already.
k removed the update, wasn't sure about it so added it in just in case lol
the repeat loop might need a check for space in itemshop bag though, if it gets full then the moveto will fail and stay in the loop forever.
the inventory:itemTotalCount() doesn't include item shop when calculating free space, so you would need to add in your own code to check free space of item shop.
Something like this
Code: Select all
local item_shop_bag = {
"Purified Fusion Stone",
"Master's Simple Repair Hammer",
"Grand Golden Repair Hammer"
}
for k,v in pairs(item_shop_bag) do
repeat
local count = 0
for slot = 1, 50 do
local item = inventory.BagSlot[slot]
item:update()
if item.Empty then
count = count + 1
end
end
if count == 0 then print("No space in item shop bag") break end
local item = inventory:findItem(v)
if item then
item:moveTo("itemshop")
end
until not item
end
count would be the number of available spots you can put items in, so count == 0 means you have no space to put the item.