kts.ChangeItem

Name

kts.ChangeItem – transform an item into another

Synopsis

kts.ChangeItem(new_item_type)

Description

This function changes the type of the item at cxt.item_pos (if any) to match the given new_item_type.

In more detail: If any of cxt.item_pos or cxt.item or new_item_type are nil, then this function does nothing. Otherwise, any item currently at position cxt.item_pos is destroyed, and then a newly generated item of type new_item_type is created and added to the dungeon at that same position.

Return Value

None.

Errors

This function raises an error in any of the following cases:

Examples

The bear trap item provides an example of this function being used. When an open bear trap is walked over by a creature, or hit with a weapon, the kts.ChangeItem function is used to change it into a closed bear trap. See items.lua.

See Also

The cxt table

kts.ChangeTile

kts.ItemType