Skip to content

Tile code functions

define_tile_code

source

function define_tile_code(tile_code: string): TILE_CODE
tile_code: string

Returns TILE_CODE

Define a new tile code, to make this tile code do anything you have to use either set_pre_tile_code_callback or set_post_tile_code_callback. If a user disables your script but still uses your level mod nothing will be spawned in place of your tile code.

get_short_tile_code

source

function get_short_tile_code(short_tile_code_def: ShortTileCodeDef): integer?
short_tile_code_def: ShortTileCodeDef

Returns integer? (may be nil)

Gets a short tile code based on definition, returns nil if it can't be found

get_short_tile_code_definition

source

function get_short_tile_code_definition(short_tile_code: SHORT_TILE_CODE): ShortTileCodeDef?
short_tile_code: SHORT_TILE_CODE

Returns ShortTileCodeDef? (may be nil)

Gets the definition of a short tile code (if available), will vary depending on which file is loaded

set_post_tile_code_callback

source

function set_post_tile_code_callback(cb: fun(x: number, y: number, layer: integer, room_template: integer), tile_code: string): CallbackId
cb: fun(x: number, y: number, layer: integer, room_template: integer)
tile_code: string

Returns CallbackId

Add a callback for a specific tile code that is called after the game handles the tile code. Use this to affect what the game or other scripts spawned in this position. This is received even if a previous pre-tile-code-callback has returned true
The callback signature is nil post_tile_code(float x, float y, int layer, ROOM_TEMPLATE room_template)

set_pre_tile_code_callback

source

function set_pre_tile_code_callback(cb: fun(x: number, y: number, layer: integer, room_template: integer): boolean, tile_code: string): CallbackId
cb: fun(x: number, y: number, layer: integer, room_template: integer): boolean
Returning nil (or nothing): treated as false.
tile_code: string

Returns CallbackId

Add a callback for a specific tile code that is called before the game handles the tile code. Return true in order to stop the game or scripts loaded after this script from handling this tile code. For example, when returning true in this callback set for "floor" then no floor will spawn in the game (unless you spawn it yourself)
The callback signature is bool pre_tile_code(float x, float y, int layer, ROOM_TEMPLATE room_template)