21 KiB
index / app
Module app🔗
Module controlling high level functions for the application, can be used to manipulate save games.
[Expand All] [Collapse All]
global record App record ProgressMonitor getProgress: function(ProgressMonitor): number
getTask: function(ProgressMonitor): string
end
quit: function(instant : boolean)
restart: function()
printMemoryStats: function()
startGame: function(startGameParams : StartGameParams)
startGame2: function(map : GameMap, seed : string, startDate : Date, startTimeOfDaySeconds : integer, startCloudCoverage : number, isMapEditor : boolean, mods : {Mod.ModId}, configDict : {{string, string}}, modParams : {string : {string : integer}})
stopGame: function()
findAllSavegames: function(namespace : string): {SaveGameInfo}
loadGame: function(saveId : SaveGameId, isMapEditor : boolean, info : SaveGameData.SaveGameDetails)
loadMission: function(saveId : SaveGameId, campaign : string, mission : string)
saveGame: function(name : string, callBack : function(), isMapEditor : boolean, skipSetName : boolean)
parseSavegameName: function(savegameName : string): ParsedSavegameName
getSavegameComplexity: function(saveGameDetails : SaveGameData.SaveGameDetails): integer
getSavegameComplexityLimit: function(): integer
getSavegameInfo: function(saveId : SaveGameId): Async<SaveGameData>
getSavegameImage: function(saveId : SaveGameId): GameScreenshot | nil
deleteSavegame: function(saveId : SaveGameId): boolean
getUserProfile: function(): UserProfile
findBuiltinSavegames: function(isMapSave : boolean): {SaveGameInfo}
getSaveGameStorageInfo: function(): SaveGameStorageInfo
getSupportedMSAASampleCounts: function(): {integer}
loadUserdata: function(directory : string, fileName : string): {<any type> : <any type>}
saveUserdata: function(directory : string, fileName : string, table : {<any type> : <any type>})
removeUserdata: function(directory : string, fileName : string)
getAllUserdata: function(directory : string): {string}
playVoiceOverOrStop: function(resName : string)
makeEmptyMap: function(climate : string, numTiles : Vec2i, waterLevel : number): GameMap
getInputActionRep: function(): InputActionRep
refreshMods: function()
setWaitForStartReadyGame: function()
isWaitForStartReadyGame: function(): boolean
startReadyGame: function()
getRandomTips: function(): {string}
getModTagTranslation: function(tag : string): string
getProgressMonitor: function(): ProgressMonitor
openUserDataFolder: function()
openUserDataSubFolder: function(directory : string)
getUserDataFolder: function(): string
getAllHeightmaps: function(): {string}
getGPUCapabilities: function(): GPUCapabilities
writeHeightmap: function(map : GameMap, path : string, writeStl : boolean, sixteenBits : boolean): boolean
showNodeEditor: function()
record SaveGameNamespace getUserdata: function(): string
getSavegame: function(): string
getSavemap: function(): string
end
record Debug setForcedGamepadDynamicScrollRepeatSpeed: function(speed : integer)
pushGamepadButtonKeyInputEvent: function(gamepadButtonName : string, press : boolean)
end
debug: Debug
end
Category: globals🔗
App🔗
[Expand All] [Collapse All]
global record App record ProgressMonitor getProgress: function(ProgressMonitor): number
getTask: function(ProgressMonitor): string
end
quit: function(instant : boolean)
restart: function()
printMemoryStats: function()
startGame: function(startGameParams : StartGameParams)
startGame2: function(map : GameMap, seed : string, startDate : Date, startTimeOfDaySeconds : integer, startCloudCoverage : number, isMapEditor : boolean, mods : {Mod.ModId}, configDict : {{string, string}}, modParams : {string : {string : integer}})
stopGame: function()
findAllSavegames: function(namespace : string): {SaveGameInfo}
loadGame: function(saveId : SaveGameId, isMapEditor : boolean, info : SaveGameData.SaveGameDetails)
loadMission: function(saveId : SaveGameId, campaign : string, mission : string)
saveGame: function(name : string, callBack : function(), isMapEditor : boolean, skipSetName : boolean)
parseSavegameName: function(savegameName : string): ParsedSavegameName
getSavegameComplexity: function(saveGameDetails : SaveGameData.SaveGameDetails): integer
getSavegameComplexityLimit: function(): integer
getSavegameInfo: function(saveId : SaveGameId): Async<SaveGameData>
getSavegameImage: function(saveId : SaveGameId): GameScreenshot | nil
deleteSavegame: function(saveId : SaveGameId): boolean
getUserProfile: function(): UserProfile
findBuiltinSavegames: function(isMapSave : boolean): {SaveGameInfo}
getSaveGameStorageInfo: function(): SaveGameStorageInfo
getSupportedMSAASampleCounts: function(): {integer}
loadUserdata: function(directory : string, fileName : string): {<any type> : <any type>}
saveUserdata: function(directory : string, fileName : string, table : {<any type> : <any type>})
removeUserdata: function(directory : string, fileName : string)
getAllUserdata: function(directory : string): {string}
playVoiceOverOrStop: function(resName : string)
makeEmptyMap: function(climate : string, numTiles : Vec2i, waterLevel : number): GameMap
getInputActionRep: function(): InputActionRep
refreshMods: function()
setWaitForStartReadyGame: function()
isWaitForStartReadyGame: function(): boolean
startReadyGame: function()
getRandomTips: function(): {string}
getModTagTranslation: function(tag : string): string
getProgressMonitor: function(): ProgressMonitor
openUserDataFolder: function()
openUserDataSubFolder: function(directory : string)
getUserDataFolder: function(): string
getAllHeightmaps: function(): {string}
getGPUCapabilities: function(): GPUCapabilities
writeHeightmap: function(map : GameMap, path : string, writeStl : boolean, sixteenBits : boolean): boolean
showNodeEditor: function()
record SaveGameNamespace getUserdata: function(): string
getSavegame: function(): string
getSavemap: function(): string
end
record Debug setForcedGamepadDynamicScrollRepeatSpeed: function(speed : integer)
pushGamepadButtonKeyInputEvent: function(gamepadButtonName : string, press : boolean)
end
debug: Debug
end
App.ProgressMonitor🔗
record App.ProgressMonitor getProgress: function(ProgressMonitor): number
getTask: function(ProgressMonitor): string
end
App.ProgressMonitor.getProgress🔗
function App.ProgressMonitor.getProgress(ProgressMonitor): number
Returns the current progress as a value from 0 to 1
Parameters
ProgressMonitor
Returns
number
App.ProgressMonitor.getTask🔗
function App.ProgressMonitor.getTask(ProgressMonitor): string
Returns the current task being executed
Parameters
ProgressMonitor
Returns
string
App.quit🔗
function App.quit(instant : boolean)
Quit the application.
Parameters
instant:boolean— immediately quit one exit
App.restart🔗
function App.restart()
Restart the application
App.printMemoryStats🔗
function App.printMemoryStats()
Prints memory statistics to the log output.
App.startGame🔗
function App.startGame(startGameParams : StartGameParams)
Starts a new test game by specifying some basic parameters
Parameters
startGameParams:StartGameParams— start game parameters (optional) - if not set, the game will start with default values
App.startGame2🔗
function App.startGame2(map : GameMap, seed : string, startDate : Date, startTimeOfDaySeconds : integer, startCloudCoverage : number, isMapEditor : boolean, mods : {Mod.ModId}, configDict : {{string, string}}, modParams : {string : {string : integer}})
Starts a new game
Parameters
map:GameMap— the map to useseed:string— the seed use for the map generationstartDate:Date— the start datestartTimeOfDaySeconds:integer— is the start time of the day in secondsstartCloudCoverage:number— is the start cloud coverageisMapEditor:boolean— starting from map editormods:{Mod.ModId}— list of mods to start the game withconfigDict:{{string, string}}— list of game settingsmodParams:{string : {string : integer}}— list of mod params
App.stopGame🔗
function App.stopGame()
Stops the current game.
App.findAllSavegames🔗
function App.findAllSavegames(namespace : string): {SaveGameInfo}
Obtain list of all savegames.
Parameters
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
App.loadGame🔗
function App.loadGame(saveId : SaveGameId, isMapEditor : boolean, info : SaveGameData.SaveGameDetails)
Loads a savegame
Parameters
saveId:SaveGameId— the savegame idisMapEditor:boolean— if the savegame is loaded in the map editorinfo:SaveGameData.SaveGameDetails— savegame info (optional)
App.loadMission🔗
function App.loadMission(saveId : SaveGameId, campaign : string, mission : string)
Loads a mission
Parameters
saveId:SaveGameId— the savegame idcampaign:string— campaign namemission:string— mission name
App.saveGame🔗
function App.saveGame(name : string, callBack : function(), isMapEditor : boolean, skipSetName : boolean)
Saves the current game.
Parameters
name:string— the name of the savegamecallBack:function()— callback when the savegame is finishedisMapEditor:boolean— is saving from the map editorskipSetName:boolean— skips setting the savegame name as the current default savegame name (optional)
App.parseSavegameName🔗
function App.parseSavegameName(savegameName : string): ParsedSavegameName
Parse savegame info from its file name
Parameters
savegameName:string— the name of the savegame
Returns
ParsedSavegameName— The info (most notably, savegame type and group name)
App.getSavegameComplexity🔗
function App.getSavegameComplexity(saveGameDetails : SaveGameData.SaveGameDetails): integer
Get an estimated value of the savegame complexity
Parameters
saveGameDetails:SaveGameData.SaveGameDetails— the savegame data of the savegame
Returns
integer— a value that represents the estimate size of the savegame
App.getSavegameComplexityLimit🔗
function App.getSavegameComplexityLimit(): integer
Get an limit for the savegame complexity for the current platform
Returns
integer— the complexity limit for the current platform
App.getSavegameInfo🔗
function App.getSavegameInfo(saveId : SaveGameId): Async<SaveGameData>
Loads savegame metadata asynchronously.
Parameters
saveId:SaveGameId— the savegame id
Returns
Async<SaveGameData>— an async object with the savegame data
App.getSavegameImage🔗
function App.getSavegameImage(saveId : SaveGameId): GameScreenshot | nil
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
Parameters
saveId:SaveGameId— the savegame id
Returns
GameScreenshot | nil— the image, or nil if no preview image is available
App.deleteSavegame🔗
function App.deleteSavegame(saveId : SaveGameId): boolean
Deletes a savegame
Parameters
saveId:SaveGameId— the savegame to delete
Returns
boolean— if the savegame was successfully deleted
App.getUserProfile🔗
function App.getUserProfile(): UserProfile
Obtain the user profile.
Returns
UserProfile— the user profile
App.findBuiltinSavegames🔗
function App.findBuiltinSavegames(isMapSave : boolean): {SaveGameInfo}
Obtains a list of built-in savegames.
Parameters
isMapSave:boolean— true to list built-in maps, false to list built-in savegames
Returns
{SaveGameInfo}— list of savegames
App.getSaveGameStorageInfo🔗
function App.getSaveGameStorageInfo(): SaveGameStorageInfo
Returns the savegame storage infos
Returns
SaveGameStorageInfo— savegame storage info
App.getSupportedMSAASampleCounts🔗
function App.getSupportedMSAASampleCounts(): {integer}
Returns the supported MSAA sample counts
Returns
{integer}— list of supported sample counts
App.loadUserdata🔗
function App.loadUserdata(directory : string, fileName : string): {<any type> : <any type>}
Load a custom userdata file
Parameters
directory:string— a folder in the userdata directoryfileName:string— a lua filename (without .lua extension)
Returns
{<any type> : <any type>}— the deserialized lua data
App.saveUserdata🔗
function App.saveUserdata(directory : string, fileName : string, table : {<any type> : <any type>})
Saves a custom table as lua file.
Parameters
directory:string— a folder in the userdata directoryfileName:string— the filename to save to (without .lua extension)table:{<any type> : <any type>}— the table to serialize
App.removeUserdata🔗
function App.removeUserdata(directory : string, fileName : string)
Removes a userdata.
Parameters
directory:string— a folder in the userdata directoryfileName:string— the filename to remove (without .lua extension)
App.getAllUserdata🔗
function App.getAllUserdata(directory : string): {string}
Returns a list of all saved mod preset names.
Parameters
directory:string— a folder in the userdata directory
Returns
{string}— a list of mod preset names
App.playVoiceOverOrStop🔗
function App.playVoiceOverOrStop(resName : string)
Plays a voice over if not currently playing, otherwise stops it.
Parameters
resName:string— the file to play
App.makeEmptyMap🔗
function App.makeEmptyMap(climate : string, numTiles : Vec2i, waterLevel : number): GameMap
Creates an empty map (for tooling / map generation workflows).
Parameters
climate:string— climate resource namenumTiles:Vec2i— map dimension in tileswaterLevel:number— water level height
Returns
GameMap— the map
App.getInputActionRep🔗
function App.getInputActionRep(): InputActionRep
Returns the global input action repository.
Returns
InputActionRep— input action repository
App.refreshMods🔗
function App.refreshMods()
Refreshes the installed mods
App.setWaitForStartReadyGame🔗
function 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
App.isWaitForStartReadyGame🔗
function App.isWaitForStartReadyGame(): boolean
Return if the setWaitForStartReadyGame had been called for this game.
Returns
boolean
App.startReadyGame🔗
function App.startReadyGame()
Start Game that is fully loaded and ready to play. This is called after the progress page has finished loading the game.
App.getRandomTips🔗
function App.getRandomTips(): {string}
Gets the list of random tips
Returns
{string}— a list of tips as string
App.getModTagTranslation🔗
function App.getModTagTranslation(tag : string): string
Returns a translated name for a mod tag.
Parameters
tag:string— tag to translate
Returns
string— the translated tag
App.getProgressMonitor🔗
function App.getProgressMonitor(): ProgressMonitor
Gets the load progress monitor
Returns
ProgressMonitor
App.openUserDataFolder🔗
function App.openUserDataFolder()
Opens the user data folder in the OS file manager
App.openUserDataSubFolder🔗
function App.openUserDataSubFolder(directory : string)
Opens the heightmaps folder in the OS file manager
Parameters
directory:string— subfolder
App.getUserDataFolder🔗
function App.getUserDataFolder(): string
Gets the directory containing userdata
Returns
string
App.getAllHeightmaps🔗
function App.getAllHeightmaps(): {string}
Gets a list of all heightmaps in the userdata directory
Returns
{string}— list of heightmaps files
App.getGPUCapabilities🔗
function App.getGPUCapabilities(): GPUCapabilities
Get information about the GPU
Returns
GPUCapabilities
App.writeHeightmap🔗
function App.writeHeightmap(map : GameMap, path : string, writeStl : boolean, sixteenBits : boolean): boolean
Writes a heightmap image (and optionally an STL) for a map.
Parameters
map:GameMap— the map to writepath:string— the relative path (extension will be added if missing)writeStl:boolean— write as an STL file as wellsixteenBits:boolean— use 16 bits depth for the heightmap (default 8 bits depth)
Returns
boolean— if the heightmap was successfully written
App.showNodeEditor🔗
function App.showNodeEditor()
Shows the node editor.
App.SaveGameNamespace🔗
record App.SaveGameNamespace getUserdata: function(): string
getSavegame: function(): string
getSavemap: function(): string
end
Savegame namespace constants.
App.SaveGameNamespace.getUserdata🔗
function App.SaveGameNamespace.getUserdata(): string
Returns the userdata savegame namespace.
Returns
string
App.SaveGameNamespace.getSavegame🔗
function App.SaveGameNamespace.getSavegame(): string
Returns the savegame namespace.
Returns
string
App.SaveGameNamespace.getSavemap🔗
function App.SaveGameNamespace.getSavemap(): string
Returns the savemap namespace.
Returns
string
App.Debug🔗
record App.Debug setForcedGamepadDynamicScrollRepeatSpeed: function(speed : integer)
pushGamepadButtonKeyInputEvent: function(gamepadButtonName : string, press : boolean)
end
App.Debug.setForcedGamepadDynamicScrollRepeatSpeed🔗
function App.Debug.setForcedGamepadDynamicScrollRepeatSpeed(speed : integer)
Overrides gamepad dynamic scroll repeat speed.
Parameters
speed:integer— the scroll speed (0: 1/sec, 3: max speed), or nil to clear the override
App.Debug.pushGamepadButtonKeyInputEvent🔗
function App.Debug.pushGamepadButtonKeyInputEvent(gamepadButtonName : string, press : boolean)
Pushes a gamepad button event into the input queue.
Parameters
gamepadButtonName:string— the button to pushpress:boolean— if pressed
App.debug🔗
App.debug: Debug