Map Class
Lua extensions to the C++ THMap class
Method Index
- ScreenToWorld(x, y)
- WorldToScreen(x, y)
- _drawDebugTiles(canvas, x, y, xpos, ypos)
- _fixTiles()
- _loadOriginalCampaignLevel(difficulty, level_number, config)
- afterLoad(old, new)
- afterSave()
- clearDebugText()
- draw(canvas, sx, sy, sw, sh, dx, dy)
- getCellFlag(x, y, flag)
- getDifficulty()
- getParcelPrice(parcel)
- getParcelTileCount(parcel)
- getPlayerCount(count)
- getRawData(map_file)
- getRoomId(x, y)
- load(level, difficulty, level_name, map_file, level_intro, map_editor)
- loadDebugText(first, last, bits_)
- loadMapConfig(filename, config, custom)
- onTick()
- prepareForSave()
- registerTemperatureDisplayMethod()
- save(filename)
- setBlocks(blocks)
- setCameraTile(x, y, player)
- setCellFlags(...)
- setDebugFont(font)
- setDebugText(x, y, msg, ...)
- setHeliportTile(x, y, player)
- setPlayerCount(count)
- setPlotOwner(plot_number, new_owner)
- setTemperatureDisplayMethod(method)
- updateDebugOverlayCamera()
- updateDebugOverlayFlags()
- updateDebugOverlayHeat()
- updateDebugOverlayHeliport()
- updateDebugOverlayParcels()
Member Index
- app
- blocks
- cell_outline
- debug_flags
- debug_font
- debug_text
- debug_tick_timer
- difficulty
- height
- hotfix1
- level_config
- level_filename
- level_intro
- level_name
- level_number
- map_file
- parcelTileCounts
- temperature_display_method
- th
- thData
- updateDebugOverlay
- width
function Map:ScreenToWorld(x, y)
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| x | ? | ? |
| y | ? | ? |
Declared on: line 110 of Lua/map.lua.
function Map:_drawDebugTiles(canvas, x, y, xpos, ypos)
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:clearDebugText()
Declared on: line 496 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| parcel | int | Parcel number being queried. |
Declared on: line 789 of Lua/map.lua.
function Map:getPlayerCount(count)
Parameters:
| Name | Type | Description |
|---|---|---|
| count | ? | ? |
Declared on: line 70 of Lua/map.lua.
function Map:getRawData(map_file)
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| first | ? | ? |
| last | ? | ? |
| bits_ | ? | ? |
Declared on: line 581 of Lua/map.lua.
function Map:loadMapConfig(filename, config, custom)
Loads map configurations from files.
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:onTick()
Declared on: line 634 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| ... | ? | ? |
Declared on: line 652 of Lua/map.lua.
function Map:setDebugFont(font)
Parameters:
| Name | Type | Description |
|---|---|---|
| font | ? | ? |
Declared on: line 656 of Lua/map.lua.
function Map:setDebugText(x, y, msg, ...)
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| method | int | Way of displaying the temperature. See also THMapTemperatureDisplay enum. |
Declared on: line 90 of Lua/map.lua.
function Map:updateDebugOverlayHeat()
Declared on: line 528 of Lua/map.lua.