Thread Tools Display Modes
Prev Previous Post   Next Post Next
11/18/14, 10:08 AM   #1
brekal
Guest
Posts: n/a
FindFirstEmptySlotInBag not updating

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:
  1. function LootManager.GetIngredientsFromBank()
  2.     local name
  3.     local item
  4.     local slotId
  5.     local count
  6.     local bagId = BAG_BANK
  7.     local slots = GetBagSize(bagId)
  8.     local slotId_Bag
  9.     local bag_Dest = BAG_BACKPACK
  10.  
  11.     for i=0, slots - 1 do
  12.         slotId = i
  13.         name = zo_strformat(SI_UNIT_NAME, GetItemName(bagId, slotId))
  14.         item, count = GetItemInfo(bagId, slotId)
  15.         slotId_Bag = FindFirstEmptySlotInBag(bag_Dest)
  16.  
  17.         if name == LootManager.savedVars.ingredient1 then
  18.             LootManager.MoveItem(bagId, slotId, bag_Dest, slotId_Bag, count)
  19.         end
  20.  
  21.         if name == LootManager.savedVars.ingredient2 then  
  22.             LootManager.MoveItem(bagId, slotId, bag_Dest, slotId_Bag, count)
  23.         end
  24.        
  25.         if name == LootManager.savedVars.ingredient3 then
  26.             LootManager.MoveItem(bagId, slotId, bag_Dest, slotId_Bag, count)
  27.         end
  28.  
  29.     end
  30.  
  31. end
  32.  
  33. ------------------------------------------------------------------------------------------
  34. ------------------------------------------------------------------------------------------
  35.  
  36. function LootManager.MoveItem(srcBag, srcSlot, destBag, destSlot, quantity)
  37.     ClearCursor()
  38.     zo_callLater(function()
  39.         if CallSecureProtected("PickupInventoryItem", srcBag, srcSlot, quantity) then
  40.             CallSecureProtected("PlaceInInventory",destBag, destSlot)
  41.         end
  42.     end, 500)  
  43.     ClearCursor()  
  44.     d("Moved: " .. zo_strformat(SI_UNIT_NAME, GetItemName(srcBag, srcSlot)) .. " x " .. quantity .. " to inventory")
  45.     d("SrcBag: " .. srcBag .. " SrcSlot: " .. srcSlot .. " DestBag: " .. destBag .. " DestSlot: " .. destSlot .. " Quantity: " .. quantity)
  46. end

Do you see any error here?

Thanks in advance
  Reply With Quote
 

ESOUI » Developer Discussions » Lua/XML Help » FindFirstEmptySlotInBag not updating


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off