CorsixTH Lua Documentation

Map Class

Lua extensions to the C++ THMap class

Declared on: line 21 of Lua/map.lua.

Method Index

Member Index

function Map:Map(app)

Parameters:

NameTypeDescription
app ? ?

Declared on: line 31 of Lua/map.lua.

function Map:ScreenToWorld(x, y)

Parameters:

NameTypeDescription
x ? ?
y ? ?

Declared on: line 127 of Lua/map.lua.

function Map:WorldToScreen(x, y)

Convert between world coordinates and screen coordinates World coordinates are (at least for standard maps) in the range [1, 128) for both x and y, with the floor of the values giving the cell index. Screen coordinates are pixels relative to the map origin - NOT relative to the top-left corner of the screen (use UI:WorldToScreen and UI:ScreenToWorld for this).

Parameters:

NameTypeDescription
x ? ?
y ? ?

Declared on: line 110 of Lua/map.lua.

function Map:_drawDebugTiles(canvas, x, y, xpos, ypos)

Parameters:

NameTypeDescription
canvas ? ?
x ? ?
y ? ?
xpos ? ?
ypos ? ?

Declared on: line 678 of Lua/map.lua.

function Map:_fixTiles()

Expandable private function to fix tile issues on loading a map.

Each fix should be rendered in a local function.

Declared on: line 796 of Lua/map.lua.

function Map:_loadOriginalCampaignLevel(difficulty, level_number, config)

Load further level configurations for the main campaign.

Parameters:

NameTypeDescription
difficulty string
level_number integer
config table The level config created so far

Declared on: line 269 of Lua/map.lua.

function Map:afterLoad(old, new)

Parameters:

NameTypeDescription
old ? ?
new ? ?

Declared on: line 856 of Lua/map.lua.

function Map:afterSave()

Restore the temporarily stored debug information after saving

Declared on: line 484 of Lua/map.lua.

function Map:draw(canvas, sx, sy, sw, sh, dx, dy)

Draws the rectangle of the map given by (sx, sy, sw, sh) at position (dx, dy) on the canvas

Parameters:

NameTypeDescription
canvas ?
sx ? Horizontal start position at the screen.
sy ? Vertical start position at the screen.
sw int Width of the screen.
sh int Height of the screen.
dx jnt Horizontal destination at the canvas.
dy int Vertical destination at the canvas. ]]

Declared on: line 718 of Lua/map.lua.

function Map:getCellFlag(x, y, flag)

Get the value of the given flag from the tile at x, y in the map.

Parameters:

NameTypeDescription
x int Vertical position of the tile to query in the map.
y ? ?
flag string Name of the queried flag.

Declared on: line 49 of Lua/map.lua.

function Map:getDifficulty()

Get the difficulty of the level. Custom levels and campaign always have medium difficulty.

Declared on: line 306 of Lua/map.lua.

function Map:getParcelPrice(parcel)

Get the price of a parcel

Parameters:

NameTypeDescription
parcel int Parcel number being queried.

Declared on: line 779 of Lua/map.lua.

function Map:getParcelTileCount(parcel)

Get the number of tiles in a parcel.

Parameters:

NameTypeDescription
parcel int Parcel number being queried.

Declared on: line 789 of Lua/map.lua.

function Map:getPlayerCount(count)

Parameters:

NameTypeDescription
count ? ?

Declared on: line 70 of Lua/map.lua.

function Map:getRawData(map_file)

Parameters:

NameTypeDescription
map_file ? ?

Declared on: line 502 of Lua/map.lua.

function Map:getRoomId(x, y)

Get the ID of the room of the tile at x, y in the map.

Parameters:

NameTypeDescription
x int Vertical position of the tile to query in the map.
y ? ?

Declared on: line 58 of Lua/map.lua.

function Map:load(level, difficulty, level_name, map_file, level_intro, map_editor)

Loads the specified level. If a string is passed it looks for the file with the same name in the "Levels" and/or "Campaigns" folder of CorsixTH, if it is a number it tries to load that level from the original game.

Parameters:

NameTypeDescription
level string or or or int The name (or number) of the level to load. If this is a number the game assumes the original game levels are considered.
difficulty ? ?
level_name string The name of the actual map/area/hospital as written in the config file.
map_file string The path to the map file as supplied by the config file.
level_intro string If loading a custom level this message will be shown as soon as the level has been loaded.
map_editor ? ?

Declared on: line 161 of Lua/map.lua.

function Map:loadDebugText(first, last, bits_)

If both 'first' and 'last' are numbers, they are indices starting at 0.

Parameters:

NameTypeDescription
first ? ?
last ? ?
bits_ ? ?

Declared on: line 581 of Lua/map.lua.

function Map:loadMapConfig(filename, config, custom)

Loads map configurations from files.

Parameters:

NameTypeDescription
filename string The absolute path to the config file to load
config string If a base config already exists and only some values should be overridden this is the base config
custom ? If true The configuration file is searched for where filename points, otherwise it is assumed that we're looking in the theme_hospital_install path.

Declared on: line 384 of Lua/map.lua.

function Map:prepareForSave()

Keep debug information in temporary local vars, do not save them

Declared on: line 472 of Lua/map.lua.

function Map:registerTemperatureDisplayMethod()

Copy the temperature display method from the Lua data, if available, else use the default.

Declared on: line 102 of Lua/map.lua.

function Map:save(filename)

Saves the map to a .map file

Parameters:

NameTypeDescription
filename string Name of the file to save the map in

Declared on: line 374 of Lua/map.lua.

function Map:setBlocks(blocks)

Set the sprites to be used by the map.

Parameters:

NameTypeDescription
blocks object Sprite sheet for the map.

Declared on: line 645 of Lua/map.lua.

function Map:setCameraTile(x, y, player)

Set the camera tile for the given player on the map

Parameters:

NameTypeDescription
x int Horizontal position of tile to set camera on
y int Vertical position of the tile to set the camera on
player int Player number (1-4)

Declared on: line 74 of Lua/map.lua.

function Map:setCellFlags(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 652 of Lua/map.lua.

function Map:setDebugFont(font)

Parameters:

NameTypeDescription
font ? ?

Declared on: line 656 of Lua/map.lua.

function Map:setDebugText(x, y, msg, ...)

Parameters:

NameTypeDescription
x ? ?
y ? ?
msg ? ?
... ? ?

Declared on: line 661 of Lua/map.lua.

function Map:setHeliportTile(x, y, player)

Set the heliport tile for the given player on the map

Parameters:

NameTypeDescription
x int Horizontal position of tile to set heliport on
y int Vertical position of the tile to set the heliport on
player int Player number (1-4)

Declared on: line 82 of Lua/map.lua.

function Map:setPlayerCount(count)

Parameters:

NameTypeDescription
count ? ?

Declared on: line 66 of Lua/map.lua.

function Map:setPlotOwner(plot_number, new_owner)

Sets the plot owner of the given plot number to the given new owner. Makes sure that any room adjacent to the new plot have walls in all directions after the purchase.

Parameters:

NameTypeDescription
plot_number int Number of the plot to change owner of. Plot 0 is the outside and should never change owner.
new_owner int The player number that should own plot_number. 0 means no owner.

Declared on: line 314 of Lua/map.lua.

function Map:setTemperatureDisplayMethod(method)

Set how to display the room temperature in the hospital map.

1=red gradients, 2=blue/green/red colour shifts, 3=yellow/orange/red colour shifts

Parameters:

NameTypeDescription
method int Way of displaying the temperature. See also THMapTemperatureDisplay enum.

Declared on: line 90 of Lua/map.lua.