Module items

Item handling functions and type.

Functions

acquirement_items (An) See the items offered by acquirement.
equipped_at (Slot, Index) Get the Item in a given equipment slot.
fire (the[, x=0[, y=0[, if=false[, whether=false]]]]) Fire an item in inventory at a target, either an evokable or a throwable ammo.
fired_item () Get the ammo Item we should fire by default.
get_items_at (x, y) List the seen items at a grid cell.
index_to_letter (idx) Get the inventory letter of a slot number.
inslot (idx) What item is in this slot?
inventory () Get the current inventory.
letter_to_index (let) Get the index of an inventory letter.
pickup (what[, qty]) Pick up items.
shop_inventory () See what a shop has for sale.
shopping_list () Look at the shopping list.
swap_slots (idx1, idx2) Swap item slots.

Class Item

item.ac Item base AC.
item.accuracy Item base accuracy.
item.artefact Is this an artefact?
item.artprops Artefact properties Full list in artefact-prop-type.h
item.branded Is this branded?
item.cursed Is this item cursed?
item.damage Item base damage.
item.delay Item base delay.
item.description Item description string, as displayed in the game UI.
item.dropped Did we drop this?
item.encumbrance Item encumbrance rating.
item.equip_type The default slot type this item goes in.
item.equipped Is this equipped?
item.evoke_damage Item evoke damage.
item.god_gift Is this a god gift?
item.ininventory Is this item in the inventory?
item.inscription Item inscription string.
item.is_corpse Is this a corpse?
item.is_enchantable Is this item enchantable?
item.is_identified Is this fully identified?
item.is_in_shop Item is for sale.
item.is_melded Is this item currently melded to us?
item.is_ranged Is this a ranged weapon?
item.is_throwable Can this be thrown effectively?
item.is_useless Is this useless?
item.is_weapon Is this item a weapon?
item.is_xp_evoker Is this an elemental evoker?
item.plus Item plus.
item.quantity How many do we have in a stack?
item.reach_range The reach range of this item.
item.slot This item's inventory slot.
item.spells What spells are in this?
item.weap_skill The weapon skill this item requires.
item:class ([terse=false]) What is the item class?
item:damage_rating () Item damage rating.
item:drop ([qty]) Drop this.
item:ego ([terse=false]) What is the ego?
item:equip () Equip this item.
item:name ([desc="plain"[, terse="false"]]) Get this item's name.
item:name_coloured ([desc="plain"[, terse="false"]]) Get this item's name as a colour-formatted string.
item:remove () Remove this item from our body.
item:subtype () What is the subtype?


Functions

acquirement_items (An)
See the items offered by acquirement. Only works when the acquirement menu is active.

Parameters:

  • An int

    integer indicating the type of acquirement:

                 1: The normal acquirement menu.
                 2: Okawaru weapon gift acquirement.
                 3: Okawaru armour gift acquirement.
                 4: Coglin gizmo acquirement.
    

Returns:

    array or nil An array of Item objects or nil if not acquiring.
equipped_at (Slot, Index)
Get the Item in a given equipment slot. Takes either a slot name or a slot number.

Parameters:

  • Slot string or int type name or index
  • Index int[opt] of item in that slot type (ie: ring #2). Default 1.

Returns:

    Item or nil returns nil for nothing equipped or invalid slot
fire (the[, x=0[, y=0[, if=false[, whether=false]]]])
Fire an item in inventory at a target, either an evokable or a throwable ammo. This will work for launcher ammo, but only if the launcher is wielded. Some evokables (e.g. artefact weapons) may also need to be wielded.

Parameters:

  • the number item's slot
  • x number coordinate (default 0)
  • y number coordinate (default 0)
  • if boolean true, aim at the target; if false, shoot past it (default false)
  • whether boolean to allow fumble throwing of non-activatable items (default false)

Returns:

    boolean whether an action took place
fired_item ()
Get the ammo Item we should fire by default.

Returns:

    Item or nil returns nil if something other than ammo is quivered
get_items_at (x, y)
List the seen items at a grid cell. This function uses player centered coordinates.

Parameters:

  • x int
  • y int

Returns:

    array An array of Item objects
index_to_letter (idx)
Get the inventory letter of a slot number.

Parameters:

  • idx int

Returns:

    string
inslot (idx)
What item is in this slot? Uses numeric slot index, use letter_to_index to look up the index from the number.

Parameters:

  • idx int slot index

Returns:

    Item or nil the item in that slot, nil if none
inventory ()
Get the current inventory.

Returns:

    array An array of Item objects for the current inventory
letter_to_index (let)
Get the index of an inventory letter.

Parameters:

  • let string

Returns:

    int
pickup (what[, qty])
Pick up items. Accepts either a single Item object, and optionally a quantity (for picking up part of a stack), defaulting to the whole stack, or a table of (Item,qty) pairs.

In the first usage returns how many of the single Item were picked up. In the second usage returns how many keys were successfully picked up.

Parameters:

  • what Item or table
  • qty int how many; defaults to the whole stack (optional)

Returns:

    int
shop_inventory ()
See what a shop has for sale. Only works when standing at a shop.

Returns:

    array or nil An array of Item objects or nil if not on a shop
shopping_list ()
Look at the shopping list.

Returns:

    array or nil Array of Items on the shopping list or nil if the shopping list is empty
swap_slots (idx1, idx2)
Swap item slots. Requires item indexes, use letter_to_index if you want to swap letters.

Parameters:

  • idx1 int
  • idx2 int

Class Item

Information and interaction with a single item.
item.ac
Item base AC.
  • ac int
item.accuracy
Item base accuracy.
  • accuracy int
item.artefact
Is this an artefact?
  • artefact boolean
item.artprops
Artefact properties Full list in artefact-prop-type.h
  • artprops table artefact property table
item.branded
Is this branded?
  • branded
item.cursed
Is this item cursed?
  • cursed boolean
item.damage
Item base damage.
  • damage int
item.delay
Item base delay.
  • delay int
item.description
Item description string, as displayed in the game UI.
  • description string
item.dropped
Did we drop this?
  • dropped boolean
item.encumbrance
Item encumbrance rating.
  • encumbrance int
item.equip_type
The default slot type this item goes in.
  • equip_type int
item.equipped
Is this equipped?
  • equipped boolean
item.evoke_damage
Item evoke damage.
  • evoke_damage string The evokable item's damage string.
item.god_gift
Is this a god gift?
  • god_gift boolean
item.ininventory
Is this item in the inventory?
  • ininventory boolean
item.inscription
Item inscription string.
  • inscription string
item.is_corpse
Is this a corpse?
  • is_corpse boolean
item.is_enchantable
Is this item enchantable?
  • is_enchantable boolean
item.is_identified
Is this fully identified?
  • is_identified boolean
item.is_in_shop
Item is for sale.
  • is_in_shop boolean
item.is_melded
Is this item currently melded to us?
  • is_melded boolean
item.is_ranged
Is this a ranged weapon?
  • is_ranged boolean
item.is_throwable
Can this be thrown effectively?
  • is_throwable boolean
item.is_useless
Is this useless?
  • is_useless boolean
item.is_weapon
Is this item a weapon?
  • is_weapon boolean
item.is_xp_evoker
Is this an elemental evoker?
  • is_xp_evoker boolean
item.plus
Item plus.
  • plus int
item.quantity
How many do we have in a stack?
  • quantity int
item.reach_range
The reach range of this item.
  • reach_range int
item.slot
This item's inventory slot.
  • slot index or nil
item.spells
What spells are in this?
  • spells array of spell names
item.weap_skill
The weapon skill this item requires.
  • weap_skill string|nil nil for non-weapons
item:class ([terse=false])
What is the item class?

Parameters:

  • terse boolean (default false)

Returns:

    string
item:damage_rating ()
Item damage rating.

Returns:

  1. number The item's damage rating.
  2. string The item's full damage rating string.
item:drop ([qty])
Drop this. Optionally specify how many for partially dropping a stack.

Parameters:

  • qty int (optional)

Returns:

    boolean successfully dropped
item:ego ([terse=false])
What is the ego?

Parameters:

  • terse boolean (default false)

Returns:

    string or nil the item's ego, if any
item:equip ()
Equip this item.

Returns:

    boolean successfully equipped
item:name ([desc="plain"[, terse="false"]])
Get this item's name. For the levels of item descriptions see crawl.grammar

Parameters:

  • desc string description type (default "plain")
  • terse boolean (default "false")

Returns:

    string
item:name_coloured ([desc="plain"[, terse="false"]])
Get this item's name as a colour-formatted string. Adds item colouring suitable for crawl.formatted_mpr.

Parameters:

  • desc string description type (default "plain")
  • terse boolean (default "false")

Returns:

    string
item:remove ()
Remove this item from our body.

Returns:

    boolean or nil successfully removed something; nil if nothing to remove
item:subtype ()
What is the subtype?

Returns:

    string or nil the item's subtype, if any
generated by LDoc 1.5.0 Last updated 2025-02-23 13:48:52