Inventory

Players' inventories, held by the server. Each change is all or nothing, and returns { ok, code, revision, items }. A refused change has ok false and a code, such as invalidItem, invalidAmount, insufficientItems, inventoryCapacity, unknownItem or staleRevision. Passing `revision` refuses the request if the inventory has changed. Rows are { id, item, name, amount, quality, health, condition, equipped, metadata }. Events are playerInventoryReady, playerInventoryChanged and playerItemUsed. On the client, Inventory.whenUsed takes over chosen items' actions on the inventory screen.

inventory.classes()

Inventory.classes()

All item classes in the game's catalogue, with id, name, nameKey, category, maximumQuality, quest, slot and model, the ground mesh, or '' if the tables give none.

inventory.setWearRates()

Inventory.setWearRates(table)

Scales how fast items wear, where 1 is the game's rate, 0 none and 2 twice as fast. A rate for an item, by table name or GUID, beats its category, such as meleeWeapon, missileWeapon, armor, helmet, hood or ammo, which beats `default`. Repairs are never scaled.

inventory.getWearRates()

Inventory.getWearRates()

The wear rates now set.

inventory.itemPrice()

Inventory.itemPrice(item, metadata)

The game's price for one unit, in money units, which are tenths of a groschen. `pristine` is at the best health its quality allows, and `current` at its own health. Null for an unknown class.

inventory.renameItem()

Inventory.renameItem(item, name)

Renames an item in all players' games, along with other classes sharing its name, until the server stops. null restores the game's name. Returns the GUIDs renamed.

inventory.overrideStats()

Inventory.overrideStats(item, stats)

Overrides a class's combat values for all current and future players until the server stops, or restores them with null or {}. Values belong to the class, so all copies change and apply from the next hit. A set names only the stats it changes, and replaces the previous set entirely, while Items.override's weight, price, max and durability stay. A melee weapon takes attack, attackModStab, attackModSlash, attackModSmash, defense, strReq and agiReq. Armour, a helmet or a hood takes defenseStab, defenseSlash, defenseSmash, noise and strReq. A missile weapon takes power, defense, strReq and agiReq, while limbResistance is not supported yet and throws. Ammunition takes attackStab, attackSlash, attackSmash and powerMod. Throws a TypeError for an unknown class, a class with none of these, a name its kind lacks, or a value out of range. Returns true.

inventory.itemStats()

Inventory.itemStats(item)

The combat numbers overrideStats set on a class, by name, or null if unchanged. The server does not read the game's numbers. Throws a TypeError for an unknown class.

inventory.get()

Inventory.get(owner)

A player's inventory as { revision, items, quickslots, ready }, or null.

inventory.add()

Inventory.add(owner, request)

Adds units of one item class to the row with the same properties, or a new row.

inventory.remove()

Inventory.remove(owner, request)

Takes units out of rows.

inventory.editCustom()

Inventory.editCustom(owner, request)

Changes only the named custom fields of a row, and null resets one.

inventory.editRow()

Inventory.editRow(owner, request)

Replaces a row's properties, keeping its id and amount.

inventory.set()

Inventory.set(owner, request)

Replaces the whole inventory. Equipped pieces must fit on a body together, otherwise it returns invalidEquipment.

inventory.transfer()

Inventory.transfer(source, target, request)

Moves exact units with their properties between inventories, all or nothing.

inventory.setStolenMarks()

Inventory.setStolenMarks(enabled)

Turns the game's stolen marks, the red hand and merchants refusing stolen goods, on or off for all players.

inventory.stolenMarks

stolenMarks

Whether the game marks items as stolen.

inventory.whenUsed()

Inventory.whenUsed(item, handler)

Client only. Takes over an item's actions on the inventory screen: 'secondary' to eat, drink or apply, 'primary' for the hint bar's action, and 'activate' for the equip toggle. The game then does nothing itself, and the handler receives { item, uid, id, revision, amount, action }, so consume anything on the server. The newest handler for an item instance beats one for its class. Returns the registration id.

inventory.stopWhenUsed()

Inventory.stopWhenUsed(id)

Client only. Removes a whenUsed handler.