Module items

Item handling functions and type.

Functions

acquirement_items () See the items offered by acquirement.
equipped_at (where) 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.can_zombify Can this be a zombie?
Item.cursed Is this item cursed?
Item.damage Item base damage.
Item.delay Item base delay.
Item.dropped Did we drop this?
Item.encumbrance Item encumbrance rating.
Item.equip_type The slot number this item goes in.
Item.equipped Is this equipped?
Item.fully_identified Is this fully identified?
Item.god_gift Is this a god gift?
Item.has_skeleton Does this have a skeleton?
Item.ininventory Is this item in the inventory?
Item.inscription Item inscription string.
Item.is_corpse Is this a corpse?
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_skeleton Is this a skeleton?
Item.is_throwable Can this be thrown effectively?
Item.is_useless Is this useless?
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.worn Are we wearing this item?
Item:class ([terse=false]) What is the item class?
Item:drop ([qty]) Drop this.
Item:ego ([terse=false]) What is the ego?
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:puton () Put this item on (as jewellry).
Item:remove () Remove this item from our body.
Item:subtype () What is the subtype?
Item:wear () Wear this item (as armour).
Item:wield () Wield this item.


Functions

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

Returns:

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

Parameters:

  • where string or int

Returns:

    Item or nil returns nil for nothing equiped 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.can_zombify
Can this be a zombie?
  • can_zombify boolean
Item.cursed
Is this item cursed?
  • cursed boolean
Item.damage
Item base damage.
  • damage int
Item.delay
Item base delay.
  • delay int
Item.dropped
Did we drop this?
  • dropped boolean
Item.encumbrance
Item encumbrance rating.
  • encumbrance int
Item.equip_type
The slot number this item goes in.
  • equip_type int
Item.equipped
Is this equipped?
  • equipped boolean
Item.fully_identified
Is this fully identified?
  • fully_identified boolean
Item.god_gift
Is this a god gift?
  • god_gift boolean
Item.has_skeleton
Does this have a skeleton?
  • has_skeleton boolean false if it's not even a corpse
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_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_skeleton
Is this a skeleton?
  • is_skeleton boolean
Item.is_throwable
Can this be thrown effectively?
  • is_throwable boolean
Item.is_useless
Is this useless?
  • is_useless 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.worn
Are we wearing this item?
  • worn slot index
Item:class ([terse=false])
What is the item class?

Parameters:

  • terse boolean (default false)

Returns:

    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: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:puton ()
Put this item on (as jewellry).

Returns:

    boolean successfuly put on
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
Item:wear ()
Wear this item (as armour).

Returns:

    boolean successfuly worn
Item:wield ()
Wield this item.

Returns:

    boolean successfuly wielded
generated by LDoc 1.4.6 Last updated 2021-01-09 22:46:05