Hello, now ive just had a need to make better item mover, so i'd like to share with community
I did not made optional backpack where pots firstly are because usually people want to sort items after magic shop. So thats why it sorting from first backpack( usually main ).
Also you don't have to loop this function:
reason of looping such function is that when you move item, the next indexes are lowered by 1 and for loop just goes ahead.
There is no such problem cause this is recursive function so if it will move item its looping itself.
I hope You enjoy
PHP Code:
toSort = {
{id = Item.GetID('mana potion'), bp = 'brocade backpack'},
{id = Item.GetID('health potion'), bp = 'demon backpack'}
}
function moveItems(table)
local fromBP = Container.GetFirst()
for spot, item in fromBP:iItems() do
for _, data in pairs(table) do
if item.id == data.id then
local toBP = Container.New(data.bp)
fromBP:MoveItemToContainer(spot, toBP:Index(), 0)
wait(Self.Ping() + 100, Self.Ping() + 300)
return moveItems(table)
end
end
end
end
Module.New('ImprovedItemMover', function(this)
moveItems(toSort)
this:Stop()
end)