CorsixTH Lua Documentation

App Class

Add patient costs inflation

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

Method Index

Member Index

function App:_checkOrFind(test_file, campaign_dir)

Check that a file at a full path exists, or find it, or expand filename to full paths

Parameters:

NameTypeDescription
test_file string A full path or a filename of a level or map file
campaign_dir ? ?

Declared on: line 1914 of Lua/app.lua.

function App:_loadLevel(level, difficulty, level_name, level_file, level_intro, map_editor, campaign_info)

Private Function to load the level. Call via App:loadLevel(...)

Loads the specified level.

Parameters:

NameTypeDescription
level string Full path of a custom level, name of a TH level, or nil for mapeditor
difficulty string One of "easy, full, hard", or nil for custom levels
level_name string Display name of the level
level_file string Full path of a custom map, name of a TH level, or nil for TH campaign or mapeditor
level_intro string Introduction text displayed to the player
map_editor boolean True for opening the map editor
campaign_info table or of or strings Information about campaign in case loading level is a part of a campaign. if not part of a campaign then campaign_info is nil.

Declared on: line 898 of Lua/app.lua.

function App:abandon()

Exits the game completely without saving the config i.e. Alt+F4 for Quit Application

Declared on: line 1996 of Lua/app.lua.

function App:afterLoad()

This function is automatically called after loading a game and serves for compatibility.

Declared on: line 2006 of Lua/app.lua.

function App:checkCompatibility(save_version, gfx_set)

Function to check the loaded game is compatible with the program

Parameters:

NameTypeDescription
save_version num
gfx_set string What graphics set is used

Declared on: line 1889 of Lua/app.lua.

function App:checkForUpdates()

that any current version with a patch in its name (Beta, RC, etc) will be older

than the update table's version if their major, minor, and revision components match.

Declared on: line 2072 of Lua/app.lua.

function App:checkMissingStringsInLanguage(dir, language)

Compares strings provided by language file of given language WITHOUT inheritance with strings provided by english language with inheritance (i.e. all strings). This will give translators an idea which strings are missing in their translation.

Parameters:

NameTypeDescription
dir ? The directory where the file to write to should be.
language ? The language to check against.

Declared on: line 1048 of Lua/app.lua.

function App:compareVersions(version_a, version_b, method)

Reports a difference between two versions based on requested methodology.

Parameters:

NameTypeDescription
version_a number or or or table The first (usually newer) version to test
version_b number or or or table The second (usually older) version to test
method string What method to compare by - method(release) reports the difference between the matching releases in steps, - revisions are not counted. - For development builds it will use the base release it started from when using - the release method - method(version) reports the difference between two savegame versions

Declared on: line 1810 of Lua/app.lua.

function App:dispatch(evt_type, ...)

Parameters:

NameTypeDescription
evt_type ? ?
... ? ?

Declared on: line 1269 of Lua/app.lua.

function App:drawFrame()

Used to loop through fps_history when [over]writing

Declared on: line 1320 of Lua/app.lua.

function App:dumpStrings()

This is a useful debug and development aid

Declared on: line 964 of Lua/app.lua.

function App:errorHandler(last_dispatch_type, st)

Parameters:

NameTypeDescription
last_dispatch_type ? ?
st ? ?

Declared on: line 1222 of Lua/app.lua.

function App:exit()

Exits the game completely (no confirmation window)

Declared on: line 1988 of Lua/app.lua.

function App:findFileInDirs(search_paths, filename)

Searches in the given folders for the given filename

Parameters:

NameTypeDescription
search_paths table List of folders (strings) to look through
filename string Filename to search for.

Declared on: line 865 of Lua/app.lua.

function App:finishVideoUpdate()

Update / start any resources relying on a video object

Declared on: line 2165 of Lua/app.lua.

function App:gamelogHeader()

Generate information about user's system and the program

Declared on: line 2194 of Lua/app.lua.

function App:getBitmapDir()

Get the directory containing the bitmap files.

Declared on: line 1611 of Lua/app.lua.

function App:getCurrentVersion()

Retrieve the current savegame version as defined in the application.

Declared on: line 1768 of Lua/app.lua.

function App:getFullPath(folders, trailing_slash)

Returns the full path of the local path given

Parameters:

NameTypeDescription
folders string or or or table A string of one segment or an set of many segments of the path
trailing_slash boolean Whether the path needs to end with a local path separator

Declared on: line 89 of Lua/app.lua.

function App:getReleaseData(savegame_version)

Requests data regarding a given savegame version

Parameters:

NameTypeDescription
savegame_version number What to lookup, uses application version if blank

Declared on: line 1773 of Lua/app.lua.

function App:getReleaseString(savegame_version)

Provides the release (or development) string for a given savegame version

For development builds, the savegame version is appended as a patch e.g. 'dev213'

Parameters:

NameTypeDescription
savegame_version number The version to look up

Declared on: line 1798 of Lua/app.lua.

function App:getVideoOptions(overrides)

Parameters:

NameTypeDescription
overrides ? ?

Declared on: line 2181 of Lua/app.lua.

function App:idle()

Function for handling idle time in the main menu, which leads to playing the

demo gameplay trailer if left long enough

Declared on: line 1292 of Lua/app.lua.

function App:initGamelogFile()

Create the gamelog, using the launch time in the filename, and write the system information.

Declared on: line 424 of Lua/app.lua.

function App:initLanguage()

Initialises the application's language based on the player's choice.

Declared on: line 615 of Lua/app.lua.

function App:initSavegameDir()

Tries to initialize the savegame directory, returns true on success and

false on failure.

Declared on: line 493 of Lua/app.lua.

function App:initUserDirectories()

Tries to initialize the user level and campaign directories TODO: Integrate other directory initialisations into this function

Declared on: line 462 of Lua/app.lua.

function App:isThemeHospitalPath(path)

Parameters:

NameTypeDescription
path ? ?

Declared on: line 1435 of Lua/app.lua.

function App:load(filepath)

Parameters:

NameTypeDescription
filepath ? ?

Declared on: line 1871 of Lua/app.lua.

function App:loadCampaign(campaign_file)

Loads the first level of the specified campaign and prepares the world

to be able to progress through that campaign.

Parameters:

NameTypeDescription
campaign_file string Full path of a CorsixTH Campaign definition Lua file.

Declared on: line 751 of Lua/app.lua.

function App:loadLevel(level, difficulty, level_name, level_file, level_intro, map_editor, error_prefix, campaign_info)

error to the player

return (boolean) The outcome of the pcall

Parameters:

NameTypeDescription
level ? ?
difficulty ? ?
level_name ? ?
level_file ? ?
level_intro ? ?
map_editor ? ?
error_prefix string (Optional) Prefixes the error relevant to what was loaded
campaign_info ? ?

Declared on: line 880 of Lua/app.lua.

function App:loadLuaFolder(dir, no_results, append_to)

Parameters:

NameTypeDescription
dir ? ?
no_results ? ?
append_to ? ?

Declared on: line 1683 of Lua/app.lua.

function App:loadMainMenu(message)

Initialise CorsixTH's main menu screen including relevant windows

Parameters:

NameTypeDescription
message string Something to display to the user

Declared on: line 705 of Lua/app.lua.

function App:mapEdit()

Begin the map editor

Declared on: line 1983 of Lua/app.lua.

function App:onEditingText(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1355 of Lua/app.lua.

function App:onKeyDown(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1347 of Lua/app.lua.

function App:onKeyUp(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1351 of Lua/app.lua.

function App:onMouseDown(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1367 of Lua/app.lua.

function App:onMouseMove(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1371 of Lua/app.lua.

function App:onMouseUp(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1363 of Lua/app.lua.

function App:onMouseWheel(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1375 of Lua/app.lua.

function App:onMovieOver(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1415 of Lua/app.lua.

function App:onMusicOver(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1411 of Lua/app.lua.

function App:onPinchBegin(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1423 of Lua/app.lua.

function App:onPinchEnd(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1431 of Lua/app.lua.

function App:onPinchUpdate(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1427 of Lua/app.lua.

function App:onSoundOver(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1419 of Lua/app.lua.

function App:onTextInput(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1359 of Lua/app.lua.

function App:onTick(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1282 of Lua/app.lua.

function App:onWindowActive(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1379 of Lua/app.lua.

function App:onWindowDisplayScaleChanged(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1395 of Lua/app.lua.

function App:onWindowMaximised(...)

Window has been maximize by the user

Call the UI to report the new window mode

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1399 of Lua/app.lua.

function App:onWindowPixelSizeChanged(...)

Render size has changed

Call the UI to adjust to the new render size

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1389 of Lua/app.lua.

function App:onWindowResized(...)

Window has been resized by the user

Call the UI to report the new window size

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1383 of Lua/app.lua.

function App:onWindowRestored(...)

Window has been restored (remove maximize/minimize) by the user

Call the UI to report the new window mode

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1405 of Lua/app.lua.

function App:prepareVideoUpdate()

Free up / stop any resources relying on the current video object

Declared on: line 2159 of Lua/app.lua.

function App:quickSave()

Omit the usual file extension so this file cannot be seen from the normal load and save screen and cannot be overwritten

Declared on: line 1865 of Lua/app.lua.

function App:readBitmapDataFile(filename)

Load bitmap data into memory.

Parameters:

NameTypeDescription
filename ? Name of the file to load.

Declared on: line 1618 of Lua/app.lua.

function App:readCampaignFile(campaign_file)

Reads the given file name as a Lua chunk from the Campaign folders

A correct campaign definition contains "name", "description", "levels", and "winning_text".

Parameters:

NameTypeDescription
campaign_file string Full path of the file to read.

Declared on: line 795 of Lua/app.lua.

function App:readDataFile(dir, filename)

Read a data file of the application into memory (possibly with decompression).

Parameters:

NameTypeDescription
dir string Directory to read from. "Bitmap" and "Levels" are meta-directories, and get resolved to real directories in the function.
filename string or or or nil If specified, the file to load. If 'nil', the 'dir' parameter is the filename in the "Data" directory.

Declared on: line 1632 of Lua/app.lua.

function App:readLevelFile(level, campaign_dir)

Opens the given file name and returns all Level definitions in a table.

Values in the returned table: "path", "level_file", "name", "map_file", "briefing", and "end_praise".

Parameters:

NameTypeDescription
level string Full path or name of the file to read.
campaign_dir string Folder of the parent campaign file

Declared on: line 810 of Lua/app.lua.

function App:readMapDataFile(path)

Get a level file.

Parameters:

NameTypeDescription
path string Full path of the level file, or a Theme Hospital level filename

Declared on: line 1654 of Lua/app.lua.

function App:resetIdle()

Reset the idle count

Declared on: line 1312 of Lua/app.lua.

function App:restart(message)

Restarts the current level (offers confirmation window first)

Parameters:

NameTypeDescription
message string Optional message to the player

Declared on: line 1955 of Lua/app.lua.

function App:save(filename)

Parameters:

NameTypeDescription
filename ? ?

Declared on: line 1861 of Lua/app.lua.

function App:setCaptureMouse()

Sets the mouse capture to the state set within

app.config.capture_mouse

Declared on: line 737 of Lua/app.lua.

function App:setCommandLine(...)

Parameters:

NameTypeDescription
... ? ?

Declared on: line 79 of Lua/app.lua.

function App:trimLogs()

Trims the logs folder of old game logs down to ten files.

Declared on: line 434 of Lua/app.lua.

function App:writeToFileOrTmp(file, mode)

Tries to open the given file or a file in OS's temp dir. Returns the file handler, and true if it was written to the intended file.

Parameters:

NameTypeDescription
file ? The full path of the intended file
mode ? The mode in which the file is opened, defaults to write

Declared on: line 1185 of Lua/app.lua.