ItemRef
The inventory interface
Properties
name
ItemRef.name: stringGet the name associated with the item type
type
ItemRef.type: stringGet the type identifier string
count
ItemRef.count: numberGet/Set the item count
level
ItemRef.level: numberGet/Set the item level
group
ItemRef.group: stringGet/Set the item group
group_secondary
ItemRef.group_secondary: stringGet/Set the secondary item group
element
ItemRef.element: stringGet/Set the item element
quest
ItemRef.quest: boolGet/Set the quest flag
Items with this flag are required for game progression.
upgrade
ItemRef.upgrade: boolGet/Set the upgrade flag
Items with this flag mark an upgrade.
skill
ItemRef.skill: boolGet/Set the skill flag
Items with this flag mark a character skill.
temporary
ItemRef.temporary: boolGet/Set the temporary flag
Items with this flag are supposed to be cleared after a stage.
display_bar
ItemRef.display_bar: boolGet/Set the display bar flag
Items with this flag set get displayed in the item bar of the interface.
durability_time
ItemRef.durability_time: boolGet/Set the durability time flag
Items with this flag loose durability for seconds elapsed
display_char
ItemRef.display_char: stringGet/Set the item fallback display character
display_col
ItemRef.display_col: tableGet/Set the item display color
pickup_sound
ItemRef.pickup_sound: stringGet/Set the path to the sound that gets played on item pickup
count_used
ItemRef.count_used: numberGet/Set the item used count
The count gets increased per use and is supposed to be permanent.
durability
ItemRef.durability: numberGet/Set the item durability attribute value.
Functions
reset
ItemRef:reset() → ()Reset the item to generated default values with a count of zero.
add
ItemRef:add(value: number | nil--
amount to add (default 1)
) → ()Add a given count to the item
use
ItemRef:use(value: number | nil--
amount to use (default 1)
) → bool--
success
Attempt to reduce the item count by the given value.
When enough items are held, subtract the count by the given value, add the count to the used counter, and return true.
When not enough items are held, do nothing and return false.
remove
ItemRef:remove(value: number | nil--
amount to remove (default 1)
) → bool--
success
Remove at maximum the given value from the item count.
When not enough items are held, reduce the item count to zero and return false.
When enough items are held, subtract the count by the given value and return true.
The used counter is not updated.
durability_drain
ItemRef:durability_drain(amount: number | nil--
drain amount (default all)
) → ()Drain the item durability by the given amount.
attr_get
ItemItemRef:attr_get(key: string--
attribute identifier
) → number | string | table | nil--
value
Get the value of an item attribute
attr_set_int
ItemItemRef:attr_set_int(key: string,--
attribute identifier
value: number--
value to set
) → ()Set the value of an item attribute to an integer
attr_set_float
ItemItemRef:attr_set_float(key: string,--
attribute identifier
value: number--
value to set
) → ()Set the value of an item attribute to a float
attr_set_string
ItemItemRef:attr_set_string(key: string,--
attribute identifier
value: string--
value to set
) → ()Set the value of an item attribute to a string