Skip to content

gui

Source: api/tealdef/api/gui.d.tl

Contains all GUI functionality apart from react.

NinePatch

record global api/tealdef/api/gui.d.tl:6

global record NinePatch

Access: api.gui.NinePatch

Nine-patch image description.

Fields

Name Type Description
fileName string Path of the image file (::/... resource path, usually a .tga).
horizontal {integer} Four horizontal pixel coordinates that split the image into left edge, stretchable middle and right edge.
vertical {integer} Four vertical pixel coordinates that split the image into top edge, stretchable middle and bottom edge (same layout as horizontal).
flipHorizontally boolean Draws the image mirrored left to right. Used for vehicle icons that face the other way (gui/line_vehicle_mgmt/vehicle_react_util.tl).
repeatHorizontally boolean Tiles the middle part horizontally instead of stretching it (see repeatFactor). Used for the game bar background (gui/game_bar/game_bar.css.lua).
repeatVertically boolean Tiles the image vertically instead of stretching it (see repeatFactor).
repeatFactor number Repeat factor (must be positive).

Functions

new() : NinePatch api/tealdef/api/gui.d.tl:7

Call as api.gui.NinePatch.new(…)

Notes

Creates a new, empty NinePatch.

Returns NinePatch

Used in the base game: 1 time in 1 file

base/content/gui/gui/line_vehicle_mgmt/vehicle_react_util.tl:95

local backGroundImage1 = api.gui.NinePatch.new()

StyleSheet

record global api/tealdef/api/gui.d.tl:20

global record StyleSheet

Access: api.gui.StyleSheet

Stylesheet used by GUI components.

Fields

Name Type Description
backgroundColor Vec4f Background colour (RGBA, components 0..1).
backgroundColor1 Vec4f Colour of the first background layer; with backgroundImage1 it tints that image (base game pairs them, e.g. white for an untinted image).
backgroundColor2 Vec4f Colour of the second background layer (pairs with backgroundImage2).
backgroundImage1 NinePatch First background image layer, as a nine-patch.
backgroundImage2 NinePatch Second background image layer, drawn in addition to the first (the base game uses it for overlays such as button glyphs and corner decorations).
borderWidth Vec4f Border width in pixels, one value per side (CSS files write it as { 2, 2, 2, 2 }).
borderColor Vec4f Colour of the border (RGBA, components 0..1).
color Vec4f Foreground colour, used for text and to tint images (RGBA, components 0..1).
size Vec2f Fixed size of the component in pixels (width, height).
padding Vec4f Inner spacing in pixels, one value per side; the first value is the top.
fontSize integer Font size in pixels.
borderImage NinePatch Nine-patch image drawn as the border / contour of the component.
anchorPoint Vec2f Point of the component that is placed at its position, as fractions of its size ({0.5, 0.5} = centre, {0, 0} = top-left corner).

Functions

new() : StyleSheet api/tealdef/api/gui.d.tl:21

Call as api.gui.StyleSheet.new(…)

Notes

Creates a new, empty StyleSheet.

Returns StyleSheet

Used in the base game: 1 time in 1 file

base/content/gui/gui/main/styleutil.tl:4

local style =  api.gui.StyleSheet.new()

Gui

record global api/tealdef/api/gui.d.tl:45

global record Gui

Access: api.gui

Main GUI interface

Fields

Name Type Description
mouse Mouse Mouse input (Gui.Mouse).
key Key Key input (Gui.Key).
dnd DnD Drag and drop (Gui.DnD).
inputAction InputAction Input actions / key bindings (Gui.InputAction).
byId ById Access to GUI components by id or tag (Gui.ById).
camera Camera Camera control (Gui.Camera).
sound Sound Sound effects (Gui.Sound).
musicPlayer MusicPlayer Music player (Gui.MusicPlayer).
backend Backend Paradox account backend (Gui.Backend).
voiceOverManager VoiceOverManager Voice-over playback (Gui.VoiceOverManager).
byEntity ByEntity Visibility checks for entities (Gui.ByEntity).
contextHelper ContextHelper Context help data (Gui.ContextHelper).
construction Construction Construction-tool helpers (Gui.Construction).
mission Mission Mission zones, markers and cutscenes (Gui.Mission).
guide Guide Guide system (Gui.Guide).
game Game Game-session helpers (Gui.Game).
map Map Map and terrain editor (Gui.Map).
benchMark BenchMark Timing data (Gui.BenchMark).
rendering Rendering Rendering helpers (Gui.Rendering).
debug Debug Debug helpers (Gui.Debug).
achievements Achievements Achievements and player stats (Gui.Achievements).
genericRep GenericRep GUI generic resources (Gui.GenericRep). used 606× in the base game
StyleSheet StyleSheet The StyleSheet record, reached as api.gui.StyleSheet (use api.gui.StyleSheet.new()).
NinePatch NinePatch The NinePatch record, reached as api.gui.NinePatch (use api.gui.NinePatch.new()).

Functions

fireReactEvent(name : string, param : any) api/tealdef/api/gui.d.tl:49

Call as api.gui.fireReactEvent(…)

Fire a react event (same as react.fireEvent() but from outside of react)

Parameter Type Description
name string the event name
param any the event parameter
Used in the base game: 30 times in 19 files

base/content/game_mechanics/game_mechanics/celebrations/celebration_react_util.tl:118

api.gui.fireReactEvent("selectEntity", {
base/content/game_mechanics/game_mechanics/celebrations/celebrations.script.tl:330
api.gui.fireReactEvent("celebration-add", { type = "ProductDeliveredToTown", entity = entityAndRev, value = v.counter, reputationEffect = v.reputationEffect })
base/content/game_mechanics/game_mechanics/notifications/notification_util.tl:451
api.gui.fireReactEvent("selectEntity", {
base/content/game_mechanics/game_mechanics/notifications/types/line_station_warning.script.tl:145
api.gui.fireReactEvent("selectEntity", {
base/content/game_mechanics/game_mechanics/notifications/types/line_warning.script.tl:199
api.gui.fireReactEvent("selectEntity", {
base/content/game_mechanics/game_mechanics/notifications/types/town_warning.script.tl:44
api.gui.fireReactEvent("selectEntity", {
… and 13 more files.

fireGuiScriptEvent(id : string, name : string, param : any) : any api/tealdef/api/gui.d.tl:57

Call as api.gui.fireGuiScriptEvent(…)

Fire a game gui script event. This event is meant to be handled by game scripts (guiHandleEvent), not by react.onEvent(). It differs from react.fireEvent in that it allows to return a value (like an error string to prevent the operation)

Parameter Type Description
id string the component id
name string the event name
param any event-specific parameters

Returns any: the result from the event handler

Example

-- tell game scripts (guiHandleEvent) that a world position was clicked
api.gui.fireGuiScriptEvent("mainView", "select-world", {
  pos = { world.pos.x, world.pos.y, world.pos.z },
  water = world.water,
})
Used in the base game: 31 times in 13 files

base/content/gui/gui/construction/construction_react_util.tl:1531

local errorMessages = api.gui.fireGuiScriptEvent("", "company.lockPermits", {
base/content/gui/gui/construction/tools/marketing_campaign_tool.script.tl:83
local errorMessages = api.gui.fireGuiScriptEvent("", "company.lockPermits", {
base/content/gui/gui/entity_window/view_manager.tl:268
api.gui.fireGuiScriptEvent("entityWindow", "locate", params.keyEntity)
base/content/gui/gui/game_bar/game_bar_widgets.tl:449
api.gui.fireGuiScriptEvent("calendar", "onManualTimeChanged", value)
base/content/gui/gui/layers/layer_terrain.tl:197
api.gui.fireGuiScriptEvent("mainView", "select", entity)
base/content/gui/gui/layers/layers_button_ridge.tl:332
api.gui.fireGuiScriptEvent("menu.layersButton", "toggleButton.toggle", value == 1)
… and 7 more files.

spawnEphemeralHudImage(iconPath : FilePath, entity : Engine.Entity, color? : Vec4f, position? : Vec3f, overrideDuration? : number, fadeIn? : boolean, fadeOut? : boolean, rev0? : integer) api/tealdef/api/gui.d.tl:89

Call as api.gui.spawnEphemeralHudImage(…)

Spawn a short-lived floating image as a hud-icon

Parameter Type Description
iconPath FilePath The icon to be used
entity Engine.Entity Optional entity (if not used, you must specify position instead)
color? Vec4f Optional color (if not used, the icon is expected to have color channels)
position? Vec3f Optional position (if not used, position is obtained from the entity)
overrideDuration? number Optional duration in seconds
fadeIn? boolean Optional: Start invisible and fade in (default: false)
fadeOut? boolean Optional: Slowly fade out at the end (default: true)
rev0? integer Optional revision0 (if not used, defaults to api.engine.getRevision(entity).num[1])

Example

-- happy / sad emote above a simulation entity (gui/hud/happy_change_display.script.tl)
api.gui.spawnEphemeralHudImage("::/gui/main/icons/symbol_emote_happy_colored.tga", simEntity)
Used in the base game: 5 times in 4 files

base/content/gui/gui/hud/greenification_display.script.tl:151

api.gui.spawnEphemeralHudImage("::/gui/main/icons/symbol_emote_leaf_colored.tga", entity, nil, api.type.Vec3f.new(pos[1], pos[2], pos[3]), IconLifetime, true)
base/content/gui/gui/hud/happy_change_display.script.tl:85
api.gui.spawnEphemeralHudImage("::/gui/main/icons/symbol_emote_happy_colored.tga", simEntity)
base/content/gui/gui/hud/marketing_display.script.tl:158
api.gui.spawnEphemeralHudImage("::/gui/main/icons/symbol_emote_megaphone_colored.tga", nil, nil,
base/content/gui/gui/line_vehicle_mgmt/vehicle_react_util.tl:405
api.gui.spawnEphemeralHudImage("::/gui/main/icons/symbol_emote_happy_colored.tga", change.vehicleEntity)

spawnEphemeralHudImageOnPath(iconPath : FilePath, pos0 : Vec3f, pos1 : Vec3f, tan0 : Vec3f, tan1 : Vec3f, speed : number, scale : number, maxDistance : number) api/tealdef/api/gui.d.tl:100

Call as api.gui.spawnEphemeralHudImageOnPath(…)

Spawns a short icon that follows a path

Parameter Type Description
iconPath FilePath The icon to be used
pos0 Vec3f The starting tangent of the icon
pos1 Vec3f The end tangent of the icon
tan0 Vec3f Start tangent of the path (the @param comments in the game file name it pos0 by mistake).
tan1 Vec3f End tangent of the path.
speed number The speed (in m/s) of the icon
scale number A scaling factor for the size of the icon
maxDistance number The maximal distance at which the icon will be rendered

Example

-- cargo icon arcing from pos0 to pos1 (gui/hud/cargo_flow.script.tl)
local d = api.type.Vec3f.distance(pos0, pos1) / 2
api.gui.spawnEphemeralHudImageOnPath(cargoType.icon, pos0, pos1,
  api.type.Vec3f.new(0, 0, 1) * d, api.type.Vec3f.new(0, 0, -1) * d, 125, 0.75, 2500.0)
Used in the base game: 1 time in 1 file

base/content/gui/gui/hud/cargo_flow.script.tl:156

api.gui.spawnEphemeralHudImageOnPath(cargoType.icon, toVec3f(flow.pos0),

closeAllWindows() api/tealdef/api/gui.d.tl:104

Call as api.gui.closeAllWindows(…)

Close all windows

Used in the base game: 1 time in 1 file

base/content/gui/gui/main/game.tl:229

api.gui.closeAllWindows()

Gui.HighlightStyle

record api/tealdef/api/gui.d.tl:59

record HighlightStyle

Notes

Shape of the highlight drawn around a GUI component by api.gui.byId.setHighlighted.

Example

-- mission/mission_sim.script.tl
api.gui.byId.setHighlighted(idOrTag, true, api.gui.HighlightStyle.Circle, color_util.toVec3(mission_colors.Highlight))
-- remove the highlight again
api.gui.byId.setHighlighted(idOrTag, nil)
Used in the base game: 1 time in 1 file

base/content/mission/mission/mission_sim.script.tl:1180

local style : Gui.HighlightStyle

Fields

Name Type Description
Square HighlightStyle Square highlight around the component. used 1× in the base game
Circle HighlightStyle Circular highlight (the default of setHighlighted). used 1× in the base game
Mask HighlightStyle Highlight drawn as a mask of the component's shape. used 1× in the base game

Gui.SpawnHudImageParams

record api/tealdef/api/gui.d.tl:66

record SpawnHudImageParams

Notes

Description of a floating HUD icon (icon path, optional tint colour, entity or position); the fields mirror the parameters of spawnEphemeralHudImage.

Fields

Name Type Description
iconPath FilePath Mandatory path to the icon
color Vec4f Optional color. If set, the icon is expected to be grayscale.
entity Engine.Entity Optional entity (if not used, specify position)
position Vec3f Optional position (if not used, position of the entity is used)

Gui.SelectionDetails

record userdata api/tealdef/api/gui.d.tl:107

record SelectionDetails

Access: api.gui.SelectionDetails

Carries details about selection event

Used in the base game: 18 times in 7 files

base/content/gui/gui/construction/construction_react_util.tl:1312

local onHoverCallback = function(entity : Engine.Entity, indices : {integer}, details : Gui.SelectionDetails)
base/content/gui/gui/construction/tools/marketing_campaign_tool.script.tl:34
onHover = function(__ : ConstructionCustomActionParams<string>, entity : Engine.Entity, __ : {integer}, __ : Gui.SelectionDetails) : SelectorBasedActionHoverRes
base/content/gui/gui/entity_window/double_slip_switch.tl:191
onHover = function(entity : Engine.Entity, indices : {integer}, _details : Gui.SelectionDetails)
base/content/gui/gui/layers/layer_terrain.tl:184
onHover = function(entity : Engine.Entity, _indices : {integer}, _apiDetails : Gui.SelectionDetails)
base/content/gui/gui/line_vehicle_mgmt/line_util.tl:382
line_util.convertDetails = function(entity : Engine.Entity, apiDetails : Gui.SelectionDetails) : LineUtil.SelectionDetails
base/content/gui/gui/main/selector_react_util.tl:101
onHover = function(entity : Engine.Entity, _indices : {integer}, _apiDetails : Gui.SelectionDetails)
… and 1 more files.

Fields

Name Type Description
data DataType variant: nil|Line|Station|Signal|Stop|Waypoint|TransportNetworkEdge|World|Marker|Town

Functions

new() : SelectionDetails api/tealdef/api/gui.d.tl:109

Call as api.gui.SelectionDetails.new(…)

Notes

Creates a new, empty SelectionDetails.

Returns SelectionDetails

new(copy : SelectionDetails) : SelectionDetails api/tealdef/api/gui.d.tl:110

Call as api.gui.SelectionDetails.new(…)

Notes

Creates a new, empty SelectionDetails.

Returns SelectionDetails

Gui.SelectionDetails.Type

record api/tealdef/api/gui.d.tl:112

record Type

Access: api.gui.SelectionDetails.Type

Notes

Kind of object under the cursor / selected; the value of SelectionDetails.data.kind.

Details

Check data.kind first, then cast data to the matching Gui.SelectionDetails.* record.

Used in the base game: 9 times in 1 file

base/content/gui/gui/hud/hud_react_util.tl:36

local forSubEntities : {{Gui.SelectionDetails.Type, Builtin.Type.VisibilityThresholds.OfSubEntity}} = {}

Fields

Name Type Description
None Type Nothing specific selected (data carries no details).
Line Type A line segment; data is a SelectionDetails.Line. used 2× in the base game
Station Type A station group, station or terminal; data is a SelectionDetails.Station. used 8× in the base game
Signal Type A signal; data is a SelectionDetails.Signal. used 1× in the base game
Stop Type A stop of a line; data is a SelectionDetails.Stop. used 1× in the base game
Waypoint Type A waypoint of a line; data is a SelectionDetails.Waypoint. used 1× in the base game
TransportNetworkEdge Type A point on a transport-network edge (track, street, ...); data is a SelectionDetails.TransportNetworkEdge. used 1× in the base game
World Type A position in the world (terrain or water); data is a SelectionDetails.World. used 2× in the base game
Marker Type A mission marker; data is a SelectionDetails.Marker. used 2× in the base game
Town Type A town or one of its districts; data is a SelectionDetails.Town. used 9× in the base game

Gui.SelectionDetails.DataType

interface api/tealdef/api/gui.d.tl:125

interface DataType is userdata

Access: api.gui.SelectionDetails.DataType

Notes

Common base of all selection detail records; kind tells which one it is.

Example

-- in a builtin.Selector onSelect / onHover callback (gui/line_vehicle_mgmt/line_util.tl)
onSelect = function(entity, indices, apiDetails)
  if apiDetails and apiDetails.data then
    if apiDetails.data.kind == api.gui.SelectionDetails.Type.Station then
      local st = apiDetails.data  -- Gui.SelectionDetails.Station
      print(st.stationGroup, st.stationTerminal.station, st.stationTerminal.terminal)
    elseif apiDetails.data.kind == api.gui.SelectionDetails.Type.World then
      local w = apiDetails.data   -- Gui.SelectionDetails.World
      print(w.pos.x, w.pos.y, w.pos.z, w.water)
    end
  end
  return true
end

Fields

Name Type Description
kind Type Which kind of details this is; selects the record to cast data to.

Gui.SelectionDetails.Line

record api/tealdef/api/gui.d.tl:131

record Line is DataType

Access: api.gui.SelectionDetails.Line

Carries details about selection event for a Line.

Used in the base game: 2 times in 1 file

base/content/gui/gui/line_vehicle_mgmt/line_util.tl:314

local function convertLineDetails(apiDetails : Gui.SelectionDetails.Line) : LineUtil.LineSelectionDetails

Fields

Name Type Description
line Engine.Entity The line entity
stop integer Stop index where the selected line segment starts
waypoint integer Waypoint index identifying the selected subsegment (-1: no waypoints, 0 = begins at stop, numWaypoints = ends at next stop)

Gui.SelectionDetails.Station

record api/tealdef/api/gui.d.tl:141

record Station is DataType

Access: api.gui.SelectionDetails.Station

Carries details about selection event for a Station, StationGroup or Terminal

Used in the base game: 7 times in 4 files

base/content/gui/gui/layers/layer_public_transport.tl:106

local stationSelectionDetails = params.details.data as Gui.SelectionDetails.Station
base/content/gui/gui/line_vehicle_mgmt/line_util.tl:323
local function convertStationDetails(apiDetails : Gui.SelectionDetails.Station) : LineUtil.StationSelectionDetails
base/content/gui/gui/main/hud_icon_toolbox.tl:218
local stationSelectionDetails = params.details.data as Gui.SelectionDetails.Station
base/content/gui/gui/statistics/statistics.tl:372
local function filterForCarrier(entity : Engine.Entity,  hudStationDetails? : Gui.SelectionDetails.Station) : boolean

Fields

Name Type Description
stationGroup Engine.Entity The station group entity
flatStationTerminalIndex integer Index in the the StationGroup's flattened list of station/terminals
stationTerminal StationTerminal Station and terminal indices (zero-based) inside the station group; an index is -1 when only the group or station, not a terminal, is selected.

Functions

new() : Station api/tealdef/api/gui.d.tl:142

Call as api.gui.SelectionDetails.Station.new(…)

Notes

Creates a new, empty Station.

Returns Station

Used in the base game: 1 time in 1 file

base/content/gui/gui/line_vehicle_mgmt/line_util.tl:949

local apiStation = api.gui.SelectionDetails.Station.new()

Gui.SelectionDetails.Signal

record api/tealdef/api/gui.d.tl:153

record Signal is DataType

Access: api.gui.SelectionDetails.Signal

Carries details about selection event for a Signal

Used in the base game: 2 times in 1 file

base/content/gui/gui/line_vehicle_mgmt/line_util.tl:350

local function convertSignalDetails(apiDetails : Gui.SelectionDetails.Signal) : LineUtil.SignalSelectionDetails

Fields

Name Type Description
signalList Engine.Entity The signalList entity
signalIndex integer Index of the actual signal in the the SignalList

Gui.SelectionDetails.Stop

record api/tealdef/api/gui.d.tl:161

record Stop is DataType

Access: api.gui.SelectionDetails.Stop

Carries details about selection event for a Stop (terminal) inside a line

Used in the base game: 2 times in 1 file

base/content/gui/gui/line_vehicle_mgmt/line_util.tl:357

local function convertStopDetails(apiDetails : Gui.SelectionDetails.Stop) : LineUtil.StopSelectionDetails

Fields

Name Type Description
station SelectionDetails.Station The station / terminal
line Engine.Entity The line entity
stopIndex integer Index of the stop in the line

Functions

new() : Stop api/tealdef/api/gui.d.tl:162

Call as api.gui.SelectionDetails.Stop.new(…)

Notes

Creates a new, empty Stop.

Returns Stop

Used in the base game: 1 time in 1 file

base/content/gui/gui/line_vehicle_mgmt/line_util.tl:948

local apiStop = api.gui.SelectionDetails.Stop.new()

Gui.SelectionDetails.Waypoint

record api/tealdef/api/gui.d.tl:173

record Waypoint is DataType

Access: api.gui.SelectionDetails.Waypoint

Carries details about selection event for a waypoint inside a line

Used in the base game: 2 times in 1 file

base/content/gui/gui/line_vehicle_mgmt/line_util.tl:366

local function convertWaypointDetails(apiDetails : Gui.SelectionDetails.Waypoint) : LineUtil.WaypointSelectionDetails

Fields

Name Type Description
line Engine.Entity The line entity
stopIndex integer Index of the stop in the line
waypointIndex integer Index of the waypoint in the line (index in stop.waypoints)
tag integer Tag of the waypoint; match it against tag of the entries in the line stop's waypoints to find the waypoint index (line_util.computeWaypointIndex0FromTag).

Gui.SelectionDetails.TransportNetworkEdge

record api/tealdef/api/gui.d.tl:185

record TransportNetworkEdge is DataType

Access: api.gui.SelectionDetails.TransportNetworkEdge

Carries details about selection event for a Transport Network Edge

Used in the base game: 2 times in 1 file

base/content/gui/gui/line_vehicle_mgmt/line_util.tl:376

local function convertTransportNetworkEdgeDetails(apiDetails : Gui.SelectionDetails.TransportNetworkEdge) : LineUtil.TransportNetworkEdgeSelectionDetails

Fields

Name Type Description
snap EdgePos Position on the edge closest to the cursor (edge id and parameter along it).

Functions

new() : TransportNetworkEdge api/tealdef/api/gui.d.tl:186

Call as api.gui.SelectionDetails.TransportNetworkEdge.new(…)

Notes

Creates a new, empty TransportNetworkEdge.

Returns TransportNetworkEdge

Used in the base game: 1 time in 1 file

base/content/gui/gui/line_vehicle_mgmt/line_util.tl:965

local apiSnap = api.gui.SelectionDetails.TransportNetworkEdge.new()

Gui.SelectionDetails.World

record api/tealdef/api/gui.d.tl:192

record World is DataType

Access: api.gui.SelectionDetails.World

Carries details about the cursor location in the world.

Used in the base game: 2 times in 2 files

base/content/gui/gui/line_vehicle_mgmt/line_util.tl:397

return { world = apiDetails.data as Gui.SelectionDetails.World }
base/content/gui/gui/main/selector_react_util.tl:111
local world = apiDetails.data as Gui.SelectionDetails.World

Fields

Name Type Description
pos Vec3f Position in world coordinates.
water boolean Whether the position is on water.

Functions

new() : World api/tealdef/api/gui.d.tl:193

Call as api.gui.SelectionDetails.World.new(…)

Notes

Creates a new, empty World.

Returns World

Gui.SelectionDetails.Marker

record api/tealdef/api/gui.d.tl:200

record Marker is DataType

Access: api.gui.SelectionDetails.Marker

Carries details about selection event for a Marker.

Used in the base game: 3 times in 2 files

base/content/gui/gui/layers/layer_terrain.tl:200

react.fireEvent(param.toolParam.gameCtx.rendererComponent, "selectMarker", (apiDetails.data as Gui.SelectionDetails.Marker).marker)
base/content/gui/gui/main/selector_react_util.tl:119
local marker = apiDetails.data as Gui.SelectionDetails.Marker

Fields

Name Type Description
marker string Key of the marker (as given to api.gui.mission.setMarkerAtPosition / setMarkerAtEntity).
fireSelectEntity boolean If true, select the underlying entity of the marker (default = true)
pos Vec3f Get the marker position (if it is a position marker)
entity Engine.Entity Get the marked entity (if it is an entity marker)

Functions

new() : Marker api/tealdef/api/gui.d.tl:201

Call as api.gui.SelectionDetails.Marker.new(…)

Notes

Creates a new, empty Marker.

Returns Marker

Gui.SelectionDetails.Town

record api/tealdef/api/gui.d.tl:213

record Town is DataType

Access: api.gui.SelectionDetails.Town

Carries details about selection event for a Town.

Used in the base game: 5 times in 3 files

base/content/gui/gui/construction/constructionHudIconMaster.tl:145

local townSelectionDetails = param.details.data as Gui.SelectionDetails.Town
base/content/gui/gui/layers/layer_cargo_flow.tl:69
local townSelectionDetails = param.details.data as Gui.SelectionDetails.Town
base/content/gui/gui/line_vehicle_mgmt/line_util.tl:399
return { townData = apiDetails.data as Gui.SelectionDetails.Town }

Fields

Name Type Description
townEntity Engine.Entity Entity of the town.
districtType LandUseType Land use type of the selected district; nil when the town as a whole is selected.
districtCenter Vec3f Centre position of the selected district (world coordinates).

Functions

new() : Town api/tealdef/api/gui.d.tl:214

Call as api.gui.SelectionDetails.Town.new(…)

Notes

Creates a new, empty Town.

Returns Town

Gui.WorldEvent

record api/tealdef/api/gui.d.tl:224

record WorldEvent

Notes

Parameter of the select-world GUI script event, fired when the player clicks a position in the world.

Example

-- in a guiHandleEvent handler (campaign mission 05, send_vehicle.tl)
if name == "select-world" then
  if param.water then
    print("water clicked at", param.pos[1], param.pos[2])
  end
end
Used in the base game: 1 time in 1 file

mods/release/urbangames_campaign_mission_05/content/mission/mission/tasks/drilling/send_vehicle.tl:210

local worldEvent = param as Gui.WorldEvent

Fields

Name Type Description
pos {number, number, number} Clicked position as {x, y, z} in world coordinates.
water boolean Whether the clicked position is on water.

Gui.Mouse

record api/tealdef/api/gui.d.tl:229

record Mouse

Access: api.gui.mouse

Notes

Mouse input, reached as api.gui.mouse.

Example

-- react recipe: close a popup when the user clicks elsewhere (gui/main/callout_react_util.tl)
react.onMouseEvent(function(evt)
  if evt.type == api.gui.mouse.Event.Type.PressedOutside and evt.button == 0 then
    params.onClose()
    return true   -- handled
  end
  return false
end)

Functions

getTerrainPosition() : Vec3f api/tealdef/api/gui.d.tl:262

Call as api.gui.mouse.getTerrainPosition(…)

Gets the last valid terrain position pointed by the mouse.

Returns Vec3f: coordinates of the terrain position

Used in the base game: 2 times in 2 files

base/content/gui/gui/layers/layer_react_util.tl:60

local pos =api.gui.mouse.getTerrainPosition()
base/content/gui/gui/main/game_tooltips.tl:238
local pos = api.gui.mouse.getTerrainPosition()

hasTerrainPosition() : boolean api/tealdef/api/gui.d.tl:265

Call as api.gui.mouse.hasTerrainPosition(…)

Returns whether a valid terrain position is currently available.

Returns boolean: boolean true if the mouse is pointing at the terrain

Used in the base game: 1 time in 1 file

base/content/gui/gui/main/game_tooltips.tl:229

if not api.gui.mouse.hasTerrainPosition() then

Gui.Mouse.Event

record api/tealdef/api/gui.d.tl:231

record Event

Represents a mouse event

Used in the base game: 32 times in 21 files

base/content/game_mechanics/game_mechanics/celebrations/celebration_react_util.tl:80

react.onMouseEvent(function (evt : Gui.Mouse.Event) : boolean
base/content/game_mechanics/game_mechanics/finance/finances_react_util.tl:102
react.onMouseEvent(function (evt :  Gui.Mouse.Event) : boolean
base/content/game_mechanics/game_mechanics/notifications/gui/notification_log.tl:125
react.onMouseEvent(function (evt : Gui.Mouse.Event) : boolean
base/content/game_mechanics/game_mechanics/notifications/gui/notification_popups.tl:116
react.onMouseEvent(function (evt : Gui.Mouse.Event) : boolean
base/content/gui/gui/construction/construction.tl:2896
react.onMouseEvent(function (evt : Gui.Mouse.Event) : boolean
base/content/gui/gui/line_vehicle_mgmt/cargofilter_window.tl:130
react.onMouseEvent(function (evt :  Gui.Mouse.Event) : boolean
… and 15 more files.

Fields

Name Type Description
type Type Event type.
button integer Mouse button: 0 = left, 1 = middle, 2 = right.
x integer Horizontal position of the mouse when event was triggered
y integer Vertical position of the mouse when event was triggered
xrel integer Relative horizontal movement.
yrel integer Relative vertical movement.
handled boolean Whether the event was already handled by a child component.
Gui.Mouse.Event.Type

record api/tealdef/api/gui.d.tl:232

record Type

Notes

Kind of mouse event (Gui.Mouse.Event.type).

Fields

Name Type Description
Pressed Type A mouse button was pressed over the component. used 14× in the base game
Released Type A mouse button was released. used 15× in the base game
Clicked Type A mouse button was clicked (pressed and released) on the component. used 6× in the base game
Entered Type The cursor entered the component (base game uses it for hover states). used 11× in the base game
Exited Type The cursor left the component. used 8× in the base game
Moved Type The cursor moved over the component. used 1× in the base game
Wheel Type The mouse wheel was turned. used 1× in the base game
DoubleClicked Type A mouse button was double-clicked.
PressedOutside Type A mouse button was pressed outside the component; used to close popups and dialogs. used 6× in the base game

Gui.Key

record api/tealdef/api/gui.d.tl:268

record Key

Access: api.gui.key

Notes

Keyboard / gamepad key input, reached as api.gui.key.

Gui.Key.State

record api/tealdef/api/gui.d.tl:269

record State

Notes

Direction of a key event (InputEvent.dir).

Fields

Name Type Description
Up State The key was released. used 1× in the base game
Pressed State The key was pressed. used 1× in the base game

Gui.Key.InputEvent

record api/tealdef/api/gui.d.tl:274

record InputEvent

Notes

Raw input event data of a key event.

Fields

Name Type Description
dir State Whether the key was pressed or released.
repeated boolean Whether the event is an automatic key repeat.

Functions

isGamepadEvent(InputEvent) : boolean api/tealdef/api/gui.d.tl:278

Returns whether this is a gamepad event.

Returns boolean

isKeyboardEvent(InputEvent) : boolean api/tealdef/api/gui.d.tl:280

Returns whether this is a keyboard event.

Returns boolean

getKey(InputEvent) : integer api/tealdef/api/gui.d.tl:282

Returns the key code.

Returns integer

getKeyMod(InputEvent) : integer api/tealdef/api/gui.d.tl:284

Returns key modifiers.

Returns integer

Gui.Key.Event

record api/tealdef/api/gui.d.tl:288

record Event

Represents a key press event.

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/settings_page.tl:271

keyListener = function(evt : Gui.Key.Event) : boolean

Fields

Name Type Description
data InputEvent Input data of the key event (direction, key code, modifiers).

Functions

isPressed(Event) : boolean api/tealdef/api/gui.d.tl:291

Returns whether the key is pressed.

Returns boolean

Gui.DataTransferItem

record api/tealdef/api/gui.d.tl:295

record DataTransferItem

Access: api.gui.DataTransferItem

Notes

One item carried by a drag and drop operation, a type resource name plus serializable data.

Example

-- vehicle_store_window.tl; the type names a resource of type "drag_and_drop"
local item = api.gui.DataTransferItem.new("::/gui/line_vehicle_mgmt/dnd_train_composition.res",
  { vehicleIndex = vehicleIndex, partIndex = partIndex })
Used in the base game: 4 times in 2 files

base/content/gui/gui/line_vehicle_mgmt/line_manager_panel.tl:502

) : Gui.DataTransferItem
base/content/gui/gui/line_vehicle_mgmt/vehicle_store_window.tl:2946
) : Gui.DataTransferItem

Fields

Name Type Description
type ResName Resource name that identifies the kind of item; drop targets filter on it.
data any type-specific data. Note that this needs to be serializable.

Functions

new(ResName, any) : DataTransferItem api/tealdef/api/gui.d.tl:296

Call as api.gui.DataTransferItem.new(…)

Notes

Creates a transfer item.

Parameter Type Description
#1 ResName Resource name that identifies the item type, e.g. "::/gui/line_vehicle_mgmt/dnd_line_stop.res" (a .res.lua file with type = "drag_and_drop").
#2 any Payload; must be serializable (plain tables, numbers, strings).

Returns DataTransferItem: The new item.

Used in the base game: 2 times in 2 files

base/content/gui/gui/line_vehicle_mgmt/line_manager_panel.tl:512

return api.gui.DataTransferItem.new(DnDLineStopRes, data)
base/content/gui/gui/line_vehicle_mgmt/vehicle_store_window.tl:2951
return api.gui.DataTransferItem.new(DnDTrainCompositionRes, data)

Gui.DnD

record api/tealdef/api/gui.d.tl:303

record DnD

Access: api.gui.dnd

Notes

Drag and drop, reached as api.gui.dnd.

Details

React code normally does not call it directly but registers handlers with react.onDragAndDrop{ grab = ..., filter = ..., drop = ... }; the base game's gui/main/react.lua translates the api.gui.dnd events into those callbacks.

Example

react.onDragAndDrop({
  grab = function()
    return { api.gui.DataTransferItem.new(MyDnDRes, { index = i }) }
  end,
  filter = function(typeName, data)
    return typeName == MyDnDRes
  end,
  drop = function(dropCtx)
    for _, item in ipairs(dropCtx:getItems()) do
      print(item.data.index)
    end
    return true
  end,
})

Functions

setCursor(cursor : integer) api/tealdef/api/gui.d.tl:319

Call as api.gui.dnd.setCursor(…)

Set cursor while dragging (will get reset when a new drag starts).

Parameter Type Description
cursor integer the cursor id
Used in the base game: 1 time in 1 file

base/content/gui/gui/main/react.lua:713

api.gui.dnd.setCursor(cursor)

addTransferData(dragStartEvent : Event, item : DataTransferItem) api/tealdef/api/gui.d.tl:324

Call as api.gui.dnd.addTransferData(…)

Add transfer data to the current drag & drop operation.

Parameter Type Description
dragStartEvent Event drag start event (must be Event.Type.DragStarted)
item DataTransferItem transferable item
Used in the base game: 1 time in 1 file

base/content/gui/gui/main/react.lua:707

api.gui.dnd.addTransferData(event, item, item)

getAllTransferData() : {DataTransferItem} api/tealdef/api/gui.d.tl:328

Call as api.gui.dnd.getAllTransferData(…)

Get current drag & drop data.

Returns {DataTransferItem}: current transfer data list

Used in the base game: 2 times in 1 file

base/content/gui/gui/main/react.lua:677

return api.gui.dnd.getAllTransferData()

Gui.DnD.Event

record api/tealdef/api/gui.d.tl:305

record Event

Represents drag & drop event

Fields

Name Type Description
type Type Event type.
Gui.DnD.Event.Type

record api/tealdef/api/gui.d.tl:306

record Type

Notes

Kind of drag and drop event.

Fields

Name Type Description
Drop Type Items were dropped on the component. used 1× in the base game
DragStarted Type A drag starts on the component; add the dragged items with addTransferData. used 1× in the base game
DragEntered Type A drag entered the component. used 1× in the base game
DragExited Type A drag left the component. used 1× in the base game

Gui.InputAction

record api/tealdef/api/gui.d.tl:331

record InputAction

Access: api.gui.inputAction

Notes

Input actions (key bindings such as IA_OPTION2), reached as api.gui.inputAction.

Functions

modifierOnlyActionIsActive(inputActionId : string) : boolean api/tealdef/api/gui.d.tl:358

Call as api.gui.inputAction.modifierOnlyActionIsActive(…)

Checks if a modifier-only action is currently active.

Parameter Type Description
inputActionId string the input action identifier

Returns boolean: True if active.

Used in the base game: 5 times in 2 files

base/content/gui/gui/construction/construction_react_util.tl:1916

local precise = api.gui.inputAction.modifierOnlyActionIsActive("IA_PRECISION_MODE")
base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:537
local startWithPreferWaypoint = api.gui.inputAction.modifierOnlyActionIsActive(commonParams.lvmButtonIAs.modifier3D_PreferWaypoint)

resetModifierOnlyActionStates() api/tealdef/api/gui.d.tl:360

Call as api.gui.inputAction.resetModifierOnlyActionStates(…)

Resets all modifier-only action states to false

Used in the base game: 1 time in 1 file

base/content/gui/gui/construction/construction.tl:4693

api.gui.inputAction.resetModifierOnlyActionStates()

hasConflicts(keyCmdDefinitions : {string : {KeyComboDef}}, inputActionId : string, keyComboDef : KeyComboDef) : string api/tealdef/api/gui.d.tl:366

Call as api.gui.inputAction.hasConflicts(…)

Checks for key binding conflicts.

Parameter Type Description
keyCmdDefinitions {string : {KeyComboDef}} Key command definitions.
inputActionId string Input action id.
keyComboDef KeyComboDef Key combo definition.

Returns string: Conflict description (empty if no conflict).

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/settings_page.tl:213

local warning = api.gui.inputAction.hasConflicts(param.appConfig.keyCmdDefinitions, param.inputActionName, currentCombo)

findDuplicatesOf(inputActionId : string) : {string} api/tealdef/api/gui.d.tl:370

Call as api.gui.inputAction.findDuplicatesOf(…)

Recursively find list of all IAs that should are duplicates of this one (i.e. duplicateOf == inputActionId and duplicatedKeybindings == true)

Parameter Type Description
inputActionId string Input action id.

Returns {string}: Duplications of the IA

Used in the base game: 3 times in 1 file

base/content/gui/gui/menu/settings_page.tl:168

local duplicates : {string} = api.gui.inputAction.findDuplicatesOf(param.inputActionName)

getFixedKeyCmdDefs(keyCmdDefinitions : {string : {KeyComboDef}}, inputActionId : string, keyComboDef : KeyComboDef) : {string : {KeyComboDef}} api/tealdef/api/gui.d.tl:376

Call as api.gui.inputAction.getFixedKeyCmdDefs(…)

Resolves key binding conflicts and returns updated key command definitions.

Parameter Type Description
keyCmdDefinitions {string : {KeyComboDef}} Key command definitions.
inputActionId string Input action id.
keyComboDef KeyComboDef Key combo definition.

Returns {string : {KeyComboDef}}: Fixed key command definitions or empty table if change not allowed.

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/settings_page.tl:227

local keyCmdsFixed = api.gui.inputAction.getFixedKeyCmdDefs(param.appConfig.keyCmdDefinitions, param.inputActionName, currentCombo)

Gui.InputAction.InputActionState

record api/tealdef/api/gui.d.tl:332

record InputActionState

Notes

Enabled state of an input action, returned by the isEnabled callback of react.iaHandler.

Example

react.useInputAction("IA_OPTION2", react.iaHandler(function()
  panelRef:get():focus()
end, function()
  return isListEmpty and api.gui.inputAction.InputActionState.Disabled
    or api.gui.inputAction.InputActionState.Enabled
end))
Used in the base game: 7 times in 5 files

base/content/game_mechanics/game_mechanics/company/company.tl:803

local function navigateToGroupEnabled() : Gui.InputAction.InputActionState
base/content/gui/gui/construction/construction.tl:2417
end, function() : Gui.InputAction.InputActionState
base/content/gui/gui/main/collapsible_checkbox_list.tl:150
end, function() : Gui.InputAction.InputActionState
base/content/gui/gui/main/game.tl:243
end, function() : Gui.InputAction.InputActionState
base/content/gui/gui/main/menu_category_util.tl:79
end, function() : Gui.InputAction.InputActionState

Fields

Name Type Description
Disabled InputActionState disabled, action will not be triggered and no hints or prompts are shown, leaving the keys for other actions used 7× in the base game
Inactive InputActionState action will not be triggered, but hints and button prompts are generated used 1× in the base game
Enabled InputActionState fully enabled, hints and prompts shown (except if disabled/invisible due to hierarchy) used 9× in the base game

Gui.InputAction.InvokeData

record userdata api/tealdef/api/gui.d.tl:339

record InvokeData

Additional info about the invocation of an input action event

Used in the base game: 9 times in 7 files

base/content/game_mechanics/game_mechanics/finance/finances_charts.tl:81

react.useInputAction("IA_OPTION2", react.iaHandlerExtended(function(data : Gui.InputAction.InvokeData)
base/content/gui/gui/entity_window/town/town_eow.script.tl:170
react.useInputAction("IA_OPTION2", react.iaHandlerExtended(function(data : Gui.InputAction.InvokeData)
base/content/gui/gui/line_vehicle_mgmt/line_manager_panel.tl:553
function(data : Gui.InputAction.InvokeData)
base/content/gui/gui/line_vehicle_mgmt/line_util.tl:877
handler : function(Gui.InputAction.InvokeData),
base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:544
function(invokeData : Gui.InputAction.InvokeData)
base/content/gui/gui/line_vehicle_mgmt/vehicle_store_window.tl:1306
react.useInputAction("IA_OPTION2", react.iaHandlerExtended(function(data : Gui.InputAction.InvokeData)
… and 1 more files.

Fields

Name Type Description
status Status status of the action.
Gui.InputAction.InvokeData.Status

record api/tealdef/api/gui.d.tl:343

record Status

Status type of the InputActionInvokeData

Fields

Name Type Description
Triggered Status Start event: when an event key combo first is fully pressed, or when axis values change used 8× in the base game
Repeat Status When the system reports a repeated key press for this action used 3× in the base game
PressedStep Status Invoked every game step, as long as the active is active = pressed used 1× in the base game
EndReleased Status "Good" end event: due to a key/button release there no longer is a action combo active used 8× in the base game
EndAborted Status Component/action became disabled, or another action with higher priority has started used 8× in the base game

Gui.ById

record api/tealdef/api/gui.d.tl:379

record ById

Access: api.gui.byId

Notes

Functions that address GUI components by id or tag, reached as api.gui.byId.

Example

if api.gui.byId.isVisibleRecursive("menu.contexthelper.window") then
  api.gui.byId.resetMovedWindowPosition("menu.contexthelper.window")
end

Functions

setVisibilityByClass(idOrTag : string, visible : boolean, idOnly? : boolean) api/tealdef/api/gui.d.tl:384

Call as api.gui.byId.setVisibilityByClass(…)

Shows or hides a component.

visible: nil removes visibility override

Parameter Type Description
idOrTag string the component identifier or a tag
visible boolean whether visible or not (nil to reset the rule
idOnly? boolean idOnly -> do not consider tags
Used in the base game: 2 times in 1 file

base/content/mission/mission/mission_sim.script.tl:1197

api.gui.byId.setVisibilityByClass(k, nil)

setEnabled(idOrTag : string, enabled : boolean, idOnly? : boolean) api/tealdef/api/gui.d.tl:389

Call as api.gui.byId.setEnabled(…)

Enables or disables a component.

enable: nil re-enables it (and removes the rule)

Parameter Type Description
idOrTag string the component identifier or a tag
enabled boolean whether enabled or not (nil sets to enabled and removes the rule)
idOnly? boolean idOnly -> do not consider tags
Used in the base game: 2 times in 1 file

base/content/mission/mission/mission_sim.script.tl:1166

api.gui.byId.setEnabled(k, nil)

setHighlighted(idOrTag : string, highlighted? : boolean, style? : HighlightStyle, color? : Vec3f, idOnly? : boolean) api/tealdef/api/gui.d.tl:396

Call as api.gui.byId.setHighlighted(…)

Sets the highlighted state of a component.

Parameter Type Description
idOrTag string the component identifier or a tag
highlighted? boolean whether highlighted or not (nil sets to not highlighted and removes the rule)
style? HighlightStyle defaults to HighlightStyle::Circle
color? Vec3f the color of the highlight, defaults to yellow
idOnly? boolean idOnly -> do not consider tags
Used in the base game: 2 times in 1 file

base/content/mission/mission/mission_sim.script.tl:1176

api.gui.byId.setHighlighted(k, nil)

isVisible(id : string) : boolean api/tealdef/api/gui.d.tl:407

Call as api.gui.byId.isVisible(…)

Checks if a UI component is visible by its id.

Parameter Type Description
id string the component identifier

Returns boolean: true if the component is visible

Used in the base game: 6 times in 2 files

base/content/gui/gui/construction/construction.tl:431

if not (params.tabId ~= nil and api.gui.byId.isVisible(params.tabId .. ".tab")) then
base/content/gui/gui/game_bar/game_bar.tl:348
return api.gui.byId.isVisible("menu.mapEditor.nodeEditor.window")

isVisibleRecursive(id : string) : boolean api/tealdef/api/gui.d.tl:411

Call as api.gui.byId.isVisibleRecursive(…)

Checks if a UI component and all its parents are visible by id.

Parameter Type Description
id string the component identifier

Returns boolean: true if the component and all parents are visible

Used in the base game: 6 times in 5 files

base/content/gui/gui/game_bar/game_bar_widgets.tl:139

if not api.gui.byId.isVisibleRecursive("cameraManagerWindow") then
base/content/mission/mission/guide_system/guide_system_react.tl:68
if api.gui.byId.isVisibleRecursive("menu.pause") then
base/content/mission/mission/guide_system/main/guide_system_story.tl:59
return api.gui.byId.isVisibleRecursive("menu.management")
base/content/mission/mission/mission_framework/mission_framework_react.tl:947
if not api.gui.byId.isVisibleRecursive("menu.construction.react") then
base/content/mission/mission/tasks/guide/guide_collect_entity.tl:43
if ctx.state.decoratorState.lock == false and (api.gui.voiceOverManager.isPlayingAny() or api.gui.byId.isVisibleRecursive( "guide.window")) then

setVisible(id : string, visible : boolean) api/tealdef/api/gui.d.tl:415

Call as api.gui.byId.setVisible(…)

Sets the visibility of a UI component by its ID.

Parameter Type Description
id string the component identifier
visible boolean if the component should be visible
Used in the base game: 26 times in 8 files

base/content/gui/gui/construction/construction.tl:1700

api.gui.byId.setVisible(constructionParamsWindowId, shouldBeVisible)
base/content/gui/gui/entity_window/view_manager.tl:335
api.gui.byId.setVisible(makeWindowId(param.keyEntity, param.keyNonEntity), true)
base/content/gui/gui/game_bar/game_bar.tl:616
api.gui.byId.setVisible("menu.construction.react", true)
base/content/gui/gui/game_bar/game_bar_widgets.tl:116
api.gui.byId.setVisible("cameraManagerWindow", show)
base/content/gui/gui/layers/layers_button_ridge.tl:126
api.gui.byId.setVisible(layerWindowId, true)
base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:8309
api.gui.byId.setVisible(managerToolWindowId, true)
… and 2 more files.

resetMovedWindowPosition(id : string) api/tealdef/api/gui.d.tl:419

Call as api.gui.byId.resetMovedWindowPosition(…)

Resets a window to its original position if it was moved by the user.

Parameter Type Description
id string string id the window identifier
Used in the base game: 1 time in 1 file

base/content/gui/gui/context_helper/context_helper_react.tl:831

api.gui.byId.resetMovedWindowPosition("menu.contexthelper.window")

getSize(id : string) : Vec2f api/tealdef/api/gui.d.tl:423

Call as api.gui.byId.getSize(…)

Get width and height of UI component

Parameter Type Description
id string string id the window identifier

Returns Vec2f: width and height

Used in the base game: 2 times in 1 file

base/content/mission/mission/mission_framework/mission_framework_react.tl:954

local constructionMenuSize = api.gui.byId.getSize("menu.construction.react").y

Gui.Camera

record api/tealdef/api/gui.d.tl:426

record Camera

Access: api.gui.camera

Notes

Camera control, reached as api.gui.camera.

Example

api.gui.camera.focusEntity(vehicle)        -- jump the view to an entity
api.gui.camera.followEntity(vehicle, false) -- follow it, sliding there
local c = api.gui.camera.getCameraData()   -- {x, y, distance, angle, pitch}

Functions

setManualCamera(center : Vec2f, distance : number) api/tealdef/api/gui.d.tl:430

Call as api.gui.camera.setManualCamera(…)

Sets camera to a given position/orientation.

Parameter Type Description
center Vec2f position on the map where the camera should point to
distance number the distance from the position
Used in the base game: 1 time in 1 file

base/content/mission/mission/mission_framework/mission_framework_react_util.tl:228

api.gui.camera.setManualCamera(api.type.Vec2f.new(location.pos[1], location.pos[2]), location.radius)

getCameraData() : Vec5f api/tealdef/api/gui.d.tl:434

Call as api.gui.camera.getCameraData(…)

Obtains the current camera data.

Returns Vec5f: the current camera data as a Vec5f {center.x, center.y, distance, angle, pitch}

Used in the base game: 9 times in 9 files

base/content/mission/mission/tutorial/tasks/camera_movement.tl:120

local cameraData = api.gui.camera.getCameraData()
mods/release/urbangames_campaign_mission_01/content/mission/mission/tasks/everything/everything.tl:8
local cameraData = api.gui.camera.getCameraData()
mods/release/urbangames_campaign_mission_02/content/mission/mission/tasks/everything/everything.tl:9
local cameraData = api.gui.camera.getCameraData()
mods/release/urbangames_campaign_mission_03/content/mission/mission/tasks/everything/everything.tl:10
local cameraData = api.gui.camera.getCameraData()
mods/release/urbangames_campaign_mission_04/content/mission/mission/tasks/everything/everything.tl:16
local cameraData = api.gui.camera.getCameraData()
mods/release/urbangames_campaign_mission_05/content/mission/mission/tasks/everything/everything.tl:9
local cameraData = api.gui.camera.getCameraData()
… and 3 more files.

setCameraData(Vec5f) api/tealdef/api/gui.d.tl:438

Call as api.gui.camera.setCameraData(…)

Set the camera data.

Parameter Type Description
#1 (Vec5f) Vec5f set the camera data as a Vec5f
Used in the base game: 4 times in 4 files

mods/release/urbangames_campaign_mission_01/content/mission/mission/tasks/everything/everything.tl:85

api.gui.camera.setCameraData(camera)
mods/release/urbangames_campaign_mission_02/content/mission/mission/tasks/everything/everything.tl:77
api.gui.camera.setCameraData(camera)
mods/release/urbangames_campaign_mission_03/content/mission/mission/tasks/everything/everything.tl:75
api.gui.camera.setCameraData(camera)
mods/release/urbangames_campaign_mission_05/content/mission/mission/tasks/everything/everything.tl:75
api.gui.camera.setCameraData(camera)

getHeightAboveTerrain() : number api/tealdef/api/gui.d.tl:442

Call as api.gui.camera.getHeightAboveTerrain(…)

Obtains the current height above terrain.

Returns number: the height of the camera above the terrain

Used in the base game: 1 time in 1 file

base/content/gui/gui/line_vehicle_mgmt/line_util.tl:1120

return api.gui.camera.getHeightAboveTerrain() > 500 and gameCtx.metroMode:old()

focusEntity(entity : Engine.Entity) api/tealdef/api/gui.d.tl:446

Call as api.gui.camera.focusEntity(…)

Focuses the camera on an entity.

Parameter Type Description
entity Engine.Entity the id of the entity that should be focused on
Used in the base game: 14 times in 13 files

base/content/game_mechanics/game_mechanics/celebrations/celebration_react_util.tl:116

api.gui.camera.focusEntity(param.entity.entity)
base/content/game_mechanics/game_mechanics/notifications/notification_util.tl:450
api.gui.camera.focusEntity(focusEntity)
base/content/game_mechanics/game_mechanics/notifications/types/line_station_warning.script.tl:144
api.gui.camera.focusEntity(notificationParams.entities[1].entity)
base/content/game_mechanics/game_mechanics/notifications/types/line_warning.script.tl:196
api.gui.camera.focusEntity(notificationParams.entities[1].entity)
base/content/game_mechanics/game_mechanics/notifications/types/subvention.script.tl:70
api.gui.camera.focusEntity(state:old().focusEntity)
base/content/game_mechanics/game_mechanics/notifications/types/subvention_notification.script.tl:93
api.gui.camera.focusEntity(state:old().focusEntity)
… and 7 more files.

focusPosition(position : Vec3f, distance : number) api/tealdef/api/gui.d.tl:451

Call as api.gui.camera.focusPosition(…)

Focuses the camera on a position.

Parameter Type Description
position Vec3f the position that should be focused
distance number the distance of the camera from the target
Used in the base game: 5 times in 3 files

base/content/game_mechanics/game_mechanics/notifications/types/line_warning.script.tl:194

api.gui.camera.focusPosition(api.type.Vec3f.new(locationOverride[1], locationOverride[2], locationOverride[3]), 15)
base/content/gui/gui/line_vehicle_mgmt/line_manager_panel.tl:1113
api.gui.camera.focusPosition(via.waypoint.pos, 15)
base/content/gui/gui/line_vehicle_mgmt/line_react_util.tl:224
api.gui.camera.focusPosition(param.position, 15)

takeScreenshot(scale : integer) api/tealdef/api/gui.d.tl:455

Call as api.gui.camera.takeScreenshot(…)

Takes a screenshot and stores it in userdata folder

Parameter Type Description
scale integer image resolution
Used in the base game: 1 time in 1 file

base/content/gui/gui/main/free_cam_options.tl:21

api.gui.camera.takeScreenshot(1)

getFollowEntity() : {Engine.Entity, Engine.Revision} api/tealdef/api/gui.d.tl:459

Call as api.gui.camera.getFollowEntity(…)

Gets the entity currently being followed.

Returns {Engine.Entity, Engine.Revision}: the entity being followed (and the entity revision)

followEntity(entity : Engine.Entity, jump : boolean) api/tealdef/api/gui.d.tl:464

Call as api.gui.camera.followEntity(…)

Sets camera to follow an Entity.

Parameter Type Description
entity Engine.Entity the id of the entity that should be followed
jump boolean true if the camera should directly jump to the entity and not slide there
Used in the base game: 13 times in 4 files

base/content/gui/gui/entity_window/view_manager.tl:269

api.gui.camera.followEntity(params.keyEntity, true)
base/content/gui/gui/line_vehicle_mgmt/line_react_util.tl:222
api.gui.camera.followEntity(param.entity, true)
base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:1402
api.gui.camera.followEntity(entity, true)
base/content/gui/gui/line_vehicle_mgmt/vehicle_list_react_util.tl:115
api.gui.camera.followEntity(entity, true)

enterFollowCameraCockpit(entity : Engine.Entity) api/tealdef/api/gui.d.tl:468

Call as api.gui.camera.enterFollowCameraCockpit(…)

Enters the cockpit of an entity.

Parameter Type Description
entity Engine.Entity entity of the object to enter
Used in the base game: 1 time in 1 file

base/content/gui/gui/main/free_cam_options.tl:40

api.gui.camera.enterFollowCameraCockpit(toolParam.cockpitCameraForEntity)

leaveFollowCameraCockpit() api/tealdef/api/gui.d.tl:471

Call as api.gui.camera.leaveFollowCameraCockpit(…)

Leave the cockpit of an entity.

Used in the base game: 1 time in 1 file

base/content/gui/gui/main/free_cam_options.tl:46

api.gui.camera.leaveFollowCameraCockpit()

isFreeCameraMouseAttached() : boolean api/tealdef/api/gui.d.tl:475

Call as api.gui.camera.isFreeCameraMouseAttached(…)

Tells if mouse is attached to free cam or not

Returns boolean: if mouse is attached (true) or not (false)

toggleFreeCameraMouseAttachment() api/tealdef/api/gui.d.tl:478

Call as api.gui.camera.toggleFreeCameraMouseAttachment(…)

Toggles mouse attachment

toggleFreeCamera() api/tealdef/api/gui.d.tl:481

Call as api.gui.camera.toggleFreeCamera(…)

Toggles free camera

Used in the base game: 1 time in 1 file

base/content/gui/gui/main/free_cam_options.tl:42

api.gui.camera.toggleFreeCamera()

world2Screen(Vec3f) : Vec2i api/tealdef/api/gui.d.tl:484

Call as api.gui.camera.world2Screen(…)

Convert a 3D World position into a position on screen (in pixels)

Returns Vec2i

screen2World(Vec3f) : Vec3f api/tealdef/api/gui.d.tl:487

Call as api.gui.camera.screen2World(…)

Convert a position on the screen (in pixels) (with depth [0, 1]) into a 3D World position

Returns Vec3f

getEye() : Vec3f api/tealdef/api/gui.d.tl:490

Call as api.gui.camera.getEye(…)

Get camera origin in world coordinates

Returns Vec3f

getCenter() : Vec3f api/tealdef/api/gui.d.tl:493

Call as api.gui.camera.getCenter(…)

Get camera center ("look-at" pos) in world coordinates

Returns Vec3f

getNearFar() : Vec2f api/tealdef/api/gui.d.tl:496

Call as api.gui.camera.getNearFar(…)

Get near and far distances of camera in x and y coordinates repsectively

Returns Vec2f

getSize() : Vec2i api/tealdef/api/gui.d.tl:499

Call as api.gui.camera.getSize(…)

Width and height of the viewport, in pixels

Returns Vec2i

traceToTerrain(worldPos : Vec3f, farPos : Vec3f, zOffset : number, numSteps : integer) : Vec3f | nil api/tealdef/api/gui.d.tl:506

Call as api.gui.camera.traceToTerrain(…)

Trace a ray from worldPos to farPos, and find the intersection (if any) with the terrain, offsetted at zOffset

Parameter Type Description
worldPos Vec3f world position of starting point of ray
farPos Vec3f world position of end point of ray
zOffset number offset to shift the terrain for intersection
numSteps integer number of steps to perform for finding an intersection. more steps are more precise but cost more, 30 is a good compromise

Returns Vec3f | nil

Gui.Sound

record api/tealdef/api/gui.d.tl:509

record Sound

Access: api.gui.sound

Notes

Sound effects, reached as api.gui.sound.

Example

api.gui.sound.playRandomSoundEffect({ "::/path/to/effect.wav" })

Functions

letVehicleHorn(vehicleEntity : Engine.Entity) api/tealdef/api/gui.d.tl:512

Call as api.gui.sound.letVehicleHorn(…)

Sounds the vehicle horn.

Parameter Type Description
vehicleEntity Engine.Entity the vehicle to sound the horn
Used in the base game: 2 times in 2 files

base/content/gui/gui/entity_window/sim_person/sim_person.tl:168

api.gui.sound.letVehicleHorn(personEntityId)
base/content/gui/gui/entity_window/vehicle/vehicle.tl:551
api.gui.sound.letVehicleHorn(vehicleEntityId)

playRandomSoundEffect(paths : {FilePath}) api/tealdef/api/gui.d.tl:516

Call as api.gui.sound.playRandomSoundEffect(…)

Plays a single sound effect randomly selected of the provided selection.

Parameter Type Description
paths {FilePath} vector of strings paths of sound effects
Used in the base game: 42 times in 15 files

base/content/game_mechanics/game_mechanics/celebrations/celebration_react_util.tl:213

api.gui.sound.playRandomSoundEffect(celebrationSFX.Earned)
base/content/game_mechanics/game_mechanics/company/company.tl:71
api.gui.sound.playRandomSoundEffect(companySFX.LevelUp)
base/content/game_mechanics/game_mechanics/company/explorations/exploration_plane.script.tl:296
api.gui.sound.playRandomSoundEffect(townSFX.Prospection)
base/content/game_mechanics/game_mechanics/notifications/gui/notification_popups.tl:102
api.gui.sound.playRandomSoundEffect(dataState.soundOnMount)
base/content/gui/gui/entity_window/view_manager.tl:251
api.gui.sound.playRandomSoundEffect(params.soundEffect)
base/content/gui/gui/hud/greenification_display.script.tl:137
api.gui.sound.playRandomSoundEffect(townSFX.Greenification)
… and 9 more files.

Gui.MusicPlayer

record api/tealdef/api/gui.d.tl:519

record MusicPlayer

Access: api.gui.musicPlayer

Notes

Music playback, reached as api.gui.musicPlayer.

Functions

goBack() api/tealdef/api/gui.d.tl:521

Call as api.gui.musicPlayer.goBack(…)

Goes back to the previous track in the music player.

Used in the base game: 1 time in 1 file

base/content/gui/gui/music_player/music_player.tl:186

onClick = function() api.gui.musicPlayer.goBack() end,

goForward() api/tealdef/api/gui.d.tl:524

Call as api.gui.musicPlayer.goForward(…)

Goes forward to the next track in the music player.

Used in the base game: 3 times in 2 files

base/content/gui/gui/music_player/music_player.tl:196

onClick = function() api.gui.musicPlayer.goForward() end,
base/content/mission/mission/mission_sim.script.tl:1207
api.gui.musicPlayer.goForward()

togglePause() api/tealdef/api/gui.d.tl:527

Call as api.gui.musicPlayer.togglePause(…)

Toggles pause/play state of the music player.

Used in the base game: 1 time in 1 file

base/content/gui/gui/music_player/music_player.tl:191

onClick = function() api.gui.musicPlayer.togglePause() end

getTitle() : string api/tealdef/api/gui.d.tl:531

Call as api.gui.musicPlayer.getTitle(…)

Gets the title of the currently playing track.

Returns string: the track title

Used in the base game: 1 time in 1 file

base/content/gui/gui/music_player/music_player.tl:40

title = api.gui.musicPlayer.getTitle(),

getArtist() : string api/tealdef/api/gui.d.tl:535

Call as api.gui.musicPlayer.getArtist(…)

Gets the artist of the currently playing track.

Returns string: the track artist

Used in the base game: 1 time in 1 file

base/content/gui/gui/music_player/music_player.tl:39

artist = api.gui.musicPlayer.getArtist(),

hasPlaylist() : boolean api/tealdef/api/gui.d.tl:539

Call as api.gui.musicPlayer.hasPlaylist(…)

Checks if the music player has tracks loaded.

Returns boolean: true if the music player has tracks

Used in the base game: 2 times in 2 files

base/content/gui/gui/menu/main_menu.tl:936

if recipe ~= LicensePage and not api.gui.musicPlayer.hasPlaylist() and api.util.getAppConfig().menuMusicEnabled then
base/content/gui/gui/music_player/music_player.tl:43
hasPlaylist = api.gui.musicPlayer.hasPlaylist(),

getPlaylistIndex() : integer api/tealdef/api/gui.d.tl:543

Call as api.gui.musicPlayer.getPlaylistIndex(…)

Gets the current track index (1-based).

Returns integer: the current track index

Used in the base game: 1 time in 1 file

base/content/gui/gui/music_player/music_player.tl:44

playlistIndex = api.gui.musicPlayer.getPlaylistIndex(),

setTrackListFromPlayList(playlist : string, startPaused : boolean, offset? : number) api/tealdef/api/gui.d.tl:550

Call as api.gui.musicPlayer.setTrackListFromPlayList(…)

Sets the current playlist. The current track will only start after the current track ends. To trigger the new playlist immediately, call goForward() right after this call.

Parameter Type Description
playlist string the playlist resource name
startPaused boolean if set, does not play the playlist, just prepares it
offset? number playback offset in seconds (optional)
Used in the base game: 2 times in 1 file

base/content/gui/gui/menu/main_menu.tl:914

api.gui.musicPlayer.setTrackListFromPlayList("::/music/menu.plist", not api.util.getAppConfig().menuMusicEnabled)

setPlaylist(playlist : string) api/tealdef/api/gui.d.tl:555

Call as api.gui.musicPlayer.setPlaylist(…)

Sets the current playlist. Only available while in-game. The current track will only start after the current track ends. To trigger the new playlist immediately, call goForward() right after this call.

Parameter Type Description
playlist string the playlist resource name
Used in the base game: 2 times in 2 files

base/content/gui/gui/music_player/music_player.tl:209

api.gui.musicPlayer.setPlaylist(newValue)
base/content/mission/mission/mission_sim.script.tl:1206
api.gui.musicPlayer.setPlaylist(newPlaylist)

getPlaylist() : string api/tealdef/api/gui.d.tl:559

Call as api.gui.musicPlayer.getPlaylist(…)

Gets the current playlist. Only available while in-game.

Returns string: the resource name of the current playlist

Used in the base game: 1 time in 1 file

base/content/gui/gui/music_player/music_player.tl:42

playlist = api.gui.musicPlayer.getPlaylist(),

isPlaying() : boolean api/tealdef/api/gui.d.tl:563

Call as api.gui.musicPlayer.isPlaying(…)

Checks if the music player is currently playing.

Returns boolean: true if music is playing

Used in the base game: 2 times in 1 file

base/content/gui/gui/music_player/music_player.tl:41

isPlaying = api.gui.musicPlayer.isPlaying(),

playTrack(trackName : string, offset? : number) api/tealdef/api/gui.d.tl:568

Call as api.gui.musicPlayer.playTrack(…)

Plays a track by name.

Parameter Type Description
trackName string the name of the track to play
offset? number playback offset in seconds (optional)
Used in the base game: 1 time in 1 file

base/content/mission/mission/mission_sim.script.tl:1212

api.gui.musicPlayer.playTrack(newSoundtrack)

playTrackFile(filePath : string, offset? : number) api/tealdef/api/gui.d.tl:573

Call as api.gui.musicPlayer.playTrackFile(…)

Plays a specific file that might not be part of the current track list

Parameter Type Description
filePath string the path to the track file
offset? number playback offset in seconds (optional)
Used in the base game: 1 time in 1 file

base/content/mission/mission/mission_react_util.tl:314

api.gui.musicPlayer.playTrackFile(data.music)

getTrackLength() : number api/tealdef/api/gui.d.tl:577

Call as api.gui.musicPlayer.getTrackLength(…)

Gets the length (duration) of the current track

Returns number: the track duration in second

Used in the base game: 1 time in 1 file

base/content/gui/gui/music_player/music_player.tl:45

trackLength = math.floor(api.gui.musicPlayer.getTrackLength()),

getTrackElapsedTime() : number api/tealdef/api/gui.d.tl:581

Call as api.gui.musicPlayer.getTrackElapsedTime(…)

Gets the time of the current track

Returns number: the current time of the current track

Used in the base game: 1 time in 1 file

base/content/gui/gui/music_player/music_player.tl:46

trackTime = math.floor(api.gui.musicPlayer.getTrackElapsedTime()),

getGain() : number api/tealdef/api/gui.d.tl:585

Call as api.gui.musicPlayer.getGain(…)

Gets the current gain (volume) of the music player.

Returns number: the gain value

setGain(gain : number) api/tealdef/api/gui.d.tl:589

Call as api.gui.musicPlayer.setGain(…)

Sets the gain (volume) of the music player.

Parameter Type Description
gain number the gain value

setTrackList(trackList : {{string, string, boolean}}, enableRepeat : boolean) api/tealdef/api/gui.d.tl:594

Call as api.gui.musicPlayer.setTrackList(…)

Sets the track list for the music player, replaces the current track list.

Parameter Type Description
trackList {{string, string, boolean}} array of tuples containing track name, file path, and repeat flag
enableRepeat boolean true to enable repeat for the entire list
Used in the base game: 3 times in 3 files

base/content/gui/gui/menu/mission_page_content.tl:436

api.gui.musicPlayer.setTrackList(trackList, true);
base/content/mission/mission/mission_framework/mission_end_window_util.tl:357
api.gui.musicPlayer.setTrackList(trackList, true);
base/content/mission/mission/mission_sim.script.tl:1231
api.gui.musicPlayer.setTrackList(trackList, enableRepeat)

addTrackList(trackList : {{string, string, boolean}}, enableRepeat : boolean) api/tealdef/api/gui.d.tl:600

Call as api.gui.musicPlayer.addTrackList(…)

Adds a track list to the music player. This doesn't replace the existing tracks and once the added tracks are finish, the track previously playing will resume

Parameter Type Description
trackList {{string, string, boolean}} array of tuples containing track name, file path, and repeat flag
enableRepeat boolean true to enable repeat for the entire list
Used in the base game: 1 time in 1 file

base/content/mission/mission/mission_sim.script.tl:1233

api.gui.musicPlayer.addTrackList(trackList, enableRepeat)

setContextTag(contextTag : string) api/tealdef/api/gui.d.tl:605

Call as api.gui.musicPlayer.setContextTag(…)

Sets the context tag for the music player. The context tag can be used to change the variant of a playing track.

Parameter Type Description
contextTag string the context tag to set
Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/main_menu.tl:946

api.gui.musicPlayer.setContextTag(state:old())

Gui.VoiceOverManager

record api/tealdef/api/gui.d.tl:608

record VoiceOverManager

Access: api.gui.voiceOverManager

Notes

Voice-over playback, reached as api.gui.voiceOverManager.

Functions

stop() api/tealdef/api/gui.d.tl:610

Call as api.gui.voiceOverManager.stop(…)

Stops the current voice over playing

Used in the base game: 4 times in 1 file

base/content/mission/mission/mission_react_util.tl:462

api.gui.voiceOverManager.stop()

play(voiceOverRes : string, delayInSeconds? : number) api/tealdef/api/gui.d.tl:615

Call as api.gui.voiceOverManager.play(…)

Plays a new voice over

Parameter Type Description
voiceOverRes string the file path to the voice over to play
delayInSeconds? number delay before the voice over starts
Used in the base game: 2 times in 1 file

base/content/mission/mission/mission_react_util.tl:83

api.gui.voiceOverManager.play(param.instructionData.voiceOver)

isPlaying(voiceOverRes : string) : boolean api/tealdef/api/gui.d.tl:620

Call as api.gui.voiceOverManager.isPlaying(…)

Checks whether a specific voice over is playing

Parameter Type Description
voiceOverRes string the voice over file to check

Returns boolean: true if the voice over file is playing

isPlayingAny() : boolean api/tealdef/api/gui.d.tl:624

Call as api.gui.voiceOverManager.isPlayingAny(…)

Checks whether any voice over is current playing

Returns boolean: true if any voice over is playing

Used in the base game: 6 times in 2 files

base/content/mission/mission/mission_react_util.tl:461

if api.gui.voiceOverManager.isPlayingAny() then
base/content/mission/mission/tasks/guide/guide_collect_entity.tl:43
if ctx.state.decoratorState.lock == false and (api.gui.voiceOverManager.isPlayingAny() or api.gui.byId.isVisibleRecursive( "guide.window")) then

getPlaying() : ResName api/tealdef/api/gui.d.tl:628

Call as api.gui.voiceOverManager.getPlaying(…)

Checks whether any voice over is current playing and returns the file path if one is playing

Returns ResName: file path if any voice over is playing

Gui.ByEntity

record api/tealdef/api/gui.d.tl:631

record ByEntity

Access: api.gui.byEntity

Notes

Visibility checks for game entities, reached as api.gui.byEntity.

Functions

isLineEmptyOrVisible(Engine.Entity) : boolean api/tealdef/api/gui.d.tl:635

Call as api.gui.byEntity.isLineEmptyOrVisible(…)

Checks if line is empty or visible

Parameter Type Description
#1 (Engine.Entity) Engine.Entity the line entity to check

Returns boolean: true if the line is empty or visible

Used in the base game: 6 times in 2 files

base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:155

if not onlyVisible or api.gui.byEntity.isLineEmptyOrVisible(lineEntity) then
base/content/gui/gui/statistics/statistic_lines.tl:313
if params.filterShowOnlyVisible and not api.gui.byEntity.isLineEmptyOrVisible(key) then

isVisible(Engine.Entity) : boolean api/tealdef/api/gui.d.tl:640

Call as api.gui.byEntity.isVisible(…)

Checks if an entity is visible

Parameter Type Description
#1 (Engine.Entity) Engine.Entity the entity to check

Returns boolean: true if the entity is visible

Used in the base game: 10 times in 6 files

base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:1677

if not onlyVisible or api.gui.byEntity.isVisible(depotEAR.entity) then
base/content/gui/gui/statistics/statistic_depots.tl:234
if params.filterShowOnlyVisible and not api.gui.byEntity.isVisible(key) then
base/content/gui/gui/statistics/statistic_industries.tl:446
if params.filterShowOnlyVisible and not api.gui.byEntity.isVisible(key) then
base/content/gui/gui/statistics/statistic_stations.tl:338
if params.filterShowOnlyVisible and not api.gui.byEntity.isVisible(key) then
base/content/gui/gui/statistics/statistic_towns.tl:544
if params.filterShowOnlyVisible and not api.gui.byEntity.isVisible(key) then
base/content/gui/gui/statistics/statistic_warehouses.tl:367
if params.filterShowOnlyVisible and not api.gui.byEntity.isVisible(key) then

isVehicleVisible(Engine.Entity) : boolean api/tealdef/api/gui.d.tl:645

Call as api.gui.byEntity.isVehicleVisible(…)

Checks if vehicle is visible

Parameter Type Description
#1 (Engine.Entity) Engine.Entity the vehicle entity to check

Returns boolean: true if the vehicle is visible

Used in the base game: 1 time in 1 file

base/content/gui/gui/statistics/statistic_vehicles.tl:419

if params.filterShowOnlyVisible and not api.gui.byEntity.isVehicleVisible(key) then

Gui.ContextHelper

record api/tealdef/api/gui.d.tl:648

record ContextHelper

Access: api.gui.contextHelper

Notes

Data for the context help window, reached as api.gui.contextHelper.

Functions

collectSubjectStates(idsOfInterest : {string}) : {string : SubjectState} api/tealdef/api/gui.d.tl:656

Call as api.gui.contextHelper.collectSubjectStates(…)

Collects subject states for given ids

Parameter Type Description
idsOfInterest {string} ids to collect states for

Returns {string : SubjectState}

Used in the base game: 1 time in 1 file

base/content/gui/gui/context_helper/context_helper_react.tl:822

local vis = api.gui.contextHelper.collectSubjectStates(interestingIds)

getIdsOfActiveTool() : {string} api/tealdef/api/gui.d.tl:657

Call as api.gui.contextHelper.getIdsOfActiveTool(…)

Notes

Ids of the currently active tools in the main view; the context helper uses them to pick the help page for the active tool.

Returns {string}: List of tool ids (empty when no tool is active).

Used in the base game: 2 times in 1 file

base/content/gui/gui/context_helper/context_helper_react.tl:782

local tools = api.gui.contextHelper.getIdsOfActiveTool()

Gui.ContextHelper.SubjectState

record api/tealdef/api/gui.d.tl:649

record SubjectState

Notes

State of a GUI component reported by collectSubjectStates.

Used in the base game: 1 time in 1 file

base/content/gui/gui/context_helper/context_helper_react.tl:815

local visibilities = react.useRef({}) as ReactRefT<{string : Gui.ContextHelper.SubjectState}>

Fields

Name Type Description
Visible SubjectState The component is visible. used 2× in the base game
Focused SubjectState The component is visible and has the focus. used 1× in the base game

Gui.Construction

record api/tealdef/api/gui.d.tl:660

record Construction

Access: api.gui.construction

Notes

Construction-tool helpers, reached as api.gui.construction.

Functions

setAngle(angle : number) api/tealdef/api/gui.d.tl:663

Call as api.gui.construction.setAngle(…)

Sets the default construction angle for constructions.

Parameter Type Description
angle number the default construction angle
Used in the base game: 1 time in 1 file

base/content/mission/mission/tasks/build_construction/build_construction.tl:51

api.gui.construction.setAngle(angle2a + math.pi)

modify(construction : Engine.Entity) api/tealdef/api/gui.d.tl:667

Call as api.gui.construction.modify(…)

Modifies a construction

Parameter Type Description
construction Engine.Entity the construction entity

getBrushIcons() : {string} api/tealdef/api/gui.d.tl:671

Call as api.gui.construction.getBrushIcons(…)

Returns brush icons for construction menu

Returns {string}: paths to brush icons for the construction menu

Used in the base game: 2 times in 1 file

base/content/gui/gui/construction/construction_react_util.tl:3124

values = api.gui.construction.getBrushIcons(),

provideDustWheneverPossible(proposal : Proposal, proposalData : ProposalData) api/tealdef/api/gui.d.tl:676

Call as api.gui.construction.provideDustWheneverPossible(…)

Provides dust effects for proposal

Parameter Type Description
proposal Proposal the proposal
proposalData ProposalData the proposal data
Used in the base game: 1 time in 1 file

base/content/gui/gui/entity_window/double_slip_switch.tl:652

api.gui.construction.provideDustWheneverPossible(cmdData.proposal, cmdData.resultProposalData)

getRefundableEntities() : {{Engine.Entity, integer}, {Engine.Revision, integer}} api/tealdef/api/gui.d.tl:678

Call as api.gui.construction.getRefundableEntities(…)

Notes

Entities whose cost would currently be refunded when they are replaced; pass the result as refundableEntities of the command context.

Returns {{Engine.Entity, integer}, {Engine.Revision, integer}}: Refundable entities with their revisions, or nil.

Example

-- gui/entity_window/bridge_and_tunnel.tl
local context = api.type.Context.new()
context.player = api.engine.util.getPlayer()
local refundables = api.gui.construction.getRefundableEntities()
if refundables ~= nil then
  context.refundableEntities = refundables
end
local cmd = api.cmd.makeWorldBuildProposalCmd(proposal, context, false, true)
api.cmd.sendCommand(cmd, function(res, success)
  if success then
    api.gui.construction.updateRefundableEntities(resultEntities, res.proposal.proposal)
  end
end)
Used in the base game: 1 time in 1 file

base/content/gui/gui/entity_window/bridge_and_tunnel.tl:189

local refundables = api.gui.construction.getRefundableEntities()

updateRefundableEntities(resultEntities : {Engine.Entity}, proposal : Proposal.StreetProposal) api/tealdef/api/gui.d.tl:682

Call as api.gui.construction.updateRefundableEntities(…)

Updates refundable entities

Parameter Type Description
resultEntities {Engine.Entity} result entities
proposal Proposal.StreetProposal the street proposal
Used in the base game: 1 time in 1 file

base/content/gui/gui/entity_window/bridge_and_tunnel.tl:203

api.gui.construction.updateRefundableEntities(validResultEntities, cmdData.proposal.proposal)

Gui.Mission

record api/tealdef/api/gui.d.tl:685

record Mission

Access: api.gui.mission

Notes

Mission and campaign helpers (zones, markers, cutscenes), reached as api.gui.mission.

Functions

getMission() : string api/tealdef/api/gui.d.tl:688

Call as api.gui.mission.getMission(…)

Get the current mission

Returns string: the mission name

Used in the base game: 7 times in 3 files

base/content/mission/mission/mission_framework/mission_end_window_util.tl:9

local missionName = api.gui.mission.getMission()
base/content/mission/mission/mission_framework/mission_framework_react.tl:539
local missionDesc = app.res.missionRep.get(app.res.missionRep.find(api.gui.mission.getMission()))
base/content/mission/mission/mission_react_util.tl:168
local missionName = api.gui.mission.getMission()

getCampaign() : string api/tealdef/api/gui.d.tl:692

Call as api.gui.mission.getCampaign(…)

Get the current campaign

Returns string: the campaign name

Used in the base game: 4 times in 2 files

base/content/mission/mission/mission_framework/mission_end_window_util.tl:272

local campaign = api.gui.mission.getCampaign()
base/content/mission/mission/mission_framework/mission_framework_react.tl:544
local achievedMedals = app.getUserProfile():getMedalsState(api.gui.mission.getCampaign(), api.gui.mission.getMission())

setZone(key : string, polygon : {Vec2f}, draw : boolean, drawColor : Vec4f, prohibitBuilding : boolean, playAnimation? : boolean, zOffset? : number) api/tealdef/api/gui.d.tl:702

Call as api.gui.mission.setZone(…)

Adds a zone

Parameter Type Description
key string the key (name) of the zone
polygon {Vec2f} the shape of the zone as a list of 2d position
draw boolean if the zone should be drawn
drawColor Vec4f the color of the zone
prohibitBuilding boolean if prevented or not to build inside the zone
playAnimation? boolean if player zone animation (optional), default to true
zOffset? number (optional), default to terrain level
Used in the base game: 2 times in 2 files

base/content/mission/mission/legacy_ui_util.tl:13

api.gui.mission.setZone(key, poly2f, legacyZone.draw, color4f, prohibitBuilding)
base/content/mission/mission/mission_sim.script.tl:1109
api.gui.mission.setZone(zone.key, zone.polygon, zone.draw, color, zone.prohibitBuilding, zone.playAnimation, zone.zOffset)

setZoneCircle(key : string, center : Vec2f, radius : number, draw : boolean, drawColor : Vec4f, prohibitBuilding : boolean, playAnimation? : boolean, zOffset? : number) api/tealdef/api/gui.d.tl:713

Call as api.gui.mission.setZoneCircle(…)

Adds a zone as a cylinder

Parameter Type Description
key string the key (name) of the zone
center Vec2f the center of the zone
radius number the radius of the zone
draw boolean if the zone should be drawn
drawColor Vec4f the color of the zone
prohibitBuilding boolean if prevented or not to build inside the zone
playAnimation? boolean if player zone animation (optional), default to true
zOffset? number (optional), default to terrain level
Used in the base game: 1 time in 1 file

base/content/mission/mission/mission_sim.script.tl:1111

api.gui.mission.setZoneCircle(zone.key, api.type.Vec2f.new(zone.circle.pos[1], zone.circle.pos[2]),

removeZone(key : string) api/tealdef/api/gui.d.tl:717

Call as api.gui.mission.removeZone(…)

Removes a zone

Parameter Type Description
key string the key of the zone
Used in the base game: 2 times in 2 files

base/content/mission/mission/legacy_ui_util.tl:5

api.gui.mission.removeZone(key)
base/content/mission/mission/mission_sim.script.tl:1160
api.gui.mission.removeZone(k)

setMarkerAtPosition(key : string, pos : Vec3f, type : string, scaling : number, isSelectable? : boolean, fireSelectEntity? : boolean) api/tealdef/api/gui.d.tl:726

Call as api.gui.mission.setMarkerAtPosition(…)

Sets marker at the given position

Parameter Type Description
key string the key of the marker
pos Vec3f the position of the marker
type string type of marker (optional)
scaling number scaling of marker (optional)
isSelectable? boolean whether marker is selectable
fireSelectEntity? boolean whether selecting the marker also selects the underlying entity (default is true)
Used in the base game: 2 times in 2 files

base/content/mission/mission/legacy_ui_util.tl:24

api.gui.mission.setMarkerAtPosition(key, pos, legacyMarker.marker.type)
base/content/mission/mission/mission_sim.script.tl:1096
api.gui.mission.setMarkerAtPosition(marker.key, api.type.Vec3f.new(marker.position[1], marker.position[2], marker.position[3]), marker.type, marker.scaling, mar

setMarkerAtEntity(key : string, entity : Engine.Entity, type : string, scaling : number, isSelectable? : boolean, fireSelectEntity? : boolean) api/tealdef/api/gui.d.tl:735

Call as api.gui.mission.setMarkerAtEntity(…)

Sets marker at the given entity

Parameter Type Description
key string the key of the marker
entity Engine.Entity the entity
type string optional type
scaling number optional scaling
isSelectable? boolean whether marker is selectable
fireSelectEntity? boolean whether selecting the marker also selects the underlying entity (default is true)
Used in the base game: 2 times in 2 files

base/content/mission/mission/legacy_ui_util.tl:21

api.gui.mission.setMarkerAtEntity(key, legacyMarker.entity, legacyMarker.type)
base/content/mission/mission/mission_sim.script.tl:1094
api.gui.mission.setMarkerAtEntity(marker.key, marker.entity, marker.type, marker.scaling, marker.isSelectable, marker.fireSelectEntity)

removeMarker(key : string) api/tealdef/api/gui.d.tl:739

Call as api.gui.mission.removeMarker(…)

Removes a marker

Parameter Type Description
key string the key of the marker
Used in the base game: 2 times in 2 files

base/content/mission/mission/legacy_ui_util.tl:19

api.gui.mission.removeMarker(key)
base/content/mission/mission/mission_sim.script.tl:1155
api.gui.mission.removeMarker(k)

setMovePathVisualizationAtEntity(key : string, entity : Engine.Entity, color? : Vec3f) api/tealdef/api/gui.d.tl:745

Call as api.gui.mission.setMovePathVisualizationAtEntity(…)

Renderes the move path of an entity dynamically ATTENTION: at the moment, only ships are supported.

Parameter Type Description
key string unique key
entity Engine.Entity entity
color? Vec3f optional color
Used in the base game: 1 time in 1 file

mods/release/urbangames_campaign_mission_05/content/mission/mission/tasks/drilling/send_vehicle.tl:338

api.gui.mission.setMovePathVisualizationAtEntity(tostring(ctx.params.vehicle), ctx.params.vehicle, drawColor)

removeMovePathVisualization(key : string) api/tealdef/api/gui.d.tl:748

Call as api.gui.mission.removeMovePathVisualization(…)

Removes the move path of an entity dynamically

Parameter Type Description
key string unique key
Used in the base game: 2 times in 1 file

mods/release/urbangames_campaign_mission_05/content/mission/mission/tasks/drilling/send_vehicle.tl:340

api.gui.mission.removeMovePathVisualization(tostring(ctx.params.vehicle))

playCutscene(filePath : string, resolveLanguageFolder? : boolean, entityToEntityMap? : {Engine.Entity : Engine.Entity}) api/tealdef/api/gui.d.tl:754

Call as api.gui.mission.playCutscene(…)

Plays a cutscene.

Parameter Type Description
filePath string the filepath to the cutscene keyframe definition that should be played
resolveLanguageFolder? boolean automatically resolve the selected keyframe file by language
entityToEntityMap? {Engine.Entity : Engine.Entity} maps entities from the keyframe file to possible runtime entities
Used in the base game: 1 time in 1 file

base/content/mission/mission/tasks/cutscene/cutscene.tl:40

api.gui.mission.playCutscene(ctx.params.filePath, true, ctx.params.getEntityToEntityMap and ctx.params.getEntityToEntityMap(taskApi.getTaskState) or nil)

isCutscenePlaying() : boolean api/tealdef/api/gui.d.tl:757

Call as api.gui.mission.isCutscenePlaying(…)

Checks if a cutscene is currently playing.

Returns boolean

Used in the base game: 5 times in 3 files

base/content/game_mechanics/game_mechanics/notifications/gui/notification_popups.tl:96

if api.gui.mission.isCutscenePlaying() then
base/content/mission/mission/mission_framework/mission_framework_react.tl:1055
if not api.gui.mission.isCutscenePlaying() and not otherTaskPlaying then
base/content/mission/mission/mission_react_util.tl:347
if api.gui.mission.isCutscenePlaying() then

getCutsceneElapsedTime() : number api/tealdef/api/gui.d.tl:761

Call as api.gui.mission.getCutsceneElapsedTime(…)

Return the current cutscene time for syncing mission related systems to the cutscene

Returns number: the actual simulated cutscene time

Used in the base game: 3 times in 1 file

base/content/mission/mission/mission_react_util.tl:349

elapsedTime = api.gui.mission.getCutsceneElapsedTime()

Gui.Game

record api/tealdef/api/gui.d.tl:764

record Game

Access: api.gui.game

Notes

Game-session helpers (GUI save data, map editor state, environment), reached as api.gui.game.

Functions

isSavegameUIBlocked() : boolean api/tealdef/api/gui.d.tl:767

Call as api.gui.game.isSavegameUIBlocked(…)

Returns if the UI is blocked by a savegame in progress

Returns boolean: true if the ui is blocked by a savegame

Used in the base game: 1 time in 1 file

base/content/gui/gui/main/pause_menu.tl:62

return api.gui.game.isSavegameUIBlocked()

setInGameMenuPause(pause : boolean) api/tealdef/api/gui.d.tl:771

Call as api.gui.game.setInGameMenuPause(…)

Sets if the game pause menu is open

Parameter Type Description
pause boolean true if the user is in the pause menu
Used in the base game: 2 times in 1 file

base/content/gui/gui/main/pause_menu.tl:264

api.gui.game.setInGameMenuPause(true)

getGuiSaveData(modId : string) : table api/tealdef/api/gui.d.tl:776

Call as api.gui.game.getGuiSaveData(…)

Returns the GUI SaveData

Parameter Type Description
modId string the mod to get the user data for

Returns table: the userData as a lua table

Used in the base game: 8 times in 7 files

base/content/gui/gui/hud/cargo_flow.script.tl:147

local hudFilter = (api.gui.game.getGuiSaveData("") as BaseGUISaveData).hudFilter
base/content/gui/gui/hud/greenification_display.script.tl:140
local hudFilter = (api.gui.game.getGuiSaveData("") as BaseGUISaveData).hudFilter
base/content/gui/gui/hud/happy_change_display.script.tl:79
local hudFilter = (api.gui.game.getGuiSaveData("") as BaseGUISaveData).hudFilter
base/content/gui/gui/hud/marketing_display.script.tl:141
local hudFilter = (api.gui.game.getGuiSaveData("") as BaseGUISaveData).hudFilter
base/content/gui/gui/layers/layer_hud_filter.tl:37
return (api.gui.game.getGuiSaveData("") as BaseGUISaveData).hudFilter
base/content/gui/gui/line_vehicle_mgmt/vehicle_react_util.tl:329
local hudFilter = (api.gui.game.getGuiSaveData("") as BaseGUISaveData).hudFilter
… and 1 more files.

setGuiSaveData(modId : string, data : table) api/tealdef/api/gui.d.tl:781

Call as api.gui.game.setGuiSaveData(…)

Sets the GUI SaveData

Parameter Type Description
modId string the mod to set the user data for
data table the user data
Used in the base game: 6 times in 1 file

base/content/gui/gui/layers/layer_hud_filter.tl:82

api.gui.game.setGuiSaveData("", copy as {string : string})

getEstimatedMaximumGameSpeed() : integer api/tealdef/api/gui.d.tl:786

Call as api.gui.game.getEstimatedMaximumGameSpeed(…)

Returns the (estimated) maximum possible game speed based on actual simulation timings. Only available in GUI thread.

Returns integer: maximum game speed (or 0 if not enough data available)

Used in the base game: 2 times in 1 file

base/content/gui/gui/main/game.tl:637

local maxSpeedup = api.gui.game.getEstimatedMaximumGameSpeed()

isMapEditor() : boolean api/tealdef/api/gui.d.tl:790

Call as api.gui.game.isMapEditor(…)

Returns if the game is currently in the map editor

Returns boolean: true if in the map editor

Used in the base game: 6 times in 6 files

base/content/gui/gui/construction/construction_react_util.tl:3305

streetEdgeNodeModifier.makePlayerOwnedOnChange = not api.gui.game.isMapEditor()
base/content/gui/gui/game_bar/game_bar_display_earnings_plugin/game_bar_display_earnings.script.tl:8
local isMapEditorRef : ReactRefT<boolean> = react.useRefLazy(function() : boolean return api.gui.game.isMapEditor() end)
base/content/gui/gui/game_bar/game_bar_display_transported_plugin/game_bar_display_transported.script.tl:9
local isMapEditorRef : ReactRefT<boolean> = react.useRefLazy(function() : boolean return api.gui.game.isMapEditor() end)
base/content/gui/gui/main/game.tl:735
local isMapEditorRef : ReactRefT<boolean> = react.useRefLazy(function() : boolean return api.gui.game.isMapEditor() end)
base/content/gui/gui/main/pause_menu.tl:58
local isMapEditorRef : ReactRefT<boolean> = react.useRefLazy(function() : boolean return api.gui.game.isMapEditor() end)
base/content/gui/gui/menu/save_game_page.tl:155
local isMapEditorRef : ReactRefT<boolean> = react.useRefLazy(function() : boolean return api.gui.game.isMapEditor() end)

getDefaultSavegameId() : string api/tealdef/api/gui.d.tl:794

Call as api.gui.game.getDefaultSavegameId(…)

Returns the default savegame id

Returns string: the default savegame id

Used in the base game: 3 times in 3 files

base/content/gui/gui/main/game.tl:795

local name = api.gui.game.getDefaultSavegameId()
base/content/gui/gui/main/pause_menu.tl:394
text = lang_util.format(_("Game Paused - {savegameName}"), { savegameName = api.gui.game.getDefaultSavegameId() }),
base/content/gui/gui/menu/save_game_page.tl:157
local defaultSave = api.gui.game.getDefaultSavegameId()

setEnvironment(environment : ResName) api/tealdef/api/gui.d.tl:799

Call as api.gui.game.setEnvironment(…)

Sets an environment. This value is saved in the GUI SaveData and will be restored on next load. Changing it will not change the current environment, for that api.gui.rendering.setEnvironment needs to be as well called.

Parameter Type Description
environment ResName the resource name for the environment
Used in the base game: 1 time in 1 file

base/content/gui/gui/game_bar/game_bar_widgets.tl:665

api.gui.game.setEnvironment(newValue as ResName)

getEnvironment() : ResName api/tealdef/api/gui.d.tl:803

Call as api.gui.game.getEnvironment(…)

Returns the resource name of the current environment

Returns ResName: the environment resource name

Used in the base game: 1 time in 1 file

base/content/gui/gui/game_bar/game_bar_widgets.tl:639

return api.gui.game.getEnvironment()

Gui.Guide

record api/tealdef/api/gui.d.tl:806

record Guide

Access: api.gui.guide

Notes

The guide system (tutorial "bookmark" buttons attached to GUI components), reached as api.gui.guide.

Functions

trySpawnGuideById(targets : {GuideTarget}, tooltip : string, caption : string) : boolean api/tealdef/api/gui.d.tl:833

Call as api.gui.guide.trySpawnGuideById(…)

Tries to attach a guide system button to the first visible target component

Parameter Type Description
targets {GuideTarget} prioritized list of target components
tooltip string text
caption string optional caption text

Returns boolean

Used in the base game: 1 time in 1 file

base/content/mission/mission/guide_system/guide_system_react.tl:256

local guideSpawned = api.gui.guide.trySpawnGuideById(apiTargets, desiredGuide.info.name, desiredGuide.info.caption)

trySpawnGuideFree(position : FreeGuidePosition, tooltip : string, caption : string) : boolean api/tealdef/api/gui.d.tl:838

Call as api.gui.guide.trySpawnGuideFree(…)

Tries to spawn a free floating guide system button

Parameter Type Description
position FreeGuidePosition
tooltip string text
caption string optional caption text

Returns boolean

Used in the base game: 1 time in 1 file

base/content/mission/mission/guide_system/guide_system_react.tl:246

local guideSpawned = api.gui.guide.trySpawnGuideFree(FreePositionTable[desiredGuide.info.freePosition] or api.gui.guide.FreeGuidePosition.Low, desiredGuide.info

completeGuideById(targets : {GuideTarget}) : boolean api/tealdef/api/gui.d.tl:841

Call as api.gui.guide.completeGuideById(…)

Completes a guide corresponding to a specific id

Returns boolean

Used in the base game: 1 time in 1 file

base/content/mission/mission/guide_system/guide_system_react.tl:170

api.gui.guide.completeGuideById(apiTargets)

resetGuide() api/tealdef/api/gui.d.tl:844

Call as api.gui.guide.resetGuide(…)

Resets the current active guide

Used in the base game: 1 time in 1 file

base/content/mission/mission/guide_system/guide_system_react.tl:237

api.gui.guide.resetGuide()

Gui.Guide.GuidePosition

record api/tealdef/api/gui.d.tl:808

record GuidePosition

Gui positioning of the guide "bookmark" with respect to target component

Used in the base game: 1 time in 1 file

base/content/mission/mission/guide_system/guide_system_react.tl:186

local PositionTable<total> : {MissionInterface.GuideInfo.Position : api.gui.guide.GuidePosition} = {

Fields

Name Type Description
Left GuidePosition Guide button to the left of the target component. used 1× in the base game
Right GuidePosition Guide button to the right of the target component. used 1× in the base game
Above GuidePosition Guide button above the target component (the default). used 1× in the base game
Below GuidePosition Guide button below the target component. used 1× in the base game

Gui.Guide.FreeGuidePosition

record api/tealdef/api/gui.d.tl:816

record FreeGuidePosition

Gui positioning of the guide "bookmark" with respect to the entire screen

Used in the base game: 1 time in 1 file

base/content/mission/mission/guide_system/guide_system_react.tl:193

local FreePositionTable<total> : {MissionInterface.GuideInfo.FreePosition : api.gui.guide.FreeGuidePosition} = {

Fields

Name Type Description
High FreeGuidePosition Free guide button in the upper part of the screen. used 1× in the base game
Low FreeGuidePosition Free guide button in the lower part of the screen (the base game's default). used 2× in the base game

Gui.Guide.GuideTarget

record userdata api/tealdef/api/gui.d.tl:822

record GuideTarget

A target component for the guide system

Used in the base game: 2 times in 1 file

base/content/mission/mission/guide_system/guide_system_react.tl:166

local apiTargets : {Gui.Guide.GuideTarget} = {}

Fields

Name Type Description
idOrTag string Id or tag of the target GUI component.
position GuidePosition default is above

Functions

new(idOrTag : string, position? : GuidePosition) : GuideTarget api/tealdef/api/gui.d.tl:824

Notes

Creates a guide target.

Parameter Type Description
idOrTag string Id or tag of the GUI component to attach the guide to.
position? GuidePosition Where to place the guide button; defaults to GuidePosition.Above.

Returns GuideTarget: The new target.

Example

-- mission/guide_system/guide_system_react.tl
local targets = { api.gui.guide.GuideTarget.new(target.idOrTag, api.gui.guide.GuidePosition.Below) }
if not api.gui.guide.trySpawnGuideById(targets, info.name, info.caption) then
  log.verbose("target component not found")
end
Used in the base game: 2 times in 1 file

base/content/mission/mission/guide_system/guide_system_react.tl:168

table.insert(apiTargets, api.gui.guide.GuideTarget.new(target.idOrTag))

Gui.Rendering

record api/tealdef/api/gui.d.tl:847

record Rendering

Access: api.gui.rendering

Notes

Rendering helpers (environment, dust effects, frame interpolation), reached as api.gui.rendering.

Functions

setEnvironment(environment : Environment) api/tealdef/api/gui.d.tl:851

Call as api.gui.rendering.setEnvironment(…)

Sets an environment. This will change the current environment, but will not persist the environment resource name. It might be necessary to as well call api.gui.game.setEnvironment if a different environment resource is set.

Parameter Type Description
environment Environment the description for the environment
Used in the base game: 3 times in 2 files

base/content/gui/gui/game_bar/game_bar_widgets.tl:555

api.gui.rendering.setEnvironment(e)
base/content/mission/mission/tasks/utility/clouds.tl:50
api.gui.rendering.setEnvironment(e)

getEnvironment() : Environment api/tealdef/api/gui.d.tl:855

Call as api.gui.rendering.getEnvironment(…)

Returns the current environment data

Returns Environment: the current environment data

Used in the base game: 5 times in 2 files

base/content/gui/gui/game_bar/game_bar_widgets.tl:291

local environment = api.gui.rendering.getEnvironment()
base/content/mission/mission/tasks/utility/clouds.tl:35
local e = api.gui.rendering.getEnvironment()

spawnDust(bbMin : Vec3f, bbMax : Vec3f, transf : Mat4f) api/tealdef/api/gui.d.tl:861

Call as api.gui.rendering.spawnDust(…)

Makes a dust cloud appear

Parameter Type Description
bbMin Vec3f bounding box min
bbMax Vec3f bounding box max
transf Mat4f transformation matrix
Used in the base game: 1 time in 1 file

base/content/mission/mission/tasks/click_and_collect_custom_entity/collect_entity.tl:130

api.gui.rendering.spawnDust(bi.bbMin, bi.bbMax, modelInstanceList.fatInstances[1].transf)

getFrameTime01() : number api/tealdef/api/gui.d.tl:862

Call as api.gui.rendering.getFrameTime01(…)

Notes

Interpolation factor of the current render frame between the previous and the current simulation step.

Returns number: Value from 0 to 1; use it to blend between previous and current positions.

Example

-- smooth vehicle position for drawing (campaign mission 05, patrol.tl)
local inst = modelInstanceList.fatInstances[1]
local pos = api.type.Vec3f.lerp(inst.transf0:getTransl(), inst.transf:getTransl(),
  api.gui.rendering.getFrameTime01())
Used in the base game: 1 time in 1 file

mods/release/urbangames_campaign_mission_05/content/mission/mission/tasks/drilling/patrol.tl:61

local frameTime01 = api.gui.rendering.getFrameTime01()

Gui.Map

record api/tealdef/api/gui.d.tl:865

record Map

Access: api.gui.map

Notes

Map and terrain helpers, reached as api.gui.map.

Functions

setMapSeedText(seed : string) api/tealdef/api/gui.d.tl:868

Call as api.gui.map.setMapSeedText(…)

Sets seed for the map. Only available in GUI thread.

Parameter Type Description
seed string the seed
Used in the base game: 1 time in 1 file

base/content/gui/gui/map_editor/map_editor.tl:753

api.gui.map.setMapSeedText(fullState:old().seed)

reloadMaterialIndexManagerPipeline() api/tealdef/api/gui.d.tl:870

Call as api.gui.map.reloadMaterialIndexManagerPipeline(…)

Reloads the material index manager pipeline.

Used in the base game: 3 times in 1 file

base/content/gui/gui/map_editor/map_editor.tl:754

api.gui.map.reloadMaterialIndexManagerPipeline()

openTerrainEditor() api/tealdef/api/gui.d.tl:871

Call as api.gui.map.openTerrainEditor(…)

Notes

Opens the terrain (node) editor; called by its game-bar toggle.

Used in the base game: 1 time in 1 file

base/content/gui/gui/game_bar/game_bar.tl:365

api.gui.map.openTerrainEditor()

closeTerrainEditor() api/tealdef/api/gui.d.tl:872

Call as api.gui.map.closeTerrainEditor(…)

Notes

Closes the terrain (node) editor.

Used in the base game: 1 time in 1 file

base/content/gui/gui/game_bar/game_bar.tl:368

api.gui.map.closeTerrainEditor()

Gui.BenchMark

record api/tealdef/api/gui.d.tl:875

record BenchMark

Access: api.gui.benchMark

Notes

Frame and simulation timing data, reached as api.gui.benchMark.

Functions

getBeginFrameTimes() : {integer} api/tealdef/api/gui.d.tl:883

Call as api.gui.benchMark.getBeginFrameTimes(…)

Returns the rendering preparation time

Returns {integer}

getEventTimes() : {integer} api/tealdef/api/gui.d.tl:886

Call as api.gui.benchMark.getEventTimes(…)

Returns the events processing time

Returns {integer}

getCoreStepTimes() : {integer} api/tealdef/api/gui.d.tl:889

Call as api.gui.benchMark.getCoreStepTimes(…)

Returns the gui update time

Returns {integer}

getRenderTimes() : {integer} api/tealdef/api/gui.d.tl:892

Call as api.gui.benchMark.getRenderTimes(…)

Returns the rendering time

Returns {integer}

getSwapTimes() : {integer} api/tealdef/api/gui.d.tl:895

Call as api.gui.benchMark.getSwapTimes(…)

Returns the rendering finish time

Returns {integer}

getReplicateTimes() : {SimTime} api/tealdef/api/gui.d.tl:898

Call as api.gui.benchMark.getReplicateTimes(…)

Returns the sync time between gui and simulation. Only available in GUI thread.

Returns {SimTime}

getCommandTimes() : {SimTime} api/tealdef/api/gui.d.tl:901

Call as api.gui.benchMark.getCommandTimes(…)

Returns commands processing time. Only available in GUI thread.

Returns {SimTime}

getGameStepTimes() : {SimTime} api/tealdef/api/gui.d.tl:904

Call as api.gui.benchMark.getGameStepTimes(…)

Returns the simulation update time. Only available in GUI thread.

Returns {SimTime}

Gui.BenchMark.SimTime

record api/tealdef/api/gui.d.tl:877

record SimTime

Simulation time frame along with game time at moment of capture

Fields

Name Type Description
frameTime integer Measured duration of the frame.
gameTime integer Game time at the moment of capture.

Gui.Debug

record api/tealdef/api/gui.d.tl:907

record Debug

Access: api.gui.debug

Notes

Debug helpers, reached as api.gui.debug.

Functions

selectEntity(entity : Engine.Entity) api/tealdef/api/gui.d.tl:910

Call as api.gui.debug.selectEntity(…)

Set the current debug entity

Parameter Type Description
entity Engine.Entity the entity
Used in the base game: 5 times in 1 file

base/content/gui/gui/debug_panel/make_entity_debug_panel.tl:150

api.gui.debug.selectEntity(comp[v])

Gui.Achievements

record api/tealdef/api/gui.d.tl:913

record Achievements

Access: api.gui.achievements

Notes

Achievements and player statistics, reached as api.gui.achievements.

Functions

areStatsDisabled() : boolean api/tealdef/api/gui.d.tl:916

Call as api.gui.achievements.areStatsDisabled(…)

Checkes whether player stats are disabled

Returns boolean: true if player stats are disabled

Used in the base game: 2 times in 1 file

base/content/game_mechanics/game_mechanics/achievements/achievements.script.tl:510

if not api.gui.achievements.areStatsDisabled() then

unlockAchievement(achievement : string) api/tealdef/api/gui.d.tl:920

Call as api.gui.achievements.unlockAchievement(…)

Unlocks an achievement based on its string id

Parameter Type Description
achievement string achievement to unlock
Used in the base game: 17 times in 1 file

base/content/game_mechanics/game_mechanics/achievements/achievements.script.tl:634

api.gui.achievements.unlockAchievement("ACH_FIRST_CARGO_DELIVERED")

isAchievementUnlockable(achievement : string) : boolean api/tealdef/api/gui.d.tl:925

Call as api.gui.achievements.isAchievementUnlockable(…)

Checks whether an achievement can be unlocked

Parameter Type Description
achievement string achievement to check

Returns boolean: true if the achievement can be unlocked

Used in the base game: 17 times in 1 file

base/content/game_mechanics/game_mechanics/achievements/achievements.script.tl:632

if api.gui.achievements.isAchievementUnlockable("ACH_FIRST_CARGO_DELIVERED") then

isAchievementUnlocked(achievement : string) : boolean api/tealdef/api/gui.d.tl:930

Call as api.gui.achievements.isAchievementUnlocked(…)

Checks whether an achievement is unlocked (completed)

Parameter Type Description
achievement string achievement to check

Returns boolean: true if the achievement is unlocked

updateStat(playerStat : string, value : number) api/tealdef/api/gui.d.tl:935

Call as api.gui.achievements.updateStat(…)

Increments a player stat value by the provided value

Parameter Type Description
playerStat string the stat id to update
value number the value to add to the stat
Used in the base game: 8 times in 1 file

base/content/game_mechanics/game_mechanics/achievements/achievements.script.tl:519

api.gui.achievements.updateStat("STAT_TRACK_TOTAL_LENGTH", delta)

setStat(playerStat : string, value : number) api/tealdef/api/gui.d.tl:940

Call as api.gui.achievements.setStat(…)

Sets a player stat value, replacing the current value by the provided one

Parameter Type Description
playerStat string the stat id to update
value number the value to add to the stat
Used in the base game: 1 time in 1 file

base/content/game_mechanics/game_mechanics/achievements/achievements.script.tl:585

api.gui.achievements.setStat("STAT_TOTAL_INCOME_BILLION", newStatValue)

getStatValue(playerStat : string) : number api/tealdef/api/gui.d.tl:945

Call as api.gui.achievements.getStatValue(…)

Gets a player stat value

Parameter Type Description
playerStat string the stat id to get

Returns number: the current value of the stat

setStatExtraData(playerStat : string, data : table) api/tealdef/api/gui.d.tl:951

Call as api.gui.achievements.setStatExtraData(…)

Sets extra data associated with a stat. Extra data are stored locally in the player profile and allow tracking of more informations if necessary.

Parameter Type Description
playerStat string the stat id to set the extra data for
data table the extra data to set
Used in the base game: 5 times in 1 file

base/content/game_mechanics/game_mechanics/achievements/achievements.script.tl:565

api.gui.achievements.setStatExtraData("STAT_CLIMATES_TYCOON", extraData)

getStatExtraData(playerStat : string) : table api/tealdef/api/gui.d.tl:957

Call as api.gui.achievements.getStatExtraData(…)

Gets extra data associated with a stat. Extra data are stored locally in the player profile and allow tracking of more informations if necessary.

Parameter Type Description
playerStat string the stat id to get the extra data for

Returns table: the extra data

Used in the base game: 5 times in 1 file

base/content/game_mechanics/game_mechanics/achievements/achievements.script.tl:552

local extraData = api.gui.achievements.getStatExtraData("STAT_CLIMATES_TYCOON") as {string:boolean}

setEarnedSFX(sfx : {FilePath}) api/tealdef/api/gui.d.tl:961

Call as api.gui.achievements.setEarnedSFX(…)

Set sound effect(s) to be played when an achievement is earned.

Parameter Type Description
sfx {FilePath} vector of filepaths pointing to .wav files with according sound effect(s)
Used in the base game: 2 times in 1 file

base/content/game_mechanics/game_mechanics/achievements/achievements.script.tl:166

api.gui.achievements.setEarnedSFX(sfxAchievement.Earned or {})

Gui.GenericRep

record api/tealdef/api/gui.d.tl:964

record GenericRep is ResTypeRep<integer, GenericGameRes>

Access: api.gui.genericRep

Notes

Repository of GUI-side generic resources (.gres files of type gui_res / gui_res_overwrite), reached as api.gui.genericRep.

Example

local colorDefault = api.gui.genericRep.get(api.gui.genericRep.find("::/gui/main/default_colors.gres")).data

Functions

getAllOfType(typeName : string, includeInvisible? : boolean) : {integer} api/tealdef/api/gui.d.tl:969

Call as api.gui.genericRep.getAllOfType(…)

Gets all the Genereic Resource Type of a given type name Only allows typeName in { "gui_res_overwrite", "gui_res" }, for other types, use api.res.genericRep

Parameter Type Description
typeName string the type name
includeInvisible? boolean whether to include invisible resources

Returns {integer}

Gui.Backend

record api/tealdef/api/gui.d.tl:972

record Backend

Access: api.gui.backend

Notes

Paradox account and online backend (login, profile, legal documents, third-party account linking), reached as api.gui.backend.

Functions

isInitialized() : boolean api/tealdef/api/gui.d.tl:978

Call as api.gui.backend.isInitialized(…)

Notes

Whether the online backend is initialized; the mod manager shows an offline message when it is not.

Returns boolean: true when the backend is available.

Used in the base game: 2 times in 2 files

base/content/gui/gui/menu/main_menu.tl:585

return api.gui.backend.isInitialized()
base/content/gui/gui/menu/mod_manager_react_util.tl:5171
if not api.gui.backend.isInitialized() then

hasLegalDocuments() api/tealdef/api/gui.d.tl:980

Call as api.gui.backend.hasLegalDocuments(…)

Notes

Whether there are legal documents the player still has to view; the main menu then shows the licence page first.

Details

The definition declares no return value, but the base game uses the result as a boolean (gui/menu/main_menu.tl).

Used in the base game: 2 times in 1 file

base/content/gui/gui/menu/main_menu.tl:703

showLicenseAgreement = api.gui.backend.hasLegalDocuments(),

getLegalDocuments() : {string} api/tealdef/api/gui.d.tl:982

Call as api.gui.backend.getLegalDocuments(…)

Notes

Types of the legal documents to show; pass each one to getLegalDocument.

Returns {string}: List of document type strings.

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/license_page.tl:17

local legalDocuments = react.useState(api.gui.backend.getLegalDocuments()) as ReactStateT<{string}>

markLegalDocumentViewed(string) api/tealdef/api/gui.d.tl:984

Call as api.gui.backend.markLegalDocumentViewed(…)

Notes

Marks a legal document as viewed by the player.

Parameter Type Description
#1 string Document type, as returned by getLegalDocuments.
Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/license_page.tl:104

api.gui.backend.markLegalDocumentViewed(legalDocuments:old()[indexState:old()])

isAccountLoggedIn() : boolean api/tealdef/api/gui.d.tl:986

Call as api.gui.backend.isAccountLoggedIn(…)

Notes

Whether a Paradox account is logged in.

Returns boolean: true when logged in.

Used in the base game: 5 times in 2 files

base/content/gui/gui/menu/mod_manager_react_util.tl:1202

api.gui.backend.isAccountLoggedIn()
base/content/gui/gui/menu/paradox_react_util.tl:980
local isLoggedIn = api.gui.backend.isAccountLoggedIn()

loginAccount(username : string, password : string) : PdxFuture<PdxLoginResult> api/tealdef/api/gui.d.tl:988

Call as api.gui.backend.loginAccount(…)

Notes

Starts logging in to a Paradox account.

Parameter Type Description
username string Account e-mail / user name.
password string Account password.

Returns PdxFuture<PdxLoginResult>: Future; poll getResult() (it returns nil until the result is available).

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/paradox_react_util.tl:1254

loginAccountFutureRef:set(api.gui.backend.loginAccount(s.username, s.password))

logoutAccount() : PdxFuture<PdxResult> api/tealdef/api/gui.d.tl:990

Call as api.gui.backend.logoutAccount(…)

Notes

Logs out of the Paradox account.

Returns PdxFuture<PdxResult>: Future with the result.

Used in the base game: 2 times in 2 files

base/content/gui/gui/menu/mod_manager_react_util.tl:1268

api.gui.backend.logoutAccount()
base/content/gui/gui/menu/paradox_react_util.tl:1224
api.gui.backend.logoutAccount()

getAccountInfo() : PdxFuture<PdxAccountInfo> api/tealdef/api/gui.d.tl:992

Call as api.gui.backend.getAccountInfo(…)

Notes

Requests information about the logged-in account.

Returns PdxFuture<PdxAccountInfo>: Future with the account info.

Used in the base game: 3 times in 1 file

base/content/gui/gui/menu/paradox_react_util.tl:1033

getAccountInfoFutureRef:set(api.gui.backend.getAccountInfo())

getProfile(social : boolean) : PdxFuture<PdxProfileResult> api/tealdef/api/gui.d.tl:994

Call as api.gui.backend.getProfile(…)

Notes

Requests the player's Paradox profile.

Parameter Type Description
social boolean Which profile to query; the base game passes true.

Returns PdxFuture<PdxProfileResult>: Future with the profile result.

Used in the base game: 3 times in 1 file

base/content/gui/gui/menu/paradox_react_util.tl:976

checkProfileFutureRef:set(api.gui.backend.getProfile(true))

createProfile(name : string, social : boolean) : PdxFuture<PdxResult> api/tealdef/api/gui.d.tl:996

Call as api.gui.backend.createProfile(…)

Notes

Creates a Paradox profile with the given name.

Parameter Type Description
name string Profile name entered by the player.
social boolean The base game passes true.

Returns PdxFuture<PdxResult>: Future with the result.

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/paradox_react_util.tl:1142

createProfileFutureRef:set(api.gui.backend.createProfile(name, true))

renameProfile(name : string, social : boolean) : PdxFuture<PdxResult> api/tealdef/api/gui.d.tl:998

Call as api.gui.backend.renameProfile(…)

Notes

Renames the Paradox profile.

Parameter Type Description
name string New profile name.
social boolean As for createProfile.

Returns PdxFuture<PdxResult>: Future with the result.

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/paradox_react_util.tl:1610

futureRef:set(api.gui.backend.renameProfile(name, true))

getCountries() : {PdxCountry} api/tealdef/api/gui.d.tl:1000

Call as api.gui.backend.getCountries(…)

Notes

Countries / regions selectable when creating an account.

Returns {PdxCountry}: List of PdxCountry (name, code); pass code to createAccount.

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/paradox_react_util.tl:543

local countries = api.gui.backend.getCountries()

getLegalDocument(type : string) : PdxFuture<PdxLegalDocument> api/tealdef/api/gui.d.tl:1002

Call as api.gui.backend.getLegalDocument(…)

Notes

Requests the content of one legal document.

Parameter Type Description
type string Document type, as returned by getLegalDocuments.

Returns PdxFuture<PdxLegalDocument>: Future with the document (title, text).

Example

-- gui/menu/license_page.tl: request, then poll every step
local future = api.gui.backend.getLegalDocument(api.gui.backend.getLegalDocuments()[1])
react.onStep(function()
  local doc = future and future:getResult()
  if doc ~= nil then
    future = nil
    title:set(doc.title); text:set(doc.text)
  end
end)
Used in the base game: 2 times in 2 files

base/content/gui/gui/menu/license_page.tl:26

futureRef:set(api.gui.backend.getLegalDocument(legalDocuments:old()[index]))
base/content/gui/gui/menu/paradox_react_util.tl:328
futureRef:set(api.gui.backend.getLegalDocument(params.type))

createAccount(email : string, password : string, dateOfBirth : string, countryCode : integer, marketingPermission : boolean) : PdxFuture<PdxResult> api/tealdef/api/gui.d.tl:1004

Call as api.gui.backend.createAccount(…)

Notes

Creates a new Paradox account.

Parameter Type Description
email string E-mail address.
password string Password.
dateOfBirth string Date of birth, as delivered by the base game's date input.
countryCode integer Country code from getCountries.
marketingPermission boolean Whether the player agrees to marketing e-mails.

Returns PdxFuture<PdxResult>: Future with the result.

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/paradox_react_util.tl:421

futureRef:set(api.gui.backend.createAccount(s.email, s.password, s.dateOfBirth, s.countryCode, s.marketingPermission))

supportsAccountLinking() : boolean api/tealdef/api/gui.d.tl:1006

Call as api.gui.backend.supportsAccountLinking(…)

Notes

Whether the platform supports linking a third-party (platform) account to the Paradox account.

Returns boolean

Used in the base game: 2 times in 1 file

base/content/gui/gui/menu/paradox_react_util.tl:1006

if api.gui.backend.supportsAccountLinking() then

getThirdPartyLinkState() : PdxFuture<PdxThirdPartyLinkState> api/tealdef/api/gui.d.tl:1008

Call as api.gui.backend.getThirdPartyLinkState(…)

Notes

Requests whether the third-party account is linked.

Returns PdxFuture<PdxThirdPartyLinkState>: Future with the link state.

Used in the base game: 3 times in 1 file

base/content/gui/gui/menu/paradox_react_util.tl:737

getThirdPartyLinkStateFutureRef:set(api.gui.backend.getThirdPartyLinkState())

getThirdPartyAutoLoginPromptState() : PdxThirdPartyAutoLoginPromptState api/tealdef/api/gui.d.tl:1010

Call as api.gui.backend.getThirdPartyAutoLoginPromptState(…)

Notes

Current state of the third-party auto-login prompt.

Returns PdxThirdPartyAutoLoginPromptState

Used in the base game: 2 times in 1 file

base/content/gui/gui/menu/paradox_react_util.tl:1038

local thirdPartyLoginPromptState = api.gui.backend.getThirdPartyAutoLoginPromptState()

setThirdPartyAutoLoginPromptState(state : PdxThirdPartyAutoLoginPromptState) api/tealdef/api/gui.d.tl:1012

Call as api.gui.backend.setThirdPartyAutoLoginPromptState(…)

Notes

Sets the state of the third-party auto-login prompt (the mod manager resets it to NotShown on logout).

Parameter Type Description
state PdxThirdPartyAutoLoginPromptState New state, e.g. api.type.enum.PdxThirdPartyAutoLoginPromptState.NotShown.
Used in the base game: 3 times in 2 files

base/content/gui/gui/menu/mod_manager_react_util.tl:1267

api.gui.backend.setThirdPartyAutoLoginPromptState(api.type["enum"].PdxThirdPartyAutoLoginPromptState.NotShown)
base/content/gui/gui/menu/paradox_react_util.tl:877
api.gui.backend.setThirdPartyAutoLoginPromptState(api.type["enum"].PdxThirdPartyAutoLoginPromptState.Accepted)

linkThirdPartyAccount() : PdxFuture<PdxResult> api/tealdef/api/gui.d.tl:1014

Call as api.gui.backend.linkThirdPartyAccount(…)

Notes

Links the third-party account to the logged-in Paradox account.

Returns PdxFuture<PdxResult>: Future with the result.

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/paradox_react_util.tl:853

linkThirdPartyAccountFutureRef:set(api.gui.backend.linkThirdPartyAccount())

unlinkThirdPartyAccount() : PdxFuture<PdxResult> api/tealdef/api/gui.d.tl:1016

Call as api.gui.backend.unlinkThirdPartyAccount(…)

Notes

Removes the link between the third-party account and the Paradox account.

Returns PdxFuture<PdxResult>: Future with the result.

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/paradox_react_util.tl:850

linkThirdPartyAccountFutureRef:set(api.gui.backend.unlinkThirdPartyAccount())

loginThirdPartyAccount() : PdxFuture<PdxLoginResult> api/tealdef/api/gui.d.tl:1018

Call as api.gui.backend.loginThirdPartyAccount(…)

Notes

Logs in to Paradox with the linked third-party account.

Returns PdxFuture<PdxLoginResult>: Future with the login result.

Used in the base game: 1 time in 1 file

base/content/gui/gui/menu/paradox_react_util.tl:919

pdxFutureRef:set(api.gui.backend.loginThirdPartyAccount())

Gui.Backend.LegalDocument

record api/tealdef/api/gui.d.tl:973

record LegalDocument

Notes

A legal document (title and text).

Fields

Name Type Description
title string Title of the document.
text string Text of the document.