Skip to content

Player inventory backend

Items a player holds. A stack is a count of one item (potions, keys). A unique item is a set of pieces of its own, each with an id and integer attributes (a sword with its power). Stores, Quests and the trading modules grant and take items through it.

Economy → Items. One row per item.

FieldMeaning
keyThe id of the item, such as potion.
name, description, icon, tagsWhat the game shows.
kindstack or unique.
stackFor a stack, the most one player holds, 0 for no limit.
tradableWhether a module that moves items between players may take the item from a player.
FunctionKindCallerArgumentsResult
listqueryclientnone[{item, name, icon, kind, count, id?, attributes?}]
grantmutationserver, other modules{item, count?, id?, attributes?}{item, count?, ids}
takemutationserver, other modules{item?, count?, id?, tradable?}{item, count?, id?, attributes?}
  • list returns a row per stack with its count, then a row per unique piece with its id, attributes and a count of 1, each with the key, the name, the icon and the kind of its item.
  • grant adds count (1 by default) to a stack, or count new pieces of a unique item with new ids and the given attributes. A piece given with an id keeps it: it moves from another player.
  • take takes count of a stack, or one piece by its id, and returns what it took. With tradable: true it refuses an item that is not tradable.
CodeWhen
unknown_itemThe item is not in the catalog.
invalid_countThe count is not positive.
stack_fullThe stack would go over its limit.
not_enoughThe player holds fewer of the item.
no_such_pieceThe player holds no piece with that id.
piece_takenThe player already holds a piece with that id.
not_tradableThe item cannot be traded.

The Overview of the player card lists what the player holds, with Take on each row and Grant above them.

A player holds at most about 800 kinds of stacks and 800 unique pieces.