reference monoe.tilemap

Lua API Reference

Represents a 2D tilemap that can place tiles, fill areas, and draw patterns using tilesets.

Properties

NameTypeDescription
uidintegerEngine-side unique ID
tilesetstable, integer> Loaded tilesets by name
lastintegerLast used ID or counter
zindexintegerThe Z index of the tilemap. Won't be used if not used with monoe.layermap.

monoe.tilemap.new

Creates a new `monoe.tilemap` object.

Returns


monoe.tilemap:place

Places a single tile at the specified tile coordinates.

Parameters

NameTypeDescription
tile_xintegerX coordinate on the tilemap
tile_yintegerY coordinate on the tilemap
tileset_namestringName of the tileset
tileset_xintegerX coordinate within the tileset
tileset_yintegerY coordinate within the tileset

monoe.tilemap:load

Loads a tileset into the tilemap.

Parameters

NameTypeDescription
namestringName of the tileset
sourcemonoe.image|stringEither a `monoe.image` or a file path
tile_widthintegerTile width in pixels (default 16)
tile_heightintegerTile height in pixels (default = `tile_width`)

monoe.tilemap:scale

Scales the entire tilemap.

Parameters

NameTypeDescription
xnumberScale factor in X
ynumberScale factor in Y

monoe.tilemap:rectangle

Draws a filled rectangle of tiles.

Parameters

NameTypeDescription
xintegerStarting tile X
yintegerStarting tile Y
widthintegerWidth in tiles
heightintegerHeight in tiles
tilesetstringTileset name
tileset_xintegerTileset X coordinate
tileset_yintegerTileset Y coordinate

monoe.tilemap:fill

Fills a rectangular area with the same tile.

Parameters

NameTypeDescription
xintegerStarting tile X
yintegerStarting tile Y
widthintegerWidth in tiles
heightintegerHeight in tiles
tilesetstringTileset name
tileset_xintegerTileset X coordinate
tileset_yintegerTileset Y coordinate

monoe.tilemap:line

Draws a line of tiles between two points.

Parameters

NameTypeDescription
x0integerStart tile X
y0integerStart tile Y
x1integerEnd tile X
y1integerEnd tile Y
tilesetstringTileset name
tileset_xintegerTileset X coordinate
tileset_yintegerTileset Y coordinate

monoe.tilemap:border

Draws a rectangular border of tiles.

Parameters

NameTypeDescription
xintegerStarting tile X
yintegerStarting tile Y
widthintegerWidth in tiles
heightintegerHeight in tiles
tilesetstringTileset name
tileset_xintegerTileset X coordinate
tileset_yintegerTileset Y coordinate

monoe.tilemap:stamp

Stamps a 2D pattern of tiles onto the map. Use `nil` in the pattern to skip a tile.

Parameters

NameTypeDescription
xintegerTop-left tile X
yintegerTop-left tile Y
patterntable2D array of {tileset_x, tileset_y} or nil
tilesetstringTileset name

monoe.tilemap:place_random

Places a random tile from a list of choices.

Parameters

NameTypeDescription
xintegerTile X
yintegerTile Y
tilesetstringTileset name
choicestableArray of {tileset_x, tileset_y}

monoe.tilemap:noise

Fills an area using random tiles based on a probability threshold.

Parameters

NameTypeDescription
xintegerStarting tile X
yintegerStarting tile Y
widthintegerWidth in tiles
heightintegerHeight in tiles
tilesetstringTileset name
tilestableArray of {tileset_x, tileset_y}
thresholdnumberProbability (0–1) for a tile to be placed (default 0.5)

monoe.tilemap:tolocal

Converts the global {x ; y} vector to a local vector, that represents their position in the tilemap.

Parameters

NameTypeDescription
xnumber
ynumber

Returns


monoe.tilemap:toglobal

Converts the local {x ; y} tile position to a global vector.

Parameters

NameTypeDescription
xnumber
ynumber

Returns


monoe.tilemap:free

Frees engine resources associated with this tilemap.


monoe.tilemap:remove

Removes the instance from the rendering side.