Hey guys it's me again ;-)
I have some issues with the function
FindFirstEmptySlotInBag(BAG_BACKPACK).
I want to move items from the bank into my inventory but it always just moves one item.
I dumped the values of the variables and found out that the Destination SlotID (slotId_Bag) always stays the same.
So I think that this is the issue - but unfortunately I cannot image why it is not updating because I call it in every loop of the for-loop so it should update correctly.
Lua Code:
function LootManager.GetIngredientsFromBank()
local name
local item
local slotId
local count
local bagId = BAG_BANK
local slots = GetBagSize(bagId)
local slotId_Bag
local bag_Dest = BAG_BACKPACK
for i=0, slots - 1 do
slotId = i
name = zo_strformat(SI_UNIT_NAME, GetItemName(bagId, slotId))
item, count = GetItemInfo(bagId, slotId)
slotId_Bag = FindFirstEmptySlotInBag(bag_Dest)
if name == LootManager.savedVars.ingredient1 then
LootManager.MoveItem(bagId, slotId, bag_Dest, slotId_Bag, count)
end
if name == LootManager.savedVars.ingredient2 then
LootManager.MoveItem(bagId, slotId, bag_Dest, slotId_Bag, count)
end
if name == LootManager.savedVars.ingredient3 then
LootManager.MoveItem(bagId, slotId, bag_Dest, slotId_Bag, count)
end
end
end
------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
function LootManager.MoveItem(srcBag, srcSlot, destBag, destSlot, quantity)
ClearCursor()
zo_callLater(function()
if CallSecureProtected("PickupInventoryItem", srcBag, srcSlot, quantity) then
CallSecureProtected("PlaceInInventory",destBag, destSlot)
end
end, 500)
ClearCursor()
d("Moved: " .. zo_strformat(SI_UNIT_NAME, GetItemName(srcBag, srcSlot)) .. " x " .. quantity .. " to inventory")
d("SrcBag: " .. srcBag .. " SrcSlot: " .. srcSlot .. " DestBag: " .. destBag .. " DestSlot: " .. destSlot .. " Quantity: " .. quantity)
end
Do you see any error here?
Thanks in advance