Zum Inhalt

app

Quelle: 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

Zugriff: app

Hinweise

Typ des globalen Objekts app, das die Anwendung steuert (Spielstände, Ladefortschritt, Benutzerprofil, Mods).

Felder

Name Typ Beschreibung
res Res The application level resource repositories.
debug Debug Die Debug-Hilfen aus App.Debug (app.debug).

Funktionen

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

Aufruf: app.quit(…)

Quit the application.

Parameter Typ Beschreibung
instant boolean immediately quit one exit

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

Aufruf: app.restart(…)

Restart the application

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

Aufruf: app.printMemoryStats(…)

Prints memory statistics to the log output.

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

Aufruf: app.startGame(…)

Starts a new test game by specifying some basic parameters

Parameter Typ Beschreibung
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

Aufruf: app.startGame2(…)

Starts a new game

Parameter Typ Beschreibung
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

Aufruf: app.stopGame(…)

Stops the current game.

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

Aufruf: app.findAllSavegames(…)

Obtain list of all savegames.

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

Rückgabe {SaveGameInfo}: a list of all savegame

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

Aufruf: app.loadGame(…)

Loads a savegame

Parameter Typ Beschreibung
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

Aufruf: app.loadMission(…)

Loads a mission

Parameter Typ Beschreibung
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

Aufruf: app.saveGame(…)

Saves the current game.

Parameter Typ Beschreibung
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

Aufruf: app.parseSavegameName(…)

Parse savegame info from its file name

Parameter Typ Beschreibung
savegameName string the name of the savegame

Rückgabe ParsedSavegameName: The info (most notably, savegame type and group name)

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

Aufruf: app.getSavegameComplexity(…)

Get an estimated value of the savegame complexity

Parameter Typ Beschreibung
saveGameDetails SaveGameData.SaveGameDetails the savegame data of the savegame

Rückgabe integer: a value that represents the estimate size of the savegame

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

Aufruf: app.getSavegameComplexityLimit(…)

Get an limit for the savegame complexity for the current platform

Rückgabe integer: the complexity limit for the current platform

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

Aufruf: app.getSavegameInfo(…)

Loads savegame metadata asynchronously.

Parameter Typ Beschreibung
saveId SaveGameId the savegame id

Rückgabe Async<SaveGameData>: an async object with the savegame data

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

Aufruf: 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 Typ Beschreibung
saveId SaveGameId the savegame id

Rückgabe GameScreenshot | nil: the image, or nil if no preview image is available

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

Aufruf: app.deleteSavegame(…)

Deletes a savegame

Parameter Typ Beschreibung
saveId SaveGameId the savegame to delete

Rückgabe boolean: if the savegame was successfully deleted

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

Aufruf: app.getUserProfile(…)

Obtain the user profile.

Rückgabe UserProfile: the user profile

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

Aufruf: app.findBuiltinSavegames(…)

Obtains a list of built-in savegames.

Parameter Typ Beschreibung
isMapSave boolean true to list built-in maps, false to list built-in savegames

Rückgabe {SaveGameInfo}: list of savegames

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

Aufruf: app.getSaveGameStorageInfo(…)

Returns the savegame storage infos

Rückgabe SaveGameStorageInfo: savegame storage info

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

Aufruf: app.getSupportedMSAASampleCounts(…)

Returns the supported MSAA sample counts

Rückgabe {integer}: list of supported sample counts

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

Aufruf: app.loadUserdata(…)

Load a custom userdata file

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

Rückgabe table: the deserialized lua data

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

Aufruf: app.saveUserdata(…)

Saves a custom table as lua file.

Parameter Typ Beschreibung
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

Aufruf: app.removeUserdata(…)

Removes a userdata.

Parameter Typ Beschreibung
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

Aufruf: app.getAllUserdata(…)

Returns a list of all saved mod preset names.

Parameter Typ Beschreibung
directory string a folder in the userdata directory

Rückgabe {string}: a list of mod preset names

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

Aufruf: app.playVoiceOverOrStop(…)

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

Parameter Typ Beschreibung
resName string the file to play

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

Aufruf: app.makeEmptyMap(…)

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

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

Rückgabe GameMap: the map

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

Aufruf: app.getInputActionRep(…)

Returns the global input action repository.

Rückgabe InputActionRep: input action repository

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

Aufruf: app.refreshMods(…)

Refreshes the installed mods

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

Aufruf: 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

Aufruf: app.isWaitForStartReadyGame(…)

Return if the setWaitForStartReadyGame had been called for this game.

Rückgabe boolean

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

Aufruf: 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

Aufruf: app.getRandomTips(…)

Gets the list of random tips

Rückgabe {string}: a list of tips as string

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

Aufruf: app.getModTagTranslation(…)

Returns a translated name for a mod tag.

Parameter Typ Beschreibung
tag string tag to translate

Rückgabe string: the translated tag

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

Aufruf: app.getProgressMonitor(…)

Gets the load progress monitor

Rückgabe ProgressMonitor

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

Aufruf: app.openUserDataFolder(…)

Opens the user data folder in the OS file manager

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

Aufruf: app.openUserDataSubFolder(…)

Opens the heightmaps folder in the OS file manager

Parameter Typ Beschreibung
directory string subfolder

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

Aufruf: app.getUserDataFolder(…)

Gets the directory containing userdata

Rückgabe string

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

Aufruf: app.getAllHeightmaps(…)

Gets a list of all heightmaps in the userdata directory

Rückgabe {string}: list of heightmaps files

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

Aufruf: app.getAllBiomes(…)

Gets a list of all biomes in the userdata directory

Rückgabe {string}: list of biomes files

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

Aufruf: app.openBiomesFolder(…)

Opens the biomes folder

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

Aufruf: app.getBiomesFolder(…)

Gets the path to the biome folder

Rückgabe string: path to biome folder

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

Aufruf: app.getGPUCapabilities(…)

Get information about the GPU

Rückgabe GPUCapabilities

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

Aufruf: app.writeHeightmap(…)

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

Parameter Typ Beschreibung
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)

Rückgabe boolean: if the heightmap was successfully written

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

Aufruf: app.showNodeEditor(…)

Shows the node editor.

App.ProgressMonitor

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

record ProgressMonitor

Hinweise

Fortschritt der aktuellen Ladeaufgabe, geliefert von app.getProgressMonitor().

Beispiel

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

Funktionen

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

Returns the current progress as a value from 0 to 1

Rückgabe number

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

Returns the current task being executed

Rückgabe 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.

Felder

Name Typ Beschreibung
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.

Funktionen

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

Returns the userdata savegame namespace.

Rückgabe string

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

Returns the savegame namespace.

Rückgabe string

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

Returns the savemap namespace.

Rückgabe string

App.Debug

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

record Debug

Hinweise

Debug-Hilfen für die Gamepad-Eingabe (erzwungene Wiederholrate beim Scrollen, eingespeiste Tastenereignisse).

Funktionen

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

Overrides gamepad dynamic scroll repeat speed.

Parameter Typ Beschreibung
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 Typ Beschreibung
gamepadButtonName string the button to push
press boolean if pressed