Attempts to place an edge between two joints, respecting all placement restrictions to only place edges legally. Can only be used in BUILD or SANDBOX modes. Returns “SUCCESS” on success, or an error message on failure.
Argument
Type
Comment
materialName
string
is the name of the desired material.
jointIdA
string
is the id of the start joint, usually obtained from GetJointIds
jointIdB
string
is the id of the end joint, usually obtained from GetJointIds
Return
Type
Comment
success
string
“SUCCESS” on success, or an error message on failure.
Attempts to place an edge starting at the given joint and ending at the given position, respecting all placement restrictions to only place edges legally. Can only be used in BUILD or SANDBOX modes. Returns “SUCCESS” on success, or an error message on failure.
Argument
Type
Comment
materialName
string
is the name of the desired material.
jointIdA
string
is the id of the start joint, usually obtained from GetJointIds.
posB
Vec3
is the end position of the edge.
Return
Type
Comment
success
string
“SUCCESS” on success, or an error message on failure.
Attempts to place an edge starting at posA and ending at posB, respecting all placement restrictions to only place edges legally. Can only be used in BUILD or SANDBOX modes. Returns “SUCCESS” on success, or an error message on failure.
Argument
Type
Comment
materialName
string
is the name of the desired material.
posA
Vec3
is the start position of the edge. This MUST be near enough to an existing joint so that edge placement can begin at that joint.
posB
Vec3
is the end position of the edge.
Return
Type
Comment
success
string
“SUCCESS” on success, or an error message on failure.
Set the color of this edge, overriding the normal texture and stress color visualization. This color will persist when switching between build mode and sim mode, as well as persist through save/load. Note that SetOverrideEdgeColor takes priority over the permanent color if it is used.
Argument
Type
Comment
id
string
is the id of the edge, usually obtained from GetBridgeEdgeIds()
overrideColor
string
is the color to set the edge. Format: #RRGGBBAA
Camera functions
GetCameraFOV
number GetCameraFOV()
returns the Field Of View value of the camera (float)
Return
Type
Comment
fov
number
the Field Of View value of the camera
GetCameraOrthographic
boolean GetCameraOrthographic()
Returns true if the camera is set to Orthographic, otherwise returns false
Return
Type
Comment
isOrthographic
boolean
true if the camera is set to Orthographic, otherwise returns false
GetCameraOrthographicSize
number GetCameraOrthographicSize()
Returns the Orthographic Size value of the camera (float)
Return
Type
Comment
size
number
the Orthographic Size value of the camera
GetCameraPosition
Vec3 GetCameraPosition()
Returns the current game world position of the camera as a float list of length 3 (corresponding to x, y, and z position)
Return
Type
Comment
position
Vec3
the current game world position of the camera as a float list of length 3
GetCameraRotation
Vec3 GetCameraRotation()
Returns the current game world rotation of the camera as a float list of length 3 (corresponding to x, y, and z euler angles)
Return
Type
Comment
rotation
Vec3
the current game world rotation of the camera as a float list of length 3
SetCameraFOV
nil SetCameraFOV(value: number)
Sets the Field Of View value of the camera to the desired value
Argument
Type
Comment
value
number
is the desired Field Of View value of the camera
SetCameraLookAtObject
nil SetCameraLookAtObject(objectId: string)
Sets the camera's rotation so that it looks at the desired object, note this will only work correctly if Orthographic is set to false
Argument
Type
Comment
objectId
string
is the id of the vehicle, edge, or joint to look at
SetCameraOrthographic
nil SetCameraOrthographic(value: boolean)
Sets the Orthographic setting of the camera to the desired value
Argument
Type
Comment
value
boolean
is the desired Orthographic state
SetCameraOrthographicSize
nil SetCameraOrthographicSize(value: number)
Sets the Orthographic Size value of the camera to the desired value
Argument
Type
Comment
value
number
is the desired Orthographic Size value of the camera
SetCameraPosition
nil SetCameraPosition(position: Vec3)
Sets the current game world position of the camera
Argument
Type
Comment
position
Vec3
is the desired position of the camera (corresponding to x, y, and z position)
SetCameraRotation
nil SetCameraRotation(rotation: Vec3)
Sets the current game world rotation of the camera
Argument
Type
Comment
rotation
Vec3
is the desired rotation of the camera (corresponding to x, y, and z euler angles)
Adds a console command that calls a named function from ConsoleCommands.lua
Argument
Type
Comment
commandName
string
is the name of the command the user will type into the debug console
helpText
string
is the help text string the user will see when they type “help” in the debug console
numParameters
integer
is the number of parameters the command requires (use 0 to make app parameters optional and use varargs (...) in the command function)
EnableDebugConsole
nil EnableDebugConsole()
Unlocks the debug console, allowing it to be opened using the ~ key
EnableLevelNavArrows
nil EnableLevelNavArrows()
Enables buttons in the top bar for navigation forward and backwards through campaign levels.
ShowLevelID
nil ShowLevelID()
Shows the current level ID in the level info panel
Game State functions
EndLevelFail
boolean EndLevelFail(failReasonText: string)
If you are in sim mode and the simulation has started, immediately end the simulation and go to level failed screen, showing failReason text. returns true if successful.
Argument
Type
Comment
failReasonText
string
Message to show in the fail panel
EndLevelSuccess
boolean EndLevelSuccess()
GetCurrentLevelID
string GetCurrentLevelID()
Returns the current level ID (string)
Return
Type
Comment
levelID
string
the current level ID
GetDefaultSimSpeed
number GetDefaultSimSpeed()
Returns the default normalized sim speed (float)
Return
Type
Comment
simSpeed
number
the default normalized sim speed
GetSimSpeed
number GetSimSpeed()
Returns the current normalized sim speed (float)
Return
Type
Comment
simSpeed
number
the current normalized sim speed
IsSimulating
boolean IsSimulating()
Returns true if you are in sim mode and the simulation has started, otherwise returns false.
IsSimulatingWithoutPassOrFail
boolean IsSimulatingWithoutPassOrFail()
Returns true or false based on if the game is currently simulating but pass/fail has yet to be determined
SetSimSpeed
nil SetSimSpeed(speed: number)
Sets the current sim speed to the desired value, note that the desired value must be a valid sim speed in the current sim speed list. Default valid sim speeds are {0.1, 0.2, 0.5, 1, 2, 3, 5}
Argument
Type
Comment
speed
number
is the desired normalized sim speed
SimulationEnd
boolean SimulationEnd()
Ends simulation if you are in sim mode and the simulation has started. returns true if successful.
SimulationPause
boolean SimulationPause()
Pauses simulation if you are in sim mode and the simulation has started. returns true if successful.
SimulationStart
boolean SimulationStart()
Starts simulation if you are in build mode, or resumes simulating if you are in a paused simulation. returns true if successful.
SimulationTogglePause
boolean SimulationTogglePause()
Toggles pause state of simulation if you are in sim mode and the simulation has started. returns true if successful.
SimulationUnpause
boolean SimulationUnpause()
Unpauses simulation if you are in sim mode and the simulation has started. returns true if successful.
Generic functions
GetVehiclePhysicsVelocity
nil GetVehiclePhysicsVelocity(undefined)
OpenLevel
nil OpenLevel(undefined)
OpenWorkshopLevel
nil OpenWorkshopLevel(undefined)
SetRoadEdgeTint
nil SetRoadEdgeTint(undefined)
SetVehiclePhysicsVelocity
nil SetVehiclePhysicsVelocity(undefined)
SetVehiclePosition
nil SetVehiclePosition(undefined)
SetVehicleRotation
nil SetVehicleRotation(undefined)
SetVehicleSpeed
nil SetVehicleSpeed(undefined)
Language functions
AddLanguageCSV
nil AddLanguageCSV(filename: string)
Add a translation for the game UI.
A template for this file can be created on the Workshop -> Created panel.
Argument
Type
Comment
filename
string
The name of the csv file located in the same directory as the lua script.
Material functions
GetHydraulicsBaseTint
string GetHydraulicsBaseTint()
Returns the tint color string for hydraulics base texture
Return
Type
Comment
tintColor
string
The tint color string for hydraulics base texture
GetMaterialCost
number GetMaterialCost(materialName: string)
Returns the cost per meter of the given material
Argument
Type
Comment
materialName
string
must match one of the material names above.
Return
Type
Comment
cost
number
The cost per meter of the given material
GetMaterialMaxLength
number GetMaterialMaxLength(materialName: string)
Returns the max length of the given material
Argument
Type
Comment
materialName
string
must match one of the material names above.
Return
Type
Comment
cost
number
The max length of the given material
GetMaterialStrength
number GetMaterialStrength(materialName: string)
Returns the strength of the given material
Argument
Type
Comment
materialName
string
must match one of the material names above.
Return
Type
Comment
strength
number
The strength of the given material
GetMaterialTint
string GetMaterialTint(materialName: string)
Returns the tint color string for this material
Argument
Type
Comment
materialName
string
The name of the material to permanently tint, see appendix for valid material names
Return
Type
Comment
tintColor
string
The tint color string for this material
GetRoadEdgeTint
string GetRoadEdgeTint()
Returns the tint color string for road edge texture
Return
Type
Comment
tintColor
string
The tint color string for road edge texture
SetHydraulicsBaseTint
nil SetHydraulicsBaseTint(tintColor: string)
Permanently tints the texture of the base of the hydraulic. Note that the extending/contracting part of the hydraulic can be tinted using SetMaterialTint()
Permanently tints the texture of the given material. Note that Hydraulics and Roads use a secondary texture, which can be tinted using SetHydraulicsBaseTint and SetRoadEdgeTint respectively
Argument
Type
Comment
materialName
string
The name of the material to permanently tint, see appendix for valid material names
tintColor
string
The color to tint the material. Format: #RRGGBBAA
Sandbox functions
AddCustomShape
nil AddCustomShape(folderName: string)
Add custom shape(s) to be used in sandbox
Argument
Type
Comment
folderName
string
The name of directory containing the custom shape(s)
Adds a texture to be used in custom shapes in sandbox
Argument
Type
Comment
filename
string
The name of the png file located in the same directory as the lua script.
textureName
string
The name that will appear in the dropdown when selecting custom shape textures.
id
string
ID for this texture. If you have multiple textures in your mod, they must have unique id values. If you edit your mod after uploading, do not change this id value.
DisableRandomVehicleSpawn
nil DisableRandomVehicleSpawn()
Disables the random vehicle spawning that occurs when a new Sandbox is created
Creates a new button object
NOTE: Please make your callback function name as unique as possible. If multiple callbacks across different mods share the same name, the one loaded last will overwrite the others.
Argument
Type
Comment
buttonId
string
is the name of the button object, used to update it later
callback
string
is the name of the LUA function this button will execute when pressed
Sets the button callback to a named global function name
NOTE: Please make your callback function name as unique as possible. If multiple callbacks across different mods share the same name, the one loaded last will overwrite the others.
Argument
Type
Comment
buttonId
string
is the name of the button object
callback
string
is the name of the LUA function this button will execute when pressed
Sets the color filter of a sprite object. For example a 1x1 solid white image with a 50% transparent red color (#FF000080) will draw a 50% transparent red sprite.
Argument
Type
Comment
spriteId
string
is the name of the sprite object
colorString
string
is the new color value for the sprite, using format: #RRGGBBAA
Enables the background of a text object
NOTE: the background auto-scales to the display size of the text, which will prevent the text pivot and alignment from working as expected
name of the theme to be modified. Currently one of: Alpine, Rocks, HighDesert, SkyCreeper
topColor
string
Color of top portion of sky using format: #RRGGBBAA
midColor
string
Color of top portion of sky using format: #RRGGBBAA
botColor
string
Color of top portion of sky using format: #RRGGBBAA
offset
number
Value between 0 and 1 that controls how colors blend. 0: blend between top and mid colors, 0.5: ⅓ top, ⅓ mid, ⅓ bot, 1: blend between mid and bot colors
Loads a z-axis boat asset from an addressable prefab to be used in sandbox and workshop.
See the UGC Pipeline section of the documentation for more info.
Argument
Type
Comment
iconFilename
string
is the name of the png file located in the same directory as the lua script, representing the icon that will appear in the dropdown to select this item.
boatName
string
is the name that will appear in game.
prefabAddress
string
is the address of the prefab object defined in the Mod Creation project.
mass
number
is the default mass of the object, used to sort UGC assets.
Loads a decor asset from an addressable prefab to be used in sandbox and workshop.
See the UGC Pipeline section of the documentation for more info.
Argument
Type
Comment
iconFilename
string
The name of the png file located in the same directory as the lua script, representing the icon that will appear in the dropdown to select this decor item.
decorName
string
The name that will appear in the decor dropdown.
prefabAddress
string
The address of the prefab object defined in the Mod Creation project. See the UGC Pipeline section for more info.
Loads a z-axis plane asset from an addressable prefab to be used in sandbox and workshop.
See the UGC Pipeline section of the documentation for more info.
Argument
Type
Comment
iconFilename
string
is the name of the png file located in the same directory as the lua script, representing the icon that will appear in the dropdown to select this item.
planeName
string
is the name that will appear in game.
prefabAddress
string
is the address of the prefab object defined in the Mod Creation project.
mass
number
is the default mass of the object, used to sort UGC assets.
Loads a vehicle asset from an addressable prefab to be used in sandbox and workshop.
See the UGC Pipeline section of the documentation for more info.
Argument
Type
Comment
iconFilename
string
is the name of the png file located in the same directory as the lua script, representing the icon that will appear in the dropdown to select this vehicle.
vehicleName
string
is the name that will appear in the vehicle dropdown.
prefabAddress
string
is the address of the prefab object defined in the Mod Creation project.
mass
number
is the default mass of the object, used to sort UGC assets.
UI functions
IsMenuOpen
boolean IsMenuOpen()
Returns true if any menu is open, otherwise returns false
Return
Type
Comment
isOpen
boolean
true if any menu (modal) is open, otherwise returns false
IsStressVisibilityEnabled
boolean IsStressVisibilityEnabled()
Returns true if stress visibility is enabled, otherwise returns false
Return
Type
Comment
isEnabled
boolean
true if stress visibility is enabled, otherwise returns false
SetDefaultSimSpeed
nil SetDefaultSimSpeed(speed: integer)
Sets the default sim speed from the available speeds. If speed does not exist in list of simulation speeds, then value is ignored
Argument
Type
Comment
speed
integer
Default simulation speed
SetSimSpeeds
nil SetSimSpeeds(speeds: integer[])
Sets the available simulation speeds to use in game as table of integers where 1000=1.0x. Default: {100, 200, 500, 1000, 2000, 3000, 5000}
Argument
Type
Comment
speeds
integer[]
Simulation speeds to use in game
ShowMessage
nil ShowMessage(text: string)
Shows an information popup message in the center of the screen with an OK button
Argument
Type
Comment
text
string
is the text to show in a popup
Utils functions
ConsoleLog
nil ConsoleLog(message: string)
Log a message to the consoles
Argument
Type
Comment
message
string
will be printed to the Unity Editor console
GetFrameCount
number GetFrameCount()
Returns the total number of frames since the start of the game (int)
Return
Type
Comment
frames
number
the total number of frames since the start of the game
GetGameState
string GetGameState()
Returns the current game state (string). Valid values include: MAIN_MENU, BUILD, SANDBOX, SIM.
Return
Type
Comment
state
string
the current game state (string). (MAIN_MENU, BUILD, SANDBOX, SIM)
GetGameTime
number GetGameTime()
Returns the time in seconds since the start of the game (float)
GetKeycodeDown
boolean GetKeycodeDown(keycodeNumber: integer)
Returns true if the key is currently held down, otherwise returns false
Argument
Type
Comment
keycodeNumber
integer
is the integer value of the desired key, like 112 for "P" or 303 for "RightShift". Full list can be found here: https://gist.github.com/Extremelyd1/4bcd495e21453ed9e1dffa27f6ba5f69
Returns true if the key was just pressed this frame, otherwise returns false
Argument
Type
Comment
keycodeNumber
integer
is the integer value of the desired key, like 112 for "P" or 303 for "RightShift". Full list can be found here: https://gist.github.com/Extremelyd1/4bcd495e21453ed9e1dffa27f6ba5f69
GetKeyDown
boolean GetKeyDown(keycodeString: string)
Returns true if the key is currently held down, otherwise returns false
Argument
Type
Comment
keycodeString
string
is the name of the desired key, like "P" or "RightShift". Full list can be found here: https://gist.github.com/Extremelyd1/4bcd495e21453ed9e1dffa27f6ba5f69
GetKeyJustPressed
boolean GetKeyJustPressed(keycodeString: string)
Returns true if the key was just pressed this frame, otherwise returns false
Argument
Type
Comment
keycodeString
string
is the name of the desired key, like "P" or "RightShift". Full list can be found here: https://gist.github.com/Extremelyd1/4bcd495e21453ed9e1dffa27f6ba5f69
GetMouseButtonDown
boolean GetMouseButtonDown(mouseButton: integer)
Returns true if the button is currently held down, otherwise returns false
Argument
Type
Comment
mouseButton
integer
is the value of the desired mouse button: 0 is the primary button, 1 is the secondary button, and 2 is the middle button
Evaluates and runs the given lua string after a delay
NOTE: the given lua string must be formatted exactly as it would be written in a lua script, so you may need to use escape characters.
Argument
Type
Comment
luaString
string
is the lua string to be executed
delaySeconds
number
is the number of seconds to wait before executing the string
SetGameInputActive
nil SetGameInputActive(isActive: boolean)
Enables or disables normal game input completely
Argument
Type
Comment
isActive
boolean
determines if normal game input is active or not
SetIgnoreGameInputKey
nil SetIgnoreGameInputKey(keycodeString: string)
After being set, holding down this key will cause normal game input to be ignored
Argument
Type
Comment
keycodeString
string
is the name of the desired key, like "P" or "RightShift". Full list can be found here: https://gist.github.com/Extremelyd1/4bcd495e21453ed9e1dffa27f6ba5f69
After being set, holding down this key will cause normal game input to be ignored
Argument
Type
Comment
keycodeNumber
integer
is the integer value of the desired key, like 112 for "P" or 303 for "RightShift". Full list can be found here: https://gist.github.com/Extremelyd1/4bcd495e21453ed9e1dffa27f6ba5f69
Unique name that is used to identify the vehicle type. See Vehicle Addressable Names table in Appendix for list of all vehicle addressable names.
filename
string
is the name of the png file located in the same directory as the lua script.
displayName
string
is the name that will appear in the dropdown when selecting vehicle skins.
flagColor
string
Default color to use for flag and checkpoints. Format: #RRGGBBAA
id
string
is an id for this skin. If you have multiple textures in your mod, they must have unique id values. If you edit your mod after uploading, do not change this id value.
GetVehicleAcceleration
number GetVehicleAcceleration(id: string)
Returns the acceleration of the vehicle (float)
Argument
Type
Comment
id
string
is the id of the vehicle, usually obtained from GetVehicleIds()
Return
Type
Comment
acceleration
number
the acceleration of the vehicle
GetVehicleBrakingForce
number GetVehicleBrakingForce(id: string)
Returns the braking force of the vehicle (float)
Argument
Type
Comment
id
string
is the id of the vehicle, usually obtained from GetVehicleIds()
Return
Type
Comment
brakingForce
number
the braking force of the vehicle
GetVehicleFlippedDirection
boolean GetVehicleFlippedDirection(id: string)
Returns true if the vehicle is flipped (facing left), otherwise returns false
Argument
Type
Comment
id
string
is the id of the vehicle, usually obtained from GetVehicleIds()
Return
Type
Comment
isFlipped
boolean
true if the vehicle is flipped (facing left), otherwise returns false
GetVehicleGameState
string GetVehicleGameState(id: string)
Returns string representing vehicle game state: "REACHED_FLAG", "UNDERWATER", "DRIVING", "WAITING_START", "WAITING_CHECKPOINT", or "WAITING_BUILD_MODE"
Argument
Type
Comment
id
string
is the id of the vehicle, usually obtained from GetVehicleIds()
Return
Type
Comment
state
string
string representing vehicle game state: "REACHED_FLAG", "UNDERWATER", "DRIVING", "WAITING_START", "WAITING_CHECKPOINT", or "WAITING_BUILD_MODE"
GetVehicleHorsepower
number GetVehicleHorsepower(id: string)
Returns the horsepower of the vehicle (float)
Argument
Type
Comment
id
string
is the id of the vehicle, usually obtained from GetVehicleIds()
Return
Type
Comment
horsepower
number
the horsepower of the vehicle
GetVehicleIdleDownhill
boolean GetVehicleIdleDownhill(id: string)
Returns true if the idle downhill setting is true on the vehicle, otherwise returns false
Argument
Type
Comment
id
string
is the id of the vehicle, usually obtained from GetVehicleIds()
Return
Type
Comment
idleDownhill
boolean
true if the idle downhill setting is true on the vehicle, otherwise returns false
GetVehicleIds
integer[] GetVehicleIds()
Returns a list of id strings for all currently active vehicles (List)
Return
Type
Comment
vehicleIds
integer[]
list of id strings for all currently active vehicles
GetVehicleMass
number GetVehicleMass(id: string)
Returns the mass of the vehicle (float)
Argument
Type
Comment
id
string
is the id of the vehicle, usually obtained from GetVehicleIds()
Return
Type
Comment
mass
number
the mass of the vehicle
GetVehiclePosition
Vec3 GetVehiclePosition(id: string)
Returns the current game world position of the vehicle as a float list of length 3 (corresponding to x, y, and z position) (List)
Argument
Type
Comment
id
string
is the id of the vehicle, usually obtained from GetVehicleIds()
GetVehicleRotation
Vec3 GetVehicleRotation(id: string)
Returns the current game world rotation of the vehicle as a float list of length 3 (corresponding to x, y, and z euler angles) (List)
Argument
Type
Comment
id
string
is the id of the vehicle, usually obtained from GetVehicleIds()
Return
Type
Comment
rotation
Vec3
the current game world rotation of the vehicle as a float list of length 3
GetVehicleSpeed
number GetVehicleSpeed(id: string)
Returns the current speed of the vehicle (float)
Argument
Type
Comment
id
string
is the id of the vehicle, usually obtained from GetVehicleIds()
Return
Type
Comment
speed
number
the current speed of the vehicle
GetVehicleTargetSpeed
number GetVehicleTargetSpeed(id: string)
Returns the target speed of the vehicle (float)
Argument
Type
Comment
id
string
is the id of the vehicle, usually obtained from GetVehicleIds()
Sets the position of the icon for the given world. Note that the X value is clamped between -125 and 125, and the Y value is clamped between -210 and 210.