Module CorsixTH.CorsixTH.Lua.app
Core function.
Functions
| App:abandon () | Exits the game completely without saving the config i.e. |
| App:afterLoad () | This function is automatically called after loading a game and serves for compatibility. |
| App:checkCompatibility (save_version, gfx_set) | Function to check the loaded game is compatible with the program. |
| App:checkMissingStringsInLanguage (dir, language) | Compares strings provided by language file of given language. |
| App:connectDebugger () | Starts a Lua DBGp client & connects it to a DBGp server. |
| App:exit () | Exits the game completely (no confirmation window). |
| App:finishVideoUpdate () | Update / start any resources relying on a video object. |
| App:gamelogHeader () | Generate information about user's system and the program. |
| App:getAbsolutePathToLevelFile (level) | Searches for the given level file in the "Campaigns" and "Levels" folder of the CorsixTH install directory. |
| App:getBitmapDir () | Get the directory containing the bitmap files. |
| App:getFullPath (folders, trailing_slash) | Returns the full path of the local path given. |
| App:getGamelogPath () | Works out the intended location of the gamelog file. |
| App:getVersion (version) | Returns the version number (name) of the local copy of the game. |
| App:idle () | Function for handling idle time in the main menu. |
| App:initGamelogFile () | Checks and creates the gamelog file if it does not exist. |
| App:initSavegameDir () | Tries to initialize the savegame directory. |
| App:initUserDirectories () | Tries to initialize the user level and campaign directories. |
| App:loadCampaign (campaign_file) | Loads the campaign for the world. |
| App:loadLevel (level, difficulty, level_name, level_file, level_intro, map_editor) | Loads the specified level. |
| App:loadMainMenu (message) | Initialise CorsixTH's main menu screen including relevant windows |
| App:mapEdit () | Begin the map editor. |
| App:onWindowResize (...) | Window has been resized by the user. |
| App:prepareVideoUpdate () | Free up / stop any resources relying on the current video object. |
| App:readCampaignFile (campaign_file) | Reads the given file name as a Lua chunk from the Campaigns folder in the CorsixTH install directory. |
| App:readLevelFile (level) | Opens the given file name and returns all Level definitions in a table. |
| App:readMapDataFile (filename) | Get a level file. |
| App:resetIdle () | Reset the idle count |
| App:restart () | Restarts the current level (.) |
| App:setCaptureMouse () | Sets the mouse capture to the state set within app.config.capture_mouse. |
| App:writeToFileOrTmp (file, mode) | Tries to open the given file or a file in OS's temp dir. |
Functions
- App:abandon ()
- Exits the game completely without saving the config i.e. Alt+F4 for Quit Application.
- App:afterLoad ()
- This function is automatically called after loading a game and serves for compatibility.
- App:checkCompatibility (save_version, gfx_set)
-
Function to check the loaded game is compatible with the program.
Parameters:
- save_version (num)
- gfx_set (string) What graphics set is used
Returns:
-
true if compatible, otherwise false
- 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:
- dir The directory where the file to write to should be.
- language The language to check against.
- App:connectDebugger ()
-
Starts a Lua DBGp client & connects it to a DBGp server.
Returns:
-
error_message (String) Returns an error message or nil.
- App:exit ()
- Exits the game completely (no confirmation window).
- App:finishVideoUpdate ()
- Update / start any resources relying on a video object.
- App:gamelogHeader ()
-
Generate information about user's system and the program.
Returns:
-
System and program info as a string
- App:getAbsolutePathToLevelFile (level)
-
Searches for the given level file in the "Campaigns" and "Levels" folder of the CorsixTH install directory.
Parameters:
- level (string) Filename to search for.
Returns:
-
(string, error) Returns the found absolute path, or nil if not found. Then
a second variable is returned with an error message.
- App:getBitmapDir ()
-
Get the directory containing the bitmap files.
Returns:
-
Name of the directory containing the bitmap files, ending with a
directory path separator.
- App:getFullPath (folders, trailing_slash)
-
Returns the full path of the local path given.
Parameters:
- folders (string 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
Returns:
-
fullpath (string) The OS dependent full path
- App:getGamelogPath ()
-
Works out the intended location of the gamelog file.
Returns:
-
full path gamelog should exist at
- App:getVersion (version)
-
Returns the version number (name) of the local copy of the game.
based on which save game version it is. This was added after the Beta 8
release, which is why the checks prior to that version aren't made.
Parameters:
- version An optional value if you want to find what game version a specific savegame version is from.
- App:idle ()
- Function for handling idle time in the main menu. which leads to playing the demo gameplay trailer if left long enough
- App:initGamelogFile ()
- Checks and creates the gamelog file if it does not exist.
- App:initSavegameDir ()
-
Tries to initialize the savegame directory.
Returns:
-
true on success and false on failure.
- App:initUserDirectories ()
- Tries to initialize the user level and campaign directories. TODO: Integrate other directory initialisations into this function
- App:loadCampaign (campaign_file)
-
Loads the campaign for the world.
First level of the specified campaign and prepares the world to be able to progress through that campaign.
Parameters:
- campaign_file (string) Name of a CorsixTH Campaign definition Lua file.
- App:loadLevel (level, difficulty, level_name, level_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" folder of CorsixTH,
if it is a number it tries to load that level from the original game.
Parameters:
- level
- difficulty
- level_name
- level_file
- level_intro
- map_editor
- App:loadMainMenu (message)
-
Initialise CorsixTH's main menu screen including relevant windows
Parameters:
- message (string) Something to display to the user
- App:mapEdit ()
- Begin the map editor.
- App:onWindowResize (...)
-
Window has been resized by the user.
Call the UI to handle the new window size
Parameters:
- ...
- App:prepareVideoUpdate ()
- Free up / stop any resources relying on the current video object.
- App:readCampaignFile (campaign_file)
-
Reads the given file name as a Lua chunk from the Campaigns folder in the CorsixTH install directory.
A correct campaign definition contains "name", "description", "levels", and "winning_text".
Parameters:
- campaign_file (string) Name of the file to read.
Returns:
-
(table) Definitions found in the campaign file.
- App:readLevelFile (level)
-
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:
- level (string) Name of the file to read.
Returns:
-
(table) Level info found in the file.
- App:readMapDataFile (filename)
-
Get a level file.
Parameters:
- filename (string) Name of the level file.
Returns:
-
If the file could be found, the data of the file, else a
tuple 'nil', and an error description
- App:resetIdle ()
- Reset the idle count
- App:restart ()
- Restarts the current level (.)
- App:setCaptureMouse ()
- Sets the mouse capture to the state set within app.config.capture_mouse.
- App:writeToFileOrTmp (file, mode)
-
Tries to open the given file or a file in OS's temp dir.
Returns the file handler
Parameters:
- file The full path of the intended file
- mode The mode in which the file is opened, defaults to write