API:GetSingleItem
From RoR Wiki
UI Lua API · Item functions
Version: WAR 1.4.8
Returns the data of the item in one slot of one item location.
item = GetSingleItem(location, slot, includeEmpty)
Arguments
- location
number– AGameData.ItemLocsvalue. See the table below.- slot
number– Slot inside that location, starting at 1.- includeEmpty
boolean–trueto get a table even when the slot is empty.
Returns
- item
table– An item data table, or nothing (see Details).
Details
- Accepted locations and the highest slot number the client accepts for each:
| Location | Value | Highest slot |
|---|---|---|
GameData.ItemLocs.EQUIPPED |
2 | 27 |
GameData.ItemLocs.INVENTORY |
3 | 80 |
GameData.ItemLocs.BANK |
4 | 241 |
GameData.ItemLocs.QUEST_ITEM |
9 | 65 |
GameData.ItemLocs.INVENTORY_OVERFLOW |
20 | – |
GameData.ItemLocs.CRAFTING_ITEM |
30 | 80 |
GameData.ItemLocs.CURRENCY_ITEM |
31 | 132 |
- Nothing is returned when the location is not in the table, when
slotis 0 or above the limit, or when the slot is empty andincludeEmptyisfalse. - With
includeEmpty = truean empty slot gives a table with default values (id0, emptyname). - For
INVENTORY_OVERFLOWtheslotargument is ignored: the client picks the slot from the overflow contents itself. GetOverflowData is the function the stock UI uses for the overflow. - The limits are the client's upper bounds. They are larger than the number of slots a player normally has, so check the slot count yourself.
includeEmptymust be a real boolean. Passingnilor a number raises an Invalid Parameters error.- The function needs at least three arguments and only reads the last three.
Errors
None besides the generic Invalid Parameters message when an argument has the wrong type.
Example
Refreshing one bank slot, from default/ea_bankwindow/source/bankwindow.lua:
local itemData = GetSingleItem( GameData.ItemLocs.BANK, slot, false ) BankWindow.items[slot] = itemData
