kts.ChangeTile

Name

kts.ChangeTile – transform one tile into another

Synopsis

kts.ChangeTile(new_tile)

Description

This function changes the tile cxt.tile, found at cxt.tile_pos in the dungeon, into the tile new_tile instead.

In more detail: If any of cxt.tile_pos or cxt.tile or new_tile are nil, then nothing happens. Otherwise, if a tile equal to cxt.tile is present at cxt.tile_pos, it is removed; and then new_tile is added to the dungeon at that same position.

Return Value

None.

Errors

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

Notes

As an alternative to this function, you could also consider using kts.AddTile and kts.RemoveTile directly, to remove the old tile and add the new one in separate steps.

Examples

This function is used to implement switches. There are two tiles, t_switch_up and t_switch_down, representing switches in the "up" or "down" position respectively. The on_activate function for t_switch_up uses kts.ChangeTile to change the switch into t_switch_down, and vice versa. See tiles.lua.

See Also

The cxt table

kts.AddTile

kts.ChangeItem

kts.RemoveTile

kts.Tile