kts.ChangeTile – transform one tile into another
kts.ChangeTile(new_tile)
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.
None.
This function raises an error in any of the following cases:
cxt
global variable is undefined or invalid cxt.tile_pos
is neither a valid map position, nor nil
(Note: a "valid map position" means a table containing fields x
and y
giving the co-ordinates of a particular dungeon square) cxt.tile
is neither a valid Tile nor nil
new_tile
is neither a valid Tile nor nil
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.
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.