Thread Tools Display Modes
08/25/14, 06:21 AM   #1
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,990
Get dataEntry by help of bagId & slotIndex

Hey community,

is there any easy way to get the "dataEntry" array/table of an item (inside your inventory, or bank, or..) by help of the bagId and slotIndex?

I'd like to check all items inside a bagId and get their dataEntry values.
I only know how to do it if I know the slot control name.

Is there any function like GetItemControl(bagId, slotId)? I did not find any so far.

Thanks for your help.
  Reply With Quote
08/25/14, 06:44 AM   #2
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Backpack:
Lua Code:
  1. local itemData = PLAYER_INVENTORY:GetBackpackItem(slotIndex)

Bank:
Lua Code:
  1. local itemData = PLAYER_INVENTORY:GetBankItem(slotIndex)

Or directly from the table:
Lua Code:
  1. local itemData = PLAYER_INVENTORY.inventories[inventoryType].slots[slotIndex]

inventoryType:
INVENTORY_BACKPACK = 1
INVENTORY_QUEST_ITEM = 2
INVENTORY_BANK = 3
INVENTORY_GUILD_BANK = 4
  Reply With Quote
08/25/14, 07:43 AM   #3
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,990
Thank you very much Garkin.

One more thing I recognized:
If you enable a filter in the inventory the items won't be in the list of
PLAYER_INVENTORY.inventories[bagId].slots[slotIndex]
anymore. They are gone until you disable the filter again.

Is there any list of the inventory items containing ALL items, including the filtered ones?
  Reply With Quote
08/25/14, 08:18 AM   #4
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by Baertram View Post
Is there any function like GetItemControl(bagId, slotId)? I did not find any so far.
There's not a control for every item in every bag. There's only as many as simultaneously visible, and item data is assigned to them as you scroll.

Originally Posted by Baertram View Post
If you enable a filter in the inventory the items won't be in the list of
PLAYER_INVENTORY.inventories[bagId].slots[slotIndex]
anymore. They are gone until you disable the filter again.
Well I'm not sure, but I think they should still be there. Filters are only applied to ScrollList controls' contents afaik. Anyway, while playing with quickslots inventory, I found they use this to get item data (and actually use that to fill inventory.slots, too):
Lua Code:
  1. SHARED_INVENTORY:GenerateSingleSlotData(bagId, slotIndex)
  Reply With Quote
08/25/14, 08:23 AM   #5
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Forgot to add important note: the table returned from SHARED_INVENTORY:GenerateSingleSlotData is cached, and as the name suggests, shared. It must not be modified. Make a copy if you need to.
  Reply With Quote
08/25/14, 09:15 AM   #6
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Baertram View Post
Thank you very much Garkin.

One more thing I recognized:
If you enable a filter in the inventory the items won't be in the list of
PLAYER_INVENTORY.inventories[bagId].slots[slotIndex]
anymore. They are gone until you disable the filter again.

Is there any list of the inventory items containing ALL items, including the filtered ones?
Just a note - bagId is not the same as inventoryType:

BAG_WORN = 0
BAG_BACKPACK = 1
BAG_BANK = 2
BAG_GUILDBANK = 3
BAG_BUYBACK = 4
BAG_TRANSFER = 5
BAG_DELETE = 255

INVENTORY_BACKPACK = 1
INVENTORY_QUEST_ITEM = 2
INVENTORY_BANK = 3
INVENTORY_GUILD_BANK = 4

As you can see only backpack has the same index, bank and guildbank has different indexes (http://wiki.esoui.com/Constants_in_100008_API).



And as merlight said, all slots should be available uf you use:
Lua Code:
  1. SHARED_INVENTORY:GenerateSingleSlotData(bagId, slotIndex)
  Reply With Quote
08/25/14, 11:04 AM   #7
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,990
Yes, I noticed the different between bagId and inventoryId. My variable name copied was the wrong one :-D
  Reply With Quote
08/29/14, 07:51 PM   #8
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
As for your first question, Garkin took care of that. I personally use
Lua Code:
  1. PLAYER_INVENTORY.inventories[inventoryType].slots[slotIndex].dataEntry

Originally Posted by Baertram View Post
Thank you very much Garkin.

One more thing I recognized:
If you enable a filter in the inventory the items won't be in the list of
PLAYER_INVENTORY.inventories[bagId].slots[slotIndex]
anymore. They are gone until you disable the filter again.

Is there any list of the inventory items containing ALL items, including the filtered ones?
I've not used the
Lua Code:
  1. SHARED_INVENTORY:GenerateSingleSlotData(bagId, slotIndex)
that they talked about, but I do know a little about the filters & slot tables you were discussing.


The filters are a small list of information (button textures, description, the button control, ect..) including a filterType which is really just a number. Its all stored in the tabFilters table of an inventory (found in):
Lua Code:
  1. PLAYER_INVENTORY.inventories[inventoryType].tabFilters

Each slot also has one or more filterType numbers assigned to it, which can be found in the slots filterData table:
Lua Code:
  1. -- With the exception of the Quest Inventory, it does not have a filterData table --
  2. PLAYER_INVENTORY.inventories[inventoryType].slots[slotIndex].filterData

When you enable a filter it clears the inventories "listView" (list of all visible items in the Inventory), and rebuilds it only (showing) adding slots (items) to the listView that have the current filterType Number in their filterData table. But the listView and the slots are two separate tables in different locations:
Lua Code:
  1. PLAYER_INVENTORY.inventories[inventoryType].slots[slotIndex]
  2. PLAYER_INVENTORY.inventories[inventoryType].listView



The point is that enabling a filter changes the listView table, it does not change the items listed in the slots table:
Lua Code:
  1. PLAYER_INVENTORY.inventories[inventoryType].slots[slotIndex]
The items are all there regardless of any applied filters.


It sounds like you were looking at:
Lua Code:
  1. PLAYER_INVENTORY.inventories[inventoryType].listView.data
Those are the "visible" items in the inventory. The ones that have a filterType number in their filterData table that matches the current filter. Those do change when filters are applied as it only lists (contains) items that are currently visible.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Get dataEntry by help of bagId & slotIndex


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