Skip to content

app

Source: api/tealdef/app.d.tl

Module controlling high level functions for the application, can be used to manipulate save games.

App

record global api/tealdef/app.d.tl:5

global record App

Access: app

Notes

Type of the global app object, which controls the application (save games, load progress, user profile, mods).

Fields

Name Type Description
res Res The application level resource repositories.
debug Debug The App.Debug helpers (app.debug).

Functions

quit(instant : boolean) api/tealdef/app.d.tl:38

Call as app.quit

Quit the application.

Parameter Type Description
instant boolean immediately quit one exit

restart() api/tealdef/app.d.tl:41

Call as app.restart

Restart the application

printMemoryStats() api/tealdef/app.d.tl:44

Call as app.printMemoryStats

Prints memory statistics to the log output.

startGame(startGameParams? : StartGameParams) api/tealdef/app.d.tl:48

Call as app.startGame

Starts a new test game by specifying some basic parameters

Parameter Type Description
startGameParams? StartGameParams start game parameters (optional) - if not set, the game will start with default values

startGame2(map : GameMap, seed : string, startDate : Date, startTimeOfDaySeconds : integer, startCloudCoverage : number, isMapEditor : boolean, mods : {Mod.ModId}, configDict : {{string, string}}, modParams : {string : {string : integer}}) api/tealdef/app.d.tl:60

Call as app.startGame2

Starts a new game

Parameter Type Description
map GameMap the map to use
seed string the seed use for the map generation
startDate Date the start date
startTimeOfDaySeconds integer is the start time of the day in seconds
startCloudCoverage number is the start cloud coverage
isMapEditor boolean starting from map editor
mods {Mod.ModId} list of mods to start the game with
configDict {{string, string}} list of game settings
modParams {string : {string : integer}} list of mod params

stopGame() api/tealdef/app.d.tl:63

Call as app.stopGame

Stops the current game.

findAllSavegames(namespace : string) : {SaveGameInfo} api/tealdef/app.d.tl:68

Call as app.findAllSavegames

Obtain list of all savegames.

Parameter Type Description
namespace string from which to obtain information (see app.SaveGameNamespace.getSavemap() or app.SaveGameNamespace.getSavegame() for the namespaces)

Returns {SaveGameInfo}: a list of all savegame

loadGame(saveId : SaveGameId, isMapEditor : boolean, info? : SaveGameData.SaveGameDetails, isTutorialInit? : boolean) api/tealdef/app.d.tl:75

Call as app.loadGame

Loads a savegame

Parameter Type Description
saveId SaveGameId the savegame id
isMapEditor boolean if the savegame is loaded in the map editor
info? SaveGameData.SaveGameDetails savegame info (optional)
isTutorialInit? boolean if the savegame is loaded as a tutorial init (optional)

loadMission(saveId : SaveGameId, campaign : string, mission : string) api/tealdef/app.d.tl:81

Call as app.loadMission

Loads a mission

Parameter Type Description
saveId SaveGameId the savegame id
campaign string campaign name
mission string mission name

saveGame(name : string, callBack : function(), isMapEditor : boolean, skipSetName? : boolean) api/tealdef/app.d.tl:88

Call as app.saveGame

Saves the current game.

Parameter Type Description
name string the name of the savegame
callBack function() callback when the savegame is finished
isMapEditor boolean is saving from the map editor
skipSetName? boolean skips setting the savegame name as the current default savegame name (optional)

parseSavegameName(savegameName : string) : ParsedSavegameName api/tealdef/app.d.tl:93

Call as app.parseSavegameName

Parse savegame info from its file name

Parameter Type Description
savegameName string the name of the savegame

Returns ParsedSavegameName: The info (most notably, savegame type and group name)

getSavegameComplexity(saveGameDetails : SaveGameData.SaveGameDetails) : integer api/tealdef/app.d.tl:98

Call as app.getSavegameComplexity

Get an estimated value of the savegame complexity

Parameter Type Description
saveGameDetails SaveGameData.SaveGameDetails the savegame data of the savegame

Returns integer: a value that represents the estimate size of the savegame

getSavegameComplexityLimit() : integer api/tealdef/app.d.tl:102

Call as app.getSavegameComplexityLimit

Get an limit for the savegame complexity for the current platform

Returns integer: the complexity limit for the current platform

getSavegameInfo(saveId : SaveGameId) : Async<SaveGameData> api/tealdef/app.d.tl:107

Call as app.getSavegameInfo

Loads savegame metadata asynchronously.

Parameter Type Description
saveId SaveGameId the savegame id

Returns Async<SaveGameData>: an async object with the savegame data

getSavegameImage(saveId : SaveGameId) : GameScreenshot | nil api/tealdef/app.d.tl:113

Call as app.getSavegameImage

Obtains the savegame preview image Note: This is - usually, if not explicitly changed in userdata - the same image as GameMetadata.screenshot but with the full available resolution

Parameter Type Description
saveId SaveGameId the savegame id

Returns GameScreenshot | nil: the image, or nil if no preview image is available

deleteSavegame(saveId : SaveGameId) : boolean api/tealdef/app.d.tl:118

Call as app.deleteSavegame

Deletes a savegame

Parameter Type Description
saveId SaveGameId the savegame to delete

Returns boolean: if the savegame was successfully deleted

getUserProfile() : UserProfile api/tealdef/app.d.tl:122

Call as app.getUserProfile

Obtain the user profile.

Returns UserProfile: the user profile

findBuiltinSavegames(isMapSave : boolean) : {SaveGameInfo} api/tealdef/app.d.tl:127

Call as app.findBuiltinSavegames

Obtains a list of built-in savegames.

Parameter Type Description
isMapSave boolean true to list built-in maps, false to list built-in savegames

Returns {SaveGameInfo}: list of savegames

getSaveGameStorageInfo() : SaveGameStorageInfo api/tealdef/app.d.tl:131

Call as app.getSaveGameStorageInfo

Returns the savegame storage infos

Returns SaveGameStorageInfo: savegame storage info

getSupportedMSAASampleCounts() : {integer} api/tealdef/app.d.tl:135

Call as app.getSupportedMSAASampleCounts

Returns the supported MSAA sample counts

Returns {integer}: list of supported sample counts

loadUserdata(directory : string, fileName : string) : table api/tealdef/app.d.tl:141

Call as app.loadUserdata

Load a custom userdata file

Parameter Type Description
directory string a folder in the userdata directory
fileName string a lua filename (without .lua extension)

Returns table: the deserialized lua data

saveUserdata(directory : string, fileName : string, table : table) api/tealdef/app.d.tl:147

Call as app.saveUserdata

Saves a custom table as lua file.

Parameter Type Description
directory string a folder in the userdata directory
fileName string the filename to save to (without .lua extension)
table table the table to serialize

removeUserdata(directory : string, fileName : string) api/tealdef/app.d.tl:152

Call as app.removeUserdata

Removes a userdata.

Parameter Type Description
directory string a folder in the userdata directory
fileName string the filename to remove (without .lua extension)

getAllUserdata(directory : string) : {string} api/tealdef/app.d.tl:157

Call as app.getAllUserdata

Returns a list of all saved mod preset names.

Parameter Type Description
directory string a folder in the userdata directory

Returns {string}: a list of mod preset names

playVoiceOverOrStop(resName : string) api/tealdef/app.d.tl:161

Call as app.playVoiceOverOrStop

Plays a voice over if not currently playing, otherwise stops it.

Parameter Type Description
resName string the file to play

makeEmptyMap(climate : string, numTiles : Vec2i, waterLevel : number) : GameMap api/tealdef/app.d.tl:168

Call as app.makeEmptyMap

Creates an empty map (for tooling / map generation workflows).

Parameter Type Description
climate string climate resource name
numTiles Vec2i map dimension in tiles
waterLevel number water level height

Returns GameMap: the map

getInputActionRep() : InputActionRep api/tealdef/app.d.tl:172

Call as app.getInputActionRep

Returns the global input action repository.

Returns InputActionRep: input action repository

refreshMods() api/tealdef/app.d.tl:175

Call as app.refreshMods

Refreshes the installed mods

setWaitForStartReadyGame() api/tealdef/app.d.tl:178

Call as app.setWaitForStartReadyGame

Wait for the game to be ready to start. This is called when loading a game to prevent the game from starting automatically

isWaitForStartReadyGame() : boolean api/tealdef/app.d.tl:181

Call as app.isWaitForStartReadyGame

Return if the setWaitForStartReadyGame had been called for this game.

Returns boolean

startReadyGame() api/tealdef/app.d.tl:184

Call as app.startReadyGame

Start Game that is fully loaded and ready to play. This is called after the progress page has finished loading the game.

getRandomTips() : {string} api/tealdef/app.d.tl:188

Call as app.getRandomTips

Gets the list of random tips

Returns {string}: a list of tips as string

getModTagTranslation(tag : string) : string api/tealdef/app.d.tl:193

Call as app.getModTagTranslation

Returns a translated name for a mod tag.

Parameter Type Description
tag string tag to translate

Returns string: the translated tag

getProgressMonitor() : ProgressMonitor api/tealdef/app.d.tl:196

Call as app.getProgressMonitor

Gets the load progress monitor

Returns ProgressMonitor

openUserDataFolder() api/tealdef/app.d.tl:199

Call as app.openUserDataFolder

Opens the user data folder in the OS file manager

openUserDataSubFolder(directory : string) api/tealdef/app.d.tl:203

Call as app.openUserDataSubFolder

Opens the heightmaps folder in the OS file manager

Parameter Type Description
directory string subfolder

getUserDataFolder() : string api/tealdef/app.d.tl:206

Call as app.getUserDataFolder

Gets the directory containing userdata

Returns string

getAllHeightmaps() : {string} api/tealdef/app.d.tl:210

Call as app.getAllHeightmaps

Gets a list of all heightmaps in the userdata directory

Returns {string}: list of heightmaps files

getAllBiomes() : {string} api/tealdef/app.d.tl:214

Call as app.getAllBiomes

Gets a list of all biomes in the userdata directory

Returns {string}: list of biomes files

openBiomesFolder() api/tealdef/app.d.tl:217

Call as app.openBiomesFolder

Opens the biomes folder

getBiomesFolder() : string api/tealdef/app.d.tl:221

Call as app.getBiomesFolder

Gets the path to the biome folder

Returns string: path to biome folder

getGPUCapabilities() : GPUCapabilities api/tealdef/app.d.tl:224

Call as app.getGPUCapabilities

Get information about the GPU

Returns GPUCapabilities

writeHeightmap(map : GameMap, path : string, writeStl : boolean, sixteenBits : boolean, biomesData : boolean) : boolean api/tealdef/app.d.tl:233

Call as app.writeHeightmap

Writes a heightmap image (and optionally an STL) for a map.

Parameter Type Description
map GameMap the map to write
path string the relative path (extension will be added if missing)
writeStl boolean write as an STL file as well
sixteenBits boolean use 16 bits depth for the heightmap (default 8 bits depth)
biomesData boolean if biomes data should as well be exported (will be written in the biomes folder)

Returns boolean: if the heightmap was successfully written

showNodeEditor() api/tealdef/app.d.tl:236

Call as app.showNodeEditor

Shows the node editor.

App.ProgressMonitor

record api/tealdef/app.d.tl:6

record ProgressMonitor

Notes

Progress of the current loading task, returned by app.getProgressMonitor().

Example

-- from gui/menu/progress_page.tl
local monitor = app.getProgressMonitor()
return {monitor:getProgress(), monitor:getTask()}

Functions

getProgress(ProgressMonitor) : number api/tealdef/app.d.tl:8

Call as progressMonitor:getProgress(…) (method)

Returns the current progress as a value from 0 to 1

Returns number

getTask(ProgressMonitor) : string api/tealdef/app.d.tl:10

Call as progressMonitor:getTask(…) (method)

Returns the current task being executed

Returns string

App.Res

record api/tealdef/app.d.tl:16

record Res

Application level resource repositories. Note: climateRep, economyRep and terrainGeneratorRep are only populated in the main menu, in the game UI use the corresponding repositories in api.res.

Fields

Name Type Description
climateRep ResTypeRep<integer, ClimateDesc> A resource repository containing data for the climates.
economyRep ResTypeRep<integer, EconomyDesc> A resource repository containing data from the ".eco" economy resources.
terrainGeneratorRep ResTypeRep<integer, TerrainGeneratorDesc> A resource repository containing data for the terrain generation.
playlistRep ResTypeRep<integer, PlaylistDesc> A repository for playlists.
nameRep ResTypeRep<integer, NameDesc> A resource repository for names.
campaignRep ResTypeRep<integer, CampaignDesc> A resource repository for campaign chapters.
missionRep ResTypeRep<integer, MissionDesc> A resource repository for campaign missions.

App.SaveGameNamespace

record api/tealdef/app.d.tl:239

record SaveGameNamespace

Savegame namespace constants.

Functions

getUserdata() : string api/tealdef/app.d.tl:241

Returns the userdata savegame namespace.

Returns string

getSavegame() : string api/tealdef/app.d.tl:243

Returns the savegame namespace.

Returns string

getSavemap() : string api/tealdef/app.d.tl:245

Returns the savemap namespace.

Returns string

App.Debug

record api/tealdef/app.d.tl:248

record Debug

Notes

Debug helpers for gamepad input (forced scroll repeat speed, injected button events).

Functions

setForcedGamepadDynamicScrollRepeatSpeed(speed? : integer) api/tealdef/app.d.tl:251

Overrides gamepad dynamic scroll repeat speed.

Parameter Type Description
speed? integer the scroll speed (0: 1/sec, 3: max speed), or nil to clear the override

pushGamepadButtonKeyInputEvent(gamepadButtonName : string, press : boolean) api/tealdef/app.d.tl:256

Pushes a gamepad button event into the input queue.

Parameter Type Description
gamepadButtonName string the button to push
press boolean if pressed