Thread Tools Display Modes
04/30/15, 06:38 AM   #1
kendaron
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 6
Bank Item Not Showing

Hi all,

For those that do not know, I am the author of CookeryWiz.

It has the ability to collect writ items that need to be crafted, and I have just implemented the ability to automatically collect them from the bank.

Now! I thought it was working fine.. but then I found that it would not work with Garlic Pumpkin Seeds (so far this is the only one I have encountered)

When I enumerate the bank, I see that this particular item is simply not showing up. Has anyone else experienced an item not showing? Is there perhaps a secret to this that I am overlooking?

Apologies if this has been discussed before but I want not quite sure what to search on

Thanks
  Reply With Quote
04/30/15, 07:17 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,991
Do you enumerate from slotindex 0 to slot count -1?

Lua Code:
  1. for slotIndex = 0, GetBagSize(bagId) - 1 do
  2. ---
  3. end

Last edited by Baertram : 04/30/15 at 07:21 AM.
  Reply With Quote
04/30/15, 07:49 AM   #3
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
How do you enumerate gbank ?

PS: You should use n.data.slotIndex to get the real slotindex of an item. where n is your slot.

I personally use ZO_GuildBankBackpack.data, but I think SHARED_INVENTORY should be better.
  Reply With Quote
04/30/15, 10:15 AM   #4
kendaron
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 6
its basically the following

local bagSize = GetBagSize(BAG_BANK)
for i = 1, bagSize do
<snip>
local itemLink = GetItemLink(BAG_BANK, i, linkStyle)
local itemType = GetItemLinkItemType(itemLink)
local itemName = GetItemLinkName(itemLink)
<snip>
end

Is the indexing actually 0 based? I was under the impression most things were 1 based>
  Reply With Quote
04/30/15, 10:24 AM   #5
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
no, as I said, your enumeration isn't correct.

Lua Code:
  1. local bankbag = SHARED_INVENTORY.bagCache[BAG_BANK]
  2.  
  3. for i, data in ipairs(bankbag)
  4.     <snip>
  5.     local itemLink = GetItemLink(BAG_BANK, data.slotIndex, linkStyle)
  6.     local itemType = GetItemLinkItemType(itemLink)
  7.     local itemName = data.name
  8.     <snip>
  9. end


If when you open the GBank, i == index,
do some restacks, ask a guildmate to change some stuff while scanning bank and you'll get your index changed a lot

Take care, if someone change something in bank between the moment of your scan and the moment of you move something, data couldn't be correct.

Last edited by Ayantir : 04/30/15 at 10:28 AM.
  Reply With Quote
04/30/15, 05:33 PM   #6
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,991
Yes the inventories are 0 based, not 1 based!

This happens for the guild bank but not for your own, local bank (isn't it?)
So is there any advantage to use the SHARED_INVENTORY here instead of PLAYER_INVENTORIES.inventories[inventoryType], where inventory type could be the backpack or bank?
  Reply With Quote
04/30/15, 05:55 PM   #7
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Ayantir View Post
no, as I said, your enumeration isn't correct.

Lua Code:
  1. local bankbag = SHARED_INVENTORY.bagCache[BAG_BANK]
  2.  
  3. for i, data in ipairs(bankbag)
  4.     <snip>
  5.     local itemLink = GetItemLink(BAG_BANK, data.slotIndex, linkStyle)
  6.     local itemType = GetItemLinkItemType(itemLink)
  7.     local itemName = data.name
  8.     <snip>
  9. end


If when you open the GBank, i == index,
do some restacks, ask a guildmate to change some stuff while scanning bank and you'll get your index changed a lot

Take care, if someone change something in bank between the moment of your scan and the moment of you move something, data couldn't be correct.
If you use SHARED_INVENTORY this way, it's possible that cache won't be updated. Also I'm not really sure if you can use ipairs, I believe that some indexes could be empty (nil).

You should get bank cache this way:
Lua Code:
  1. local bankCache = SHARED_INVENTORY:GenerateFullSlotData(nil, BAG_BANK)
  2.  
  3. for slotIndex, itemData in pairs(bankCache) do
  4.     --
  5.     local itemLink = GetItemLink(itemData.bagId, itemData.slotIndex, LINK_STYLE_BRACKETS)
  6.     local itemType = itemData.itemType
  7.     local itemName = itemData.rawName
  8.     --
  9. end
  Reply With Quote
04/30/15, 08:05 PM   #8
kendaron
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 6
Yay

I enumerated the player bank as per Garkin's example and those pesky Garlic Pumpkin Seeds popped out of hiding!

Thanks everyone for your assistance





Originally Posted by Garkin View Post
If you use SHARED_INVENTORY this way, it's possible that cache won't be updated. Also I'm not really sure if you can use ipairs, I believe that some indexes could be empty (nil).

You should get bank cache this way:
Lua Code:
  1. local bankCache = SHARED_INVENTORY:GenerateFullSlotData(nil, BAG_BANK)
  2.  
  3. for slotIndex, itemData in pairs(bankCache) do
  4.     --
  5.     local itemLink = GetItemLink(itemData.bagId, itemData.slotIndex, LINK_STYLE_BRACKETS)
  6.     local itemType = itemData.itemType
  7.     local itemName = itemData.rawName
  8.     --
  9. end
  Reply With Quote

ESOUI » AddOns » AddOn Help/Support » Bank Item Not Showing


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