API:GetInventoryItemData
From RoR Wiki
UI Lua API · Game functions
Version: WAR 1.4.8
Returns the items in the player's backpack, one table per backpack slot.
items = GetInventoryItemData()
Arguments
None.
Returns
- items
table– Array of item data tables, indexed by backpack slot from 1. See Item data table below.
Details
- There is one entry for every backpack slot the player has, including empty slots. An empty slot has an item table with default values (for example
id0 and an emptyname). - If there is no player object, or the Lua state is not available, the function returns nothing.
- A new table is built on every call. The stock UI caches it in
DataUtils.GetItems()(easystem_utils/source/datautils.lua) and rebuilds it only whenGameData.Player.itemsDirtyis set. - The same item data table is used by GetEquipmentData, GetQuestItemData, GetTradeItemData, GetCurrentEnhancementItemData, GetChoiceRewardsData and GetGivenRewardsData.
Item data table
| Key | Type | Meaning |
|---|---|---|
timestamp |
number |
— |
id |
number |
Item id. 0 for an empty slot. |
uniqueID |
number |
Id of this particular item instance. |
name |
wstring |
Item name. For a broken item that has a broken name, this is the broken name (see below). |
description |
wstring |
Description text. |
iconNum |
number |
Icon id for GetIconData. For a broken item that has a broken name, this is the broken icon. |
equipSlot |
number |
Equipment slot the item goes in. 0 if none. |
type |
number |
Item type. |
level |
number |
Required level. |
iLevel |
number |
Item level. |
tier |
number |
— |
renown |
number |
Required renown rank. |
rarity |
number |
Rarity. The client adds 1 to its stored value, so the lowest rarity is 1. |
sellPrice |
number |
Vendor price. |
capacity |
number |
— |
stackCount |
number |
Number of items in the stack. |
races |
table |
Array of race ids (number, 1–7) that may use the item. Empty if there is no race restriction.
|
careers |
table |
Array of career ids (number, 1–31) that may use the item.
|
slots |
table |
Array of slot numbers (number, 1–20) the item can be used on.
|
skills |
table |
Array of skill ids (number, 0–27).
|
flags |
table |
Table of 20 booleans with keys 0–19. Index it with GameData.Item.EITEMFLAG_* values.
|
armor |
number |
Armor value. |
dps |
number |
Damage per second. |
speed |
number |
Weapon speed. |
blockRating |
number |
Block rating. |
itemSet |
number |
Item set id. |
trophyLocation |
number |
— |
trophyLocIndex |
number |
The client adds 1 to its stored value. |
bop |
boolean |
— |
boundToPlayer |
boolean |
— |
isNew |
boolean |
— |
broken |
boolean |
true if the item is broken.
|
repairedName |
wstring |
Only for a broken item that has a broken name: the normal (repaired) name. |
repairedIconNum |
number |
Only for a broken item that has a broken name: the normal icon. |
brokenName |
wstring |
Only for a broken item that has a broken name: the broken name. |
brokenIconNum |
number |
Only for a broken item that has a broken name: the broken icon. |
repairPrice |
number |
Only for a broken item that has a broken name: cost to repair. sellPrice is also replaced in this case.
|
bonus |
table |
Array of bonus tables, indexed from 1, at most 10 entries. See Bonus tables. |
craftingBonus |
table |
Array of crafting bonus tables, indexed from 1. Each has bonusType (number, always 6), bonusReference (number) and bonusValue (number).
|
marketingIndex |
number |
— |
marketingVariation |
number |
— |
numEnhancementSlots |
number |
Number of enhancement (talisman) slots, at most 3. |
enhSlot |
table |
Filled enhancement slots, keyed by slot number from 1. Empty slots have no entry. See Enhancement slot tables. |
noChargeLeftDontDelete |
number |
— |
currChargesRemaining |
number |
Charges left. |
tintA, tintB |
number |
— |
dyeTintA, dyeTintB |
number |
— |
cultivationType |
number |
— |
craftingSkillRequirement |
number |
Crafting skill needed to use the item. |
maxEquip |
number |
— |
isRefinable |
boolean |
— |
timeLeftBeforeDecay |
number |
— |
decayPaused |
boolean |
— |
isTwoHanded |
boolean |
— |
customizedIconNum |
number |
— |
customizedIconName |
wstring |
— |
Bonus tables
Every entry of bonus has a type field. The other fields depend on it. The type numbers match GameDefs.ITEMBONUS_* in easystem_utils/source/gamedefs.lua.
type |
Fields |
|---|---|
2 (ITEMBONUS_MAGIC) |
reference (number, the stat), value (number, may be negative), isPercentage (boolean), duration (number, seconds)
|
3 (ITEMBONUS_USE) |
reference (number), value (number), cooldownTimeLeft (number, seconds), totalCooldownTime (number, seconds)
|
5 (ITEMBONUS_CONTINUOUS) |
reference (number), value (always 0), duration (number, seconds)
|
Bonuses of type 2 are listed first, then type 3, then type 5. The list stops after 10 entries.
Enhancement slot tables
| Key | Type | Meaning |
|---|---|---|
name |
wstring |
Name of the enhancement in the slot. |
id |
number |
Item id of the enhancement. |
iconNum |
number |
Icon id of the enhancement. |
inventorySlot |
number |
— |
rarity |
number |
— |
level |
number |
— |
bonus, craftingBonus, marketingIndex, marketingVariation |
Same layout as on the item itself. |
Errors
None.
Example
From easystem_utils/source/datautils.lua:
function DataUtils.GetItems()
if (GameData.Player.itemsDirty)
then
GameData.Player.itemsDirty = false
DataUtilsData.items = GetInventoryItemData()
end
return DataUtilsData.items
end
Reading flags and bonuses, from easystem_tooltips/source/itemtooltips.lua:
local itemIsSalvagable = (itemData.flags[GameData.Item.EITEMFLAG_MAGICAL_SALVAGABLE] == true);
...
for i, bonus in ipairs(itemData.bonus) do
...
if( bonus.type == GameDefs.ITEMBONUS_MAGIC and bonus.reference > 0 and bonus.value ~= 0 ) then
