Skip to content

item

One item in your bags or worn on your character.

Returned as array elements by eq2.inventory() and eq2.equipped(), which snapshot the client's item arrays on the game thread.

Like effect, an item is a plain table of values, not of functions — read its fields directly.

for _, it in ipairs(eq2.inventory()) do
  eq2.print(("[%d] %s x%d"):format(it.index, it.name, it.stack))
end

Fields

Field Type Notes
index number Linear array index. This is the argument native item commands take — and for eq2.equipped() it is the equipment slot index.
id number Item id.
name string Item name, with link-tag prefixes stripped.
bag number Raw bag/slot field.
container number Raw container instance id. 0xFFFFFFFF when the item is equipped.
stack number Stack count or charges, where applicable.
level number Raw item level byte.
tier number Raw item tier byte.
flags number Raw action/metadata bitfield.
vectorPos number Same logical position as index; exposed for parity with the raw struct.
is_bag bool Derived from the raw flag bits.
equippable bool Best current gear-equippable test.
icon number Icon id.
num_slots number Bag capacity (bags only).
num_free number Free slots in this bag (bags only).
item_def_id number The item-template id. Pass this to eq2.item_def() for examine-level detail (mitigation, weapon damage, req level, tier, description).
sell_id string Broker/vendor id, as a string — large enough that it's kept out of Lua's double-precision number range.

index is the handle

Item actions are native slash commands that take the linear index, not the name or id:

local inv = require("lib.inventory")
local scroll = inv.find("pure awe")
if scroll then
  eq2.cmdf("scribe_scroll_item %d", scroll.id)
end

Indices move

index is a position in a live array, not a stable identity. Anything that reorders your bags — looting, moving, destroying — invalidates indices you captured earlier. Re-snapshot immediately before acting rather than caching an index across an eq2.delay().

Free space

eq2.inventory() lists what you have; it does not tell you what will fit. For that use Me.FreeInventory() — a full inventory otherwise looks exactly like a silent loot failure.

See also

  • item_def — examine-level detail (mitigation, weapon damage, description) for a specific item, looked up by item_def_id.
  • /inv — the command front-end.
  • lib.inventory — name lookup and action helpers.