Lua API Reference

Globals

field COBSCALE


is integer
[source]

table Encoding


Lua Encoding API

[source]


fn DecodeBase64 (text) -> decoded


Decodes a base64 string

[source]

Decodes a base64 encoded string. If it encounters invalid data, it stops and returns whatever it parsed so far.


Params

text: string --Text to decode

Returns

decoded: string --Decoded text

fn EncodeBase64 (text, stripPadding) -> encoded


Encodes a base64 string

[source]


Params

text: string --Text to encode
stripPadding: boolean? --Remove padding (`=` characters) at the end when 'true'. Defaults to `true`.

Returns

encoded: string --Encoded text

fn IsValidBase64 (text) -> valid


Validates a base64 string

[source]


Params

text: string --Text to validate

Returns

valid: boolean --Whether the text is valid base64

fn DecodeBase64Url (text) -> decoded


Decodes a base64url string

[source]

Decodes a base64url encoded string. If it encounters invalid data, it stops and returns whatever it parsed so far.


Params

text: string --Text to decode

Returns

decoded: string --Decoded text

fn EncodeBase64Url (text) -> encoded


Encodes a base64url string

[source]


Params

text: string --Text to encode

Returns

encoded: string --Encoded text

fn IsValidBase64Url (text) -> valid


Validates a base64url string

[source]


Params

text: string --Text to validate

Returns

valid: boolean --Whether the text is valid base64url

table Engine


Engine specific information.

[source]


field version


is string
“Major.Minor.PatchSet” for releases, “Major.Minor.PatchSet-CommitNum-gHash branch” otherwise

field versionFull


is string
“Major.Minor.PatchSet” for releases, “Major.Minor.PatchSet-CommitNum-gHash branch” otherwise. Will also include (buildFlags), if there’re any.

field versionMajor


is string
Major part of the named release version

field versionMinor


is string
Minor part of the named release version

field versionPatchSet


is string
Build number of the named release version

field commitsNumber


is string
Number of commits after the latest named release, non-zero indicates a “dev” build

field buildFlags


is string
Gets additional engine buildflags, e.g. “Debug” or “Sync-Debug”

field featureSupport


is FeatureSupport
Table containing various engine features as keys; use for cross-version compat

field wordSize


is number
Indicates the build type always 64 these days

field gameSpeed


is number
Number of simulation gameframes per second

field textColorCodes


is TextColorCode
Table containing keys that represent the color code operations during font rendering

table Game


Game specific information

[source]


field maxUnits


is number

field maxTeams


is number

field maxPlayers


is number

field squareSize


is number
Divide Game.mapSizeX or Game.mapSizeZ by this to get engine’s “mapDims” coordinates. The resolution of height, yard and type maps.

field metalMapSquareSize


is number
The resolution of metalmap (for use in API such as Spring.GetMetalAmount etc.)

field gameSpeed


is number
Number of simulation gameframes per second

field startPosType


is number

field ghostedBuildings


is boolean

field mapChecksum


is string

field modChecksum


is string

field mapDamage


is boolean

field mapName


is string

field mapDescription


is string
= string Game.mapHumanName

field mapHardness


is number

field mapX


is number

field mapY


is number

field mapSizeX


is number
in worldspace/opengl coords. Divide by Game.squareSize to get engine’s “mapDims” coordinates

field mapSizeZ


is number
in worldspace/opengl coords. Divide by Game.squareSize to get engine’s “mapDims” coordinates

field gravity


is number

field tidal


is number

field windMin


is number

field windMax


is number

field extractorRadius


is number

field waterDamage


is number

field envDamageTypes


is table
Containing {def}IDs of environmental-damage sources

field gameName


is string

field gameShortName


is string

field gameVersion


is string

field gameMutator


is string

field gameDesc


is string

field requireSonarUnderWater


is boolean

field transportAir


is number

field transportShip


is number

field transportHover


is number

field transportGround


is number

field fireAtKilled


is number

field fireAtCrashing


is number

field constructionDecay


is boolean

field reclaimAllowEnemies


is boolean

field reclaimAllowAllies


is boolean

field constructionDecayTime


is number

field constructionDecaySpeed


is number

field multiReclaim


is number

field reclaimMethod


is number

field reclaimUnitMethod


is number

field reclaimUnitEnergyCostFactor


is number

field reclaimUnitEfficiency


is number

field reclaimFeatureEnergyCostFactor


is number

field repairEnergyCostFactor


is number

field resurrectEnergyCostFactor


is number

field captureEnergyCostFactor


is number

field springCategories


is table<string,integer>
    example: {
      ["vtol"]         = 0,  ["special"]      = 1,  ["noweapon"]     = 2,
      ["notair"]       = 3,  ["notsub"]       = 4,  ["all"]          = 5,
      ["weapon"]       = 6,  ["notship"]      = 7,  ["notland"]      = 8,
      ["mobile"]       = 9,  ["kbot"]         = 10, ["antigator"]    = 11,
      ["tank"]         = 12, ["plant"]        = 13, ["ship"]         = 14,
      ["antiemg"]      = 15, ["antilaser"]    = 16, ["antiflame"]    = 17,
      ["underwater"]   = 18, ["hover"]        = 19, ["phib"]         = 20,
      ["constr"]       = 21, ["strategic"]    = 22, ["commander"]    = 23,
      ["paral"]        = 24, ["jam"]          = 25, ["mine"]         = 26,
      ["kamikaze"]     = 27, ["minelayer"]    = 28, ["notstructure"] = 29,
      ["air"]          = 30
    }

field armorTypes


is table<(string|integer),(integer|string)>

(bidirectional)

    example: {
      [1]  = amphibious,   [2] = anniddm,     [3] = antibomber,
      [4]  = antifighter,  [5] = antiraider,  [6] = atl,
      [7]  = blackhydra,   [8] = bombers,     [9] = commanders,
      [10] = crawlingbombs, ...

      ["amphibious"]   = 1, ["anniddm"]    = 2, ["antibomber"] = 3
      ["antifighter"]  = 4, ["antiraider"] = 5, ["atl"]        = 6
      ["blackhydra"]   = 7, ["bombers"]    = 8, ["commanders"] = 9
      ["crawlingbombs"]= 10, ...
    }

field textColorCodes


is TextColorCode
Table containing keys that represent the color code operations during font rendering

table gl


Callouts for OpenGL API

Only setters and getters for OpenGL usage in Recoil, see GL for constants.

[source]


See: GL

fn AddFallbackFont (filePath) -> success


Adds a fallback font for the font rendering engine.

Fonts added first will have higher priority. When a glyph isn’t found when rendering a font, the fallback fonts will be searched first, otherwise os fonts will be used.

The application should listen for the unsynced ‘FontsChanged’ callin so modules can clear any already reserved display lists or other relevant caches.

Note the callin won’t be executed at the time of calling this method, but later, on the Update cycle (before other Update and Draw callins).

[source]


Params

filePath: string --VFS path to the file, for example "fonts/myfont.ttf". Uses VFS.RAW_FIRST access mode.

Returns

success: boolean

fn ClearFallbackFonts () ->


Clears all fallback fonts.

See the note at ‘AddFallbackFont’ about the ‘FontsChanged’ callin, it also applies when calling this method.

[source]


Returns

: nil

fn GetVAO () -> vao


Example:

local myVAO = gl.GetVAO()
if myVAO == nil then Spring.Echo("Failed to get VAO") end

[source]


Returns

vao: VAO? --The VAO ref on success, else `nil`

fn CreateFBO (fboDesc) -> fbo


[source]

Params

fboDesc: FBODescription

Returns

fbo: FBO

fn DeleteFBO (fbo)


This doesn’t delete the attached objects!

[source]


Params

fbo: FBO

fn IsValidFBO (fbo, target) -> valid, status


[source]

Params

fbo: FBO
target: GL?

Returns

valid: boolean
status: number?

fn ActiveFBO (fbo, func, ...)


[source]

Params

fbo: FBO
func: fun(…)
...: any --args

fn ActiveFBO (fbo, target, func, ...)


[source]

Params

fbo: FBO
target: GL?
func: fun(…)
...: any --args

fn RawBindFBO (fbo, target, rawFboId) ->


Bind default or specified via rawFboId numeric id of FBO

[source]


Params

fbo: nil
target: GL? --(Default: `GL_FRAMEBUFFER_EXT`)
rawFboId: integer? --(Default: `0`)

Returns

: nil

fn RawBindFBO (fbo, target) -> previouslyBoundRawFboId


[source]

Params

fbo: FBO
target: GL? --(Default: `fbo.target`)

Returns

previouslyBoundRawFboId: number

fn BlitFBO (x0Src, y0Src, x1Src, y1Src, x0Dst, y0Dst, x1Dst, y1Dst, mask, filter)


needs GLAD_GL_EXT_framebuffer_blit

[source]


Params

x0Src: number
y0Src: number
x1Src: number
y1Src: number
x0Dst: number
y0Dst: number
x1Dst: number
y1Dst: number
mask: number? --(Default: GL_COLOR_BUFFER_BIT)
filter: number? --(Default: GL_NEAREST)

fn BlitFBO (fboSrc, x0Src, y0Src, x1Src, y1Src, fboDst, x0Dst, y0Dst, x1Dst, y1Dst, mask, filter)


needs GLAD_GL_EXT_framebuffer_blit

[source]


Params

fboSrc: FBO
x0Src: number
y0Src: number
x1Src: number
y1Src: number
fboDst: FBO
x0Dst: number
y0Dst: number
x1Dst: number
y1Dst: number
mask: number? --(Default: GL_COLOR_BUFFER_BIT)
filter: number? --(Default: GL_NEAREST)

fn ClearAttachmentFBO (target, attachment, clearValue0, clearValue1, clearValue2, clearValue3) -> success


needs Platform.glVersionNum >= 30 Clears the “attachment” of the currently bound FBO type “target” with “clearValues”

[source]


Params

target: number? --(Default: `GL.FRAMEBUFFER`)
attachment: (GL|Attachment) --(e.g. `"color0"` or `GL.COLOR_ATTACHMENT0`)
clearValue0: number? --(Default: `0`)
clearValue1: number? --(Default: `0`)
clearValue2: number? --(Default: `0`)
clearValue3: number? --(Default: `0`)

Returns

success: boolean

fn HasExtension (ext) ->


[source]

Params

ext: string

Returns

: boolean

fn GetNumber (pname, count) ->


Get the value or values of a selected parameter.

[source]


Params

pname: GL
count: integer? --(Default: `1`) Number of values to return, in range [1, 64].

Returns

: number …

fn GetString (pname)


Get a string describing the current OpenGL connection.

[source]


Params

pname: GL

fn GetScreenViewTrans () -> x, y, z


[source]

Returns

x: number
y: number
z: number

fn GetViewSizes () -> x, y


[source]

Returns

x: number
y: number

fn GetViewRange () -> nearPlaneDist, farPlaneDist, minViewRange, maxViewRange


[source]

Returns

nearPlaneDist: number
farPlaneDist: number
minViewRange: number
maxViewRange: number

fn SlaveMiniMap (newMode)


[source]

Params

newMode: boolean

fn ConfigMiniMap (px, py, sx, sy)


[source]

Params

px: integer
py: integer
sx: integer
sy: integer

fn DrawMiniMap (defaultTransform)


[source]

Params

defaultTransform: boolean? --(Default: `true`)

fn BeginText (userDefinedBlending)


Begin a block of text commands.

[source]

Text can be drawn without Start/End, but when doing several operations it’s more optimal if done inside a block.

Also allows disabling automatic setting of the blend mode. Otherwise the font will always print with BlendFunc(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA).


See: gl.BlendFunc gl.BlendFuncSeparate

Params

userDefinedBlending: boolean? --When `true` doesn't set the gl.BlendFunc automatically. Defaults to `false`.

fn EndText ()


[source]

fn Text (text, x, y, size, options) ->


[source]

Params

text: string
x: number
y: number
size: number
options: string? --concatenated string of option characters. - horizontal alignment: - 'c' = center - 'r' = right - vertical alignment: - 'a' = ascender - 't' = top - 'v' = vertical center - 'x' = baseline - 'b' = bottom - 'd' = descender - decorations: - 'o' = black outline - 'O' = white outline - 's' = shadow - other: - 'n' = don't round vertex coords to nearest integer (font may get blurry)

Returns

: nil

fn GetTextWidth (text) -> width


[source]

Params

text: string

Returns

width: number

fn GetTextHeight (text) -> height, descender, lines


[source]

Params

text: string

Returns

height: number
descender: number
lines: integer

fn Unit (unitID, doRawDraw, useLuaMat, noLuaCall, fullModel)


Draw the unit, applying transform.

[source]


Params

unitID: integer
doRawDraw: boolean? --(Default: `false`)
useLuaMat: integer?
noLuaCall: boolean? --(Default: `false`) Skip the `DrawUnit` callin.
fullModel: boolean? --(Default: `true`)

fn UnitRaw (unitID, doRawDraw, useLuaMat, noLuaCall, fullModel)


Draw the unit without applying transform.

Also skips the DrawUnit callin by default so any recursion is blocked.

[source]


Params

unitID: integer
doRawDraw: boolean? --(Default: `false`)
useLuaMat: integer?
noLuaCall: boolean? --(Default: `true`) Skip the `DrawUnit` callin.
fullModel: boolean? --(Default: `true`)

fn UnitTextures (unitID, push)


[source]

Params

unitID: integer
push: boolean --If `true`, push the render state; if `false`, pop it.

fn UnitShape (unitDefID, teamID, rawState, toScreen, opaque)


[source]

Params

unitDefID: integer
teamID: integer
rawState: boolean? --(Default: `true`)
toScreen: boolean? --(Default: `false`)
opaque: boolean? --(Default: `true`) If `true`, draw opaque; if `false`, draw alpha.

fn UnitShapeTextures (unitDefID, push)


[source]

Params

unitDefID: integer
push: boolean --If `true`, push the render state; if `false`, pop it.

fn UnitMultMatrix (unitID)


[source]

Params

unitID: integer

fn UnitPiece (unitID, pieceID)


[source]

Params

unitID: integer
pieceID: integer

fn UnitPieceMatrix (unitID, pieceID)


[source]

Params

unitID: integer
pieceID: integer

fn UnitPieceMultMatrix (unitID, pieceID)


[source]

Params

unitID: integer
pieceID: integer

fn Feature (featureID, doRawDraw, useLuaMat, noLuaCall)


Draw the feature, applying transform.

[source]


Params

featureID: integer
doRawDraw: boolean? --(Default: `false`)
useLuaMat: integer?
noLuaCall: boolean? --(Default: `false`) Skip the `DrawFeature` callin.

fn FeatureRaw (featureID, doRawDraw, useLuaMat, noLuaCall)


Draw the unit without applying transform.

Also skips the DrawFeature callin by default so any recursion is blocked.

[source]


Params

featureID: integer
doRawDraw: boolean? --(Default: `false`)
useLuaMat: integer?
noLuaCall: boolean? --(Default: `true`) Skip the `DrawFeature` callin.

fn FeatureTextures (featureID, push)


[source]

Params

featureID: integer
push: boolean --If `true`, push the render state; if `false`, pop it.

fn FeatureShape (featureDefID, teamID, rawState, toScreen, opaque)


[source]

Params

featureDefID: integer
teamID: integer
rawState: boolean? --(Default: `true`)
toScreen: boolean? --(Default: `false`)
opaque: boolean? --(Default: `true`) If `true`, draw opaque; if `false`, draw alpha.

fn FeatureShapeTextures (featureDefID, push)


[source]

Params

featureDefID: integer
push: boolean --If `true`, push the render state; if `false`, pop it.

fn FeatureMultMatrix (featureID)


[source]

Params

featureID: integer

fn FeaturePiece (featureID, pieceID)


[source]

Params

featureID: integer
pieceID: integer

fn FeaturePieceMatrix (featureID, pieceID)


[source]

Params

featureID: integer
pieceID: integer

fn FeaturePieceMultMatrix (featureID, pieceID)


[source]

Params

featureID: integer
pieceID: integer

fn DrawListAtUnit (unitID, listIndex, useMidPos, scaleX, scaleY, scaleZ, degrees, rotX, rotY, rotZ)


[source]

Params

unitID: integer
listIndex: integer
useMidPos: boolean? --(Default: `true`)
scaleX: number? --(Default: `1.0`)
scaleY: number? --(Default: `1.0`)
scaleZ: number? --(Default: `1.0`)
degrees: number? --(Default: `0.0`)
rotX: number? --(Default: `0.0`)
rotY: number? --(Default: `1.0`)
rotZ: number? --(Default: `0.0`)

fn DrawFuncAtUnit (unitID, useMidPos, fun, ...)


[source]

Params

unitID: integer
useMidPos: boolean? --(Default: `true`)
fun: unknown
...: any --Arguments passed to function.

fn DrawGroundCircle (posX, posY, posZ, radius, resolution)


[source]

Params

posX: number
posY: number
posZ: number
radius: number
resolution: integer

fn DrawGroundCircle (posX, posY, posZ, radius, resolution, slope, gravity, weaponDefID)


[source]

Params

posX: number
posY: number
posZ: number
radius: number
resolution: integer
slope: number
gravity: number
weaponDefID: integer

fn DrawGroundCircle (x0, z0, x1, z1, useNorm, useTxcd)


[source]

Params

x0: number
z0: number
x1: number
z1: number
useNorm: nil --No longer used.
useTxcd: boolean? --(Default: `false`)

fn DrawGroundCircle (x0, z0, x1, z1, useNorm, tu0, tv0, tu1, tv1)


[source]

Params

x0: number
z0: number
x1: number
z1: number
useNorm: nil --No longer used.
tu0: number
tv0: number
tu1: number
tv1: number

fn Shape (type, vertices)


[source]

Params

type: GL
vertices: VertexData[]

fn BeginEnd (primMode, fun, ...)


[source]

Params

primMode: GL
fun: unknown
...: any --Arguments passed to function.

fn Vertex (v)


[source]

Params

v: xy

fn Vertex (v)


[source]

Params

v: xyz

fn Vertex (v)


[source]

Params

v: xyzw

fn Vertex (x, y, z, w)


[source]

Params

x: number
y: number
z: number?
w: number?

fn Normal (v)


[source]

Params

v: xyz

fn Normal (x, y, z)


[source]

Params

x: number
y: number
z: number

fn TexCoord (coord)


[source]

Params

coord: (number)

fn TexCoord (coord)


[source]

Params

coord: xy

fn TexCoord (coord)


[source]

Params

coord: xyz

fn TexCoord (coord)


[source]

Params

coord: xyzw

fn TexCoord (s, t, r, q)


[source]

Params

s: number
t: number?
r: number?
q: number?

fn MultiTexCoord (texNum, coord)


[source]

Params

texNum: integer
coord: (number)

fn MultiTexCoord (texNum, coord)


[source]

Params

texNum: integer
coord: xy

fn MultiTexCoord (texNum, coord)


[source]

Params

texNum: integer
coord: xyz

fn MultiTexCoord (texNum, coord)


[source]

Params

texNum: integer
coord: xyzw

fn MultiTexCoord (texNum, s, t, r, q)


[source]

Params

texNum: integer
s: number
t: number?
r: number?
q: number?

fn SecondaryColor (color)


[source]

Params

color: rgb

fn SecondaryColor (r, g, b)


[source]

Params

r: number
g: number
b: number

fn FogCoord (coord)


[source]

Params

coord: number

fn EdgeFlag (flag)


[source]

Params

flag: boolean

fn Rect (x1, y1, x2, y2)


[source]

Params

x1: number
y1: number
x2: number
y2: number

fn Rect (x1, y1, x2, y2, flipSCoords, flipTCoords)


[source]

Params

x1: number
y1: number
x2: number
y2: number
flipSCoords: boolean?
flipTCoords: boolean?

fn Rect (x1, y1, x2, y2, s1, t1, s2, t2)


[source]

Params

x1: number
y1: number
x2: number
y2: number
s1: number
t1: number
s2: number
t2: number

fn DispatchCompute (numGroupX, numGroupY, numGroupZ, barriers)


[source]

Params

numGroupX: integer
numGroupY: integer
numGroupZ: integer
barriers: integer? --(Default: `4`)

fn MemoryBarrier (barriers)


[source]

Params

barriers: integer? --(Default: `4`)

fn Color (r, g, b, a)


[source]

Params

r: number --Red.
g: number --Green.
b: number --Blue.
a: number? --(Default: `1.0`) Alpha.

fn Color (color)


[source]

Params

color: rgba --Color with alpha.

fn Color (color)


[source]

Params

color: rgb --Color.

fn Material (material)


[source]

Params

material: Material

fn ResetState ()


[source]

fn ResetMatrices ()


[source]

fn Lighting (enable)


[source]

Params

enable: boolean

fn ShadeModel (model)


[source]

Params

model: GL

fn Scissor (enable)


[source]

Params

enable: boolean

fn Scissor (x, y, w, h)


[source]

Params

x: integer
y: integer
w: integer
h: integer

fn Viewport (x, y, w, h)


[source]

Params

x: integer
y: integer
w: integer
h: integer

fn ColorMask (rgba)


Enable or disable writing of frame buffer color components.

[source]


Params

rgba: boolean

fn ColorMask (red, green, blue, alpha)


Enable or disable writing of frame buffer color components.

[source]


Params

red: boolean
green: boolean
blue: boolean
alpha: boolean

fn DepthMask (enable)


Enable or disable writing into the depth buffer.

[source]


Params

enable: boolean

fn DepthTest (enable)


Enable or disable depth test.

[source]


Params

enable: boolean

fn DepthTest (depthFunction)


Enable depth test and specify the depth comparison function.

[source]


Params

depthFunction: GL

fn DepthClamp (enable)


[source]

Params

enable: boolean

fn Culling (enable)


[source]

Params

enable: boolean

fn Culling (mode)


Enable culling and set culling mode.

[source]


Params

mode: GL

fn LogicOp (enable)


[source]

Params

enable: boolean

fn LogicOp (opCode)


Specify a logical pixel operation for rendering.

[source]


Params

opCode: GL

fn Fog (enable)


[source]

Params

enable: boolean

fn Blending (enable)


[source]

Params

enable: boolean

fn Blending (mode)


[source]

Params

mode: (“add”|“alpha_add”|“alpha”|“reset”|“color”|“modulate”…)

fn Blending (src, dst)


[source]

Params

src: GL
dst: GL

fn BlendEquation (mode)


[source]

Params

mode: GL

fn BlendFunc (src, dst)


[source]

Params

src: GL
dst: GL

fn BlendEquationSeparate (modeRGB, modeAlpha)


[source]

Params

modeRGB: GL
modeAlpha: GL

fn BlendFuncSeparate (srcRGB, dstRGB, srcAlpha, dstAlpha)


[source]

Params

srcRGB: GL
dstRGB: GL
srcAlpha: GL
dstAlpha: GL

fn AlphaTest (enable)


[source]

Params

enable: boolean

fn AlphaTest (func, ref)


Specify the alpha test function.

[source]


Params

func: GL
ref: number

fn AlphaToCoverage (enable)


[source]

Params

enable: boolean

fn PolygonMode (face, mode)


Select polygon rasterization mode.

[source]


Params

face: GL
mode: GL

fn PolygonOffset (enable)


[source]

Params

enable: boolean

fn PolygonOffset (factor, units)


[source]

Params

factor: number
units: number

fn StencilTest (enable)


[source]

Params

enable: boolean

fn StencilMask (mask)


Control the front and back writing of individual bits in the stencil planes.

[source]


Params

mask: integer --Specifies a bit mask to enable and disable writing of individual bits in the stencil planes. Initially, the mask is all `1`'s.

fn StencilFunc (func, ref, mask)


Set front and back function and reference value for stencil testing.

[source]


Params

func: GL --Specifies the test function. Eight symbolic constants are valid: `GL.NEVER`, `GL.LESS`, `GL.EQUAL`, `GL.LEQUAL`, `GL.GREATER`, `GL.NOTEQUAL`, `GL.GEQUAL`, and `GL.ALWAYS`. The initial value is `GL.ALWAYS`.
ref: integer --Specifies the reference value for the stencil test. `ref` is clamped to the range `[0, 2^n - 1]`, where `n` is the number of bitplanes in the stencil buffer. The initial value is `0`.
mask: integer --Specifies a mask that is ANDed with both the reference value and the stored stencil value when the test is done. The initial value is all `1`'s.

fn StencilOp (fail, zfail, zpass)


Set front and back stencil test actions.

[source]


Params

fail: GL --Specifies the action to take when the stencil test fails. Eight symbolic constants are valid: `GL.KEEP`, `GL.ZERO`, `GL.REPLACE`, `GL.INCR`, `GL.INCR_WRAP`, `GL.DECR`, `GL.DECR_WRAP`, and `GL.INVERT`. The initial value is `GL.KEEP`.
zfail: GL --Specifies the stencil action when the stencil test passes, but the depth test fails. The initial value is `GL.KEEP`.
zpass: GL --Specifies the stencil action when both the stencil test and the depth test pass, or when the stencil test passes and either there is no depth buffer or depth testing is not enabled. The initial value is `GL.KEEP`.

fn StencilMaskSeparate (face, mask)


Control the front and back writing of individual bits in the stencil planes.

[source]


Params

face: GL --Specifies whether the front and/or back stencil writemask is updated. Three symbolic constants are accepted: `GL.FRONT`, `GL.BACK`, and `GL.FRONT_AND_BACK`. The initial value is `GL.FRONT_AND_BACK`.
mask: integer --Specifies a bit mask to enable and disable writing of individual bits in the stencil planes. Initially, the mask is all `1`'s.

fn StencilFuncSeparate (face, func, ref, mask)


Set front and/or back function and reference value for stencil testing.

[source]


Params

face: GL --Specifies whether front and/or back stencil state is updated. Three symbolic constants are accepted: `GL.FRONT`, `GL.BACK`, and `GL.FRONT_AND_BACK`. The initial value is `GL.FRONT_AND_BACK`.
func: GL --Specifies the test function. Eight symbolic constants are valid: `GL.NEVER`, `GL.LESS`, `GL.EQUAL`, `GL.LEQUAL`, `GL.GREATER`, `GL.NOTEQUAL`, `GL.GEQUAL`, and `GL.ALWAYS`. The initial value is `GL.ALWAYS`.
ref: integer --Specifies the reference value for the stencil test. `ref` is clamped to the range `[0, 2^n - 1]`, where `n` is the number of bitplanes in the stencil buffer. The initial value is `0`.
mask: integer --Specifies a mask that is ANDed with both the reference value and the stored stencil value when the test is done. The initial value is all `1`'s.

fn StencilOpSeparate (face, fail, zfail, zpass)


Set front and/or back stencil test actions.

[source]


Params

face: GL --Specifies whether front and/or back stencil state is updated. Three symbolic constants are accepted: `GL.FRONT`, `GL.BACK`, and `GL.FRONT_AND_BACK`. The initial value is `GL.FRONT_AND_BACK`.
fail: GL --Specifies the action to take when the stencil test fails. Eight symbolic constants are valid: `GL.KEEP`, `GL.ZERO`, `GL.REPLACE`, `GL.INCR`, `GL.INCR_WRAP`, `GL.DECR`, `GL.DECR_WRAP`, and `GL.INVERT`. The initial value is `GL.KEEP`.
zfail: GL --Specifies the stencil action when the stencil test passes, but the depth test fails. The initial value is `GL.KEEP`.
zpass: GL --Specifies the stencil action when both the stencil test and the depth test pass, or when the stencil test passes and either there is no depth buffer or depth testing is not enabled. The initial value is `GL.KEEP`.

fn LineStipple (enable)


[source]

Params

enable: boolean

fn LineStipple (ignoredString)


[source]

Params

ignoredString: string --The value of this string is ignored, but it still does something.

fn LineStipple (factor, pattern, shift)


[source]

Params

factor: integer
pattern: integer
shift: integer?

fn LineWidth (width)


[source]

Params

width: number

fn PointSize (size)


[source]

Params

size: number

fn PointSprite (enable, enableCoordReplace, coordOrigin)


[source]

Params

enable: boolean
enableCoordReplace: boolean?
coordOrigin: boolean? --`true` for upper left, `false` for lower left, otherwise no change.

fn PointParameter (atten0, atten1, atten2, sizeMin, sizeMax, sizeFade)


[source]

Params

atten0: number
atten1: number
atten2: number
sizeMin: number?
sizeMax: number?
sizeFade: number?

fn Texture (texNum, enable) ->


[source]

Params

texNum: integer
enable: boolean?

Returns

: boolean

fn Texture (enable) ->


[source]

Params

enable: boolean

Returns

: boolean

fn Texture (texNum, image) ->


[source]

Params

texNum: integer
image: string

Returns

: boolean

fn Texture (image) ->


[source]

Params

image: string

Returns

: boolean

fn CreateTexture (xsize, ysize, texture) -> texName


[source]

Params

xsize: integer
ysize: integer
texture: Texture

Returns

texName: string?

fn CreateTexture (xsize, ysize, zsize, texture) -> texName


[source]

Params

xsize: integer
ysize: integer
zsize: integer
texture: Texture

Returns

texName: string?

fn ChangeTextureParams (texName, params)


[source]

Params

texName: string
params: Texture

fn DeleteTexture (texName) ->


[source]

Params

texName: string

Returns

: boolean

fn DeleteTextureFBO (texName) ->


[source]

Params

texName: string

Returns

: boolean

fn TextureInfo (texName) -> textureInfo


[source]

Params

texName: string

Returns

textureInfo: TextureInfo

fn CopyToTexture (texName, xoff, yoff, x, y, w, h, target, level)


[source]

Params

texName: string
xoff: integer
yoff: integer
x: integer
y: integer
w: integer
h: integer
target: GL?
level: GL?

fn RenderToTexture (texName, fun, ...)


[source]

Params

texName: string
fun: unknown
...: any --Arguments to the function.

fn GenerateMipmap (texName)


[source]

Params

texName: string

fn ActiveTexture (texNum, func, ...)


[source]

Params

texNum: integer
func: function
...: any --Arguments to the function.

fn TextEnv (target, pname, value)


[source]

Params

target: GL
pname: GL
value: number

fn TextEnv (target, pname, r, g, b, a)


[source]

Params

target: GL
pname: GL
r: number? --(Default: `0.0`)
g: number? --(Default: `0.0`)
b: number? --(Default: `0.0`)
a: number? --(Default: `0.0`)

fn MultiTexEnv (texNum, target, pname, value)


[source]

Params

texNum: integer
target: GL
pname: GL
value: number

fn MultiTexEnv (texNum, target, pname, r, g, b, a)


[source]

Params

texNum: integer
target: GL
pname: GL
r: number? --(Default: `0.0`)
g: number? --(Default: `0.0`)
b: number? --(Default: `0.0`)
a: number? --(Default: `0.0`)

fn TexGen (target, state)


[source]

Params

target: GL
state: boolean

fn TexGen (target, pname, value)


[source]

Params

target: GL
pname: GL
value: number

fn TexGen (target, pname, r, g, b, a)


[source]

Params

target: GL
pname: GL
r: number? --(Default: `0.0`)
g: number? --(Default: `0.0`)
b: number? --(Default: `0.0`)
a: number? --(Default: `0.0`)

fn MultiTexGen (texNum, target, state)


[source]

Params

texNum: integer
target: GL
state: boolean

fn MultiTexGen (texNum, target, pname, value)


[source]

Params

texNum: integer
target: GL
pname: GL
value: number

fn MultiTexGen (texNum, target, pname, r, g, b, a)


[source]

Params

texNum: integer
target: GL
pname: GL
r: number? --(Default: `0.0`)
g: number? --(Default: `0.0`)
b: number? --(Default: `0.0`)
a: number? --(Default: `0.0`)

fn BindImageTexture (unit, texID, level, layer, access, format)


[source]

For format parameters refer to https://registry.khronos.org/OpenGL-Refpages/gl4/html/glBindImageTexture.xhtml and https://beyond-all-reason.github.io/RecoilEngine/lua-api/types/GL#rgba32f

Example uses local my_texture_id = gl.CreateTexture(…)

– bind layer 1 of my_texture_id if it supports layered bindings to image unit 0 gl.BindImageTexture(0, my_texture_id, 0, 1, GL.READ_WRITE, GL.RGBA16F)

– bind all layers of my_texture_id if it supports layered bindings to image unit 0 gl.BindImageTexture(0, my_texture_id, 0, nil, GL.READ_WRITE, GL.RGBA16F)

– unbind any texture attached to image unit 0 gl.BindImageTexture(0, nil, nil, nil, nil, GL.RGBA16F)


Params

unit: integer
texID: string? --(nil breaks any existing binding to the image unit)
level: integer? --(Default: 0)
layer: integer? --(nil binds the entire texture(array/cube), an integer binds a specific layer, ignored by gl if the texture does not support layered bindings)
access: GL? --(Default: GL.READ_WRITE) Accepts `GL.READ_ONLY`, `GL.WRITE_ONLY` or `GL.READ_WRITE`.
format: integer --(Example: GL.RGBA16F)

fn CreateTextureAtlas (xsize, ysize, allocType) -> texName


[source]

Params

xsize: integer
ysize: integer
allocType: integer?

Returns

texName: string

fn FinalizeTextureAtlas (texName) ->


[source]

Params

texName: string

Returns

: boolean

fn DeleteTextureAtlas (texName) ->


[source]

Params

texName: string

Returns

: boolean

fn AddAtlasTexture (texName, subAtlasTexName)


[source]

Params

texName: string
subAtlasTexName: string

fn GetAtlasTexture (texName, subAtlasTexName) -> x1, x2, y1, y2


[source]

Params

texName: string
subAtlasTexName: string

Returns

x1: number
x2: number
y1: number
y2: number

fn GetEngineAtlasTextures (atlasName) -> atlasTextures


[source]

Params

atlasName: ("$explosions"|"$groundfx")

Returns

atlasTextures: table<string,float4> --Table of x1,x2,y1,y2 coordinates by texture name.

fn Clear (bits, val)


[source]

Params

bits: GL --`GL.DEPTH_BUFFER_BIT` or `GL.STENCIL_BUFFER_BIT`.
val: number

fn Clear (bits, r, g, b, a)


[source]

Params

bits: GL --`GL.COLOR_BUFFER_BIT` or `GL.ACCUM_BUFFER_BIT`.
r: number
g: number
b: number
a: number

fn SwapBuffers ()


[source]

fn Translate (x, y, z)


[source]

Params

x: number
y: number
z: number

fn Scale (x, y, z)


[source]

Params

x: number
y: number
z: number

fn Rotate (r, x, y, z)


[source]

Params

r: number
x: number
y: number
z: number

fn Ortho (left, right, bottom, top, near, far)


[source]

Params

left: number
right: number
bottom: number
top: number
near: number
far: number

fn Frustum (left, right, bottom, top, near, far)


[source]

Params

left: number
right: number
bottom: number
top: number
near: number
far: number

fn Billboard ()


[source]

fn Light (light, enable)


[source]

Params

light: integer
enable: boolean

fn Light (light, pname, param)


[source]

Params

light: integer
pname: GL
param: GL

fn Light (light, pname, r, g, b, a)


[source]

Params

light: integer
pname: GL
r: number
g: number
b: number
a: number?

fn ClipPlane (plane, enable)


[source]

Params

plane: integer
enable: boolean

fn ClipPlane (plane, equation0, equation1, equation2, equation3)


[source]

Params

plane: integer
equation0: number
equation1: number
equation2: number
equation3: number

fn ClipDistance (clipId, enable)


[source]

Params

clipId: integer
enable: boolean

fn MatrixMode (mode)


[source]

Params

mode: GL

fn LoadIdentity ()


[source]

fn LoadMatrix (matrix)


[source]

Params

matrix: string

fn LoadMatrix (matrix)


[source]

Params

matrix: Matrix4x4

fn LoadMatrix () -> m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44


[source]

Returns

m11: number
m12: number
m13: number
m14: number
m21: number
m22: number
m23: number
m24: number
m31: number
m32: number
m33: number
m34: number
m41: number
m42: number
m43: number
m44: number

fn MultMatrix (matrixName)


[source]

Params

matrixName: string

fn MultMatrix (matrix)


[source]

Params

matrix: Matrix4x4

fn MultMatrix (m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44)


[source]

Params

m11: number
m12: number
m13: number
m14: number
m21: number
m22: number
m23: number
m24: number
m31: number
m32: number
m33: number
m34: number
m41: number
m42: number
m43: number
m44: number

fn PushMatrix ()


[source]

fn PopMatrix ()


[source]

fn PushPopMatrix (matMode1, func, ...)


[source]

Params

matMode1: GL
func: fun()
...: any --Arguments to the function.

fn PushPopMatrix (func, ...)


[source]

Params

func: fun()
...: any --Arguments to the function.

fn GetMatrixData (type, index) -> The


Get value at index of matrix.

[source]


Params

type: GL --Matrix type (`GL.PROJECTION`, `GL.MODELVIEW`, `GL.TEXTURE`).
index: integer --Matrix index in range `[1, 16]`.

Returns

The: number --value.

fn GetMatrixData (type) -> The


[source]

Params

type: GL --Matrix type (`GL.PROJECTION`, `GL.MODELVIEW`, `GL.TEXTURE`).

Returns

The: Matrix4x4 --matrix.

fn GetMatrixData (index) -> The


[source]

Params

index: integer --Matrix index in range `[1, 16]`.

Returns

The: number --value.

fn GetMatrixData (name) -> The


[source]

Params

name: MatrixName --The matrix name.

Returns

The: Matrix4x4 --matrix.

fn PushAttrib (mask)


[source]

Params

mask: GL? --(Default: `GL.ALL_ATTRIB_BITS`)

fn PopAttrib ()


[source]

fn UnsafeState (state, func, ...)


[source]

Params

state: GL
func: fun()
...: any --Arguments to the function.

fn UnsafeState (state, reverse, func, ...)


[source]

Params

state: GL
reverse: boolean
func: fun()
...: any --Arguments to the function.

fn GetFixedState (param, toStr) -> enabled, values


[source]

Params

param: string
toStr: boolean? --(Default: `false`)

Returns

enabled: boolean
values: any …

fn CreateList (func, ...)


[source]

Params

func: fun()
...: any --Arguments to the function.

fn CallList (listIndex)


[source]

Params

listIndex: integer

fn DeleteList (listIndex)


[source]

Params

listIndex: integer

fn Flush ()


[source]

fn Finish ()


[source]

fn ReadPixels (x, y, w, h, format) -> Color


Get single pixel.

[source]


Params

x: integer
y: integer
w: 1
h: 1
format: GL? --(Default: `GL.RGBA`)

Returns

Color: number … --values (color size based on format).

fn ReadPixels (x, y, w, h, format) -> Column


Get column of pixels.

[source]


Params

x: integer
y: integer
w: 1
h: integer
format: GL? --(Default: `GL.RGBA`)

Returns

Column: number[][] --of color values (color size based on format).

fn ReadPixels (x, y, w, h, format) -> Row


Get row of pixels.

[source]


Params

x: integer
y: integer
w: integer
h: 1
format: GL? --(Default: `GL.RGBA`)

Returns

Row: number[][] --of color values (color size based on format).

fn ReadPixels (x, y, w, h, format) -> Array


Get row of pixels.

[source]


Params

x: integer
y: integer
w: integer
h: integer
format: GL? --(Default: `GL.RGBA`)

Returns

Array: number[][][] --of columns of color values (color size based on format).

fn SaveImage (x, y, width, height, filename, options) -> success


[source]

Params

x: integer
y: integer
width: integer
height: integer
filename: string
options: SaveImageOptions?

Returns

success: boolean?

fn CreateQuery () -> query


[source]

Returns

query: any

fn DeleteQuery (query)


[source]

Params

query: any

fn RunQuery (query)


[source]

Params

query: any

fn GetQuery (query) -> count


[source]

Params

query: any

Returns

count: integer

fn GetGlobalTexNames () -> List


[source]

Returns

List: string[] --of texture names.

fn GetGlobalTexCoords () -> xstart, ystart, xend, yend


[source]

Returns

xstart: number
ystart: number
xend: number
yend: number

fn GetShadowMapParams () -> x, y, z, w


[source]

Returns

x: number
y: number
z: number
w: number

fn GetAtmosphere () -> lightDirX, lightDirY, lightDirZ


[source]

Returns

lightDirX: number
lightDirY: number
lightDirZ: number

fn GetAtmosphere (param) ->


[source]

Params

param: (“fogStart”|“fogEnd”|“pos”|“fogColor”|“skyColor”|“sunColor”…)

Returns

: any …

fn GetSun () -> lightDirX, lightDirY, lightDirZ


[source]

Returns

lightDirX: number
lightDirY: number
lightDirZ: number

fn GetSun (param, mode) -> data1, data2, data3


[source]

Params

param: (“pos”|“dir”|“specularExponent”|“shadowDensity”|“diffuse”|“ambient”…)
mode: (“ground”|“unit”) --(Default: `"ground"`)

Returns

data1: number?
data2: number?
data3: number?

fn GetWaterRendering (key) -> value


[source]

Params

key: string

Returns

value: any …

fn GetMapRendering (key) -> value


[source]

Params

key: string

Returns

value: any …

fn ObjectLabel (objectTypeIdentifier, objectID, label)


Labels an object for use with debugging tools. May be unavailable and nil if the platform doesn’t support the feature.

[source]


Params

objectTypeIdentifier: GL --Specifies the type of object being labeled.
objectID: integer --Specifies the name or ID of the object to label.
label: string --A string containing the label to be assigned to the object.

fn PushDebugGroup (id, message, sourceIsThirdParty) ->


Pushes a debug marker for debugging tools such as nVidia nSight 2024.04, see https://registry.khronos.org/OpenGL-Refpages/gl4/html/glPushDebugGroup.xhtml .

May be unavailable and nil if the platform doesn’t support the feature.

Groups are basically named scopes similar to tracy’s, and are pushed/popped independently from GL attribute/matrix push/pop (though of course makes sense to put them together).

Tools are known to struggle to see the annotation for FBOs if they are raw bound.

[source]


Params

id: integer --A numeric identifier for the group, can be any unique number.
message: string --A human-readable string describing the debug group. Will be truncated if longer than driver-specific limit
sourceIsThirdParty: boolean --Set the source tag, true for GL_DEBUG_SOURCE_THIRD_PARTY, false for GL_DEBUG_SOURCE_APPLICATION. default false

Returns

: nil

fn PopDebugGroup () ->


Pops the most recent GL debug group from the stack (does NOT take the numerical ID from push). May be unavailable and nil if the platform doesn’t support the feature.

[source]


Returns

: nil

fn GetShaderLog () -> infoLog


Returns the shader compilation error log. This is empty if the shader linking failed, in that case, check your in/out blocks and ensure they match.

[source]


Returns

infoLog: string

fn CreateShader (shaderParams) -> shaderID


Create a shader.

[source]


Params

shaderParams: ShaderParams

Returns

shaderID: integer

fn DeleteShader (shaderID)


Deletes a shader identified by shaderID

[source]


Params

shaderID: integer

fn UseShader (shaderID) -> linked


Binds a shader program identified by shaderID. Pass 0 to disable the shader. Returns whether the shader was successfully bound.

[source]


Params

shaderID: integer

Returns

linked: boolean

fn ActiveShader (shaderID, func, ...)


Binds a shader program identified by shaderID, and calls the Lua func with the specified arguments.

Can be used in NON-drawing events (to update uniforms etc.)!

[source]


Params

shaderID: integer
func: function
...: any --Arguments

fn GetActiveUniforms (shaderID) -> activeUniforms


Query the active (actually used) uniforms of a shader and identify their names, types (float, int, uint) and sizes (float, vec4, …).

[source]


Params

shaderID: integer

Returns

activeUniforms: ActiveUniform[]

fn GetUniformLocation (shaderID, name) -> locationID


Returns the locationID of a shaders uniform. Needed for changing uniform values with function gl.Uniform.

[source]


Params

shaderID: integer
name: string

Returns

locationID: GL

fn Uniform (locationID, f1, f2, f3, f4)


Sets the uniform float value at the locationID for the currently active shader. Shader must be activated before setting uniforms.

[source]


Params

locationID: (GL|string) --uniformName
f1: number
f2: number?
f3: number?
f4: number?

fn UniformInt (locationID, int1, int2, int3, int4)


Sets the uniform int value at the locationID for the currently active shader. Shader must be activated before setting uniforms.

[source]


Params

locationID: (integer|string) --uniformName
int1: integer
int2: integer?
int3: integer?
int4: integer?

fn UniformArray (locationID, type, uniforms)


Sets the an array of uniform values at the locationID for the currently active shader.

Shader must be activated before setting uniforms.

[source]


Params

locationID: (integer|string) --uniformName
type: UniformArrayType
uniforms: number[] --Array up to 1024 elements

fn UniformMatrix (locationID, matrix)


Sets the a uniform mat4 locationID for the currently active shader.

Shader must be activated before setting uniforms.

Can set one one common matrix like shadow, or by passing 16 additional numbers for the matrix.

[source]


Params

locationID: (integer|string) --uniformName
matrix: MatrixName --Name of common matrix.

fn UniformMatrix (locationID, matrix)


Sets the a uniform mat4 locationID for the currently active shader.

Shader must be activated before setting uniforms.

Can set one one common matrix like shadow, or by passing 16 additional numbers for the matrix.

[source]


Params

locationID: (integer|string) --uniformName
matrix: number[] --A 2x2, 3x3 or 4x4 matrix.

fn GetEngineUniformBufferDef (index) -> glslDefinition


[source]

Return the GLSL compliant definition of UniformMatricesBuffer(idx=0) or UniformParamsBuffer(idx=1) structure.


Params

index: number

Returns

glslDefinition: string

fn GetEngineModelUniformDataDef (index) -> glslDefinition


[source]

Return the GLSL compliant definition of ModelUniformData structure (per Unit/Feature buffer available on GPU)


Params

index: number

Returns

glslDefinition: string

fn GetEngineModelUniformDataSize (index) -> sizeInElements, sizeInBytesOnCPU


[source]

Return the current size values of ModelUniformData structure (per Unit/Feature buffer available on GPU)


Params

index: number

Returns

sizeInElements: number
sizeInBytesOnCPU: number

fn SetGeometryShaderParameter (shaderID, key, value) ->


Sets the Geometry shader parameters for shaderID. Needed by geometry shader programs (check the opengl GL_ARB_geometry_shader4 extension for glProgramParameteri)

[source]


Params

shaderID: integer
key: number
value: number

Returns

: nil

fn SetTesselationShaderParameter (param, value) ->


Sets the tesselation shader parameters for shaderID.

Needed by tesselation shader programs. (Check the opengl GL_ARB_tessellation_shader extension for glProgramParameteri).

[source]


Params

param: integer
value: integer

Returns

: nil

fn CreateRBO (xsize, ysize, data) ->


[source]

Params

xsize: integer
ysize: integer
data: CreateRBOData

Returns

: RBO

fn DeleteRBO (rbo)


[source]

Params

rbo: RBO

fn GetVBO (bufferType, freqUpdated) -> VBO


Example:

local myVBO = gl.GetVBO()
if myVBO == nil then Spring.Echo("Failed to get VBO") end

[source]


See: GL.OpenGL_Buffer_Types

Params

bufferType: GL? --(Default: `GL.ARRAY_BUFFER`) The buffer type to use. Accepts the following: - `GL.ARRAY_BUFFER` for vertex data. - `GL.ELEMENT_ARRAY_BUFFER` for vertex indices. - `GL.UNIFORM_BUFFER` - `GL.SHADER_STORAGE_BUFFER`
freqUpdated: boolean? --(Default: `true`) `true` to updated frequently, `false` to update only once.

Returns

VBO: VBO?

table Platform


Platform specific information

[source]


field gpu


is string
[source] Full GPU device name

field gpuVendor


is (“Nvidia”|“Intel”|“ATI”|“Mesa”|“Unknown”)
[source]

field gpuMemorySize


is number
[source] Size of total GPU memory in MBs; only available for “Nvidia”, (rest are 0)

field glVersionShort


is string
[source] major.minor.buildNumber

field glVersionNum


is integer
[source]

field glslVersionShort


is string
[source] major.minor

field glslVersionNum


is string
[source]

field glVersion


is string
[source] Full version

field glVendor


is string
[source]

field glRenderer


is string
[source]

field glslVersion


is string
[source] Full version

field gladVersion


is string
[source]

field glewVersion


is string
[source]

field sdlVersionCompiledMajor


is number
[source]

field sdlVersionCompiledMinor


is number
[source]

field sdlVersionCompiledPatch


is number
[source]

field sdlVersionLinkedMajor


is number
[source]

field sdlVersionLinkedMinor


is number
[source]

field sdlVersionLinkedPatch


is number
[source]

field availableVideoModes


is PlatformVideoMode[]
[source]

field numDisplays


is integer
[source]

field glSupportNonPowerOfTwoTex


is boolean
[source]

field glSupportTextureQueryLOD


is boolean
[source]

field glSupportMSAAFrameBuffer


is boolean
[source]

field glHaveAMD


is boolean
[source]

field glHaveNVidia


is boolean
[source]

field glHaveIntel


is boolean
[source]

field glHaveGLSL


is boolean
[source]

field glHaveGL4


is boolean
[source]

field glSupportDepthBufferBitDepth


is number
[source]

field glSupportRestartPrimitive


is boolean
[source]

field glSupportClipSpaceControl


is boolean
[source]

field glSupportFragDepthLayout


is boolean
[source]

field glSupportSeamlessCubeMaps


is boolean
[source]

field osName


is string
[source] full name of the OS

field osVersion


is string
[source]

field osFamily


is (“Windows”|“Linux”|“MacOSX”|“FreeBSD”|“Unknown”)
[source]

field hwConfig


is string
[source]

field cpuLogicalCores


is integer
[source]

field cpuPhysicalCores


is integer
[source]

field cpuBrand


is string
[source]

field totalRAM


is number
[source] Total physical system RAM in MBs.

field sysInfoHash


is string
[source]

field macAddrHash


is string
[source]

table RmlUi


Global functions for Recoil’s RmlUi implementation.

[source]


field Context


is RmlUi.Context

field ElementText


is RmlUi.ElementText

field ElementTabSet


is RmlUi.ElementTabSet

field ElementProgress


is RmlUi.ElementProgress

field EventListener


is RmlUi.EventListener

field Element


is RmlUi.Element

field ElementPtr


is RmlUi.ElementPtr

fn CreateContext (name) -> nil


Create a new context.

[source]


Params

name: string

Returns

nil: RmlUi.Context? --if failed.

fn RemoveContext (context)


Remove a context.

[source]


Params

context: (string|RmlUi.Context)

fn LoadFontFace (file_path, fallback, weight) -> success


Load a font face.

[source]


Params

file_path: string
fallback: boolean?
weight: RmlUi.font_weight?

Returns

success: boolean

fn GetContext (name) -> nil


Get a context by name.

[source]


Params

name: string

Returns

nil: RmlUi.Context? --if failed.

fn RegiserEventType (event_type, interruptible, bubbles, default_phase) ->


Register a new event type.

[source]


Params

event_type: string
interruptible: boolean?
bubbles: boolean?
default_phase: RmlUi.default_action_phase?

Returns

: RmlUi.EventID

fn AddTranslationString (key, translation) -> success


Add a translation string.

[source]


Params

key: string
translation: string

Returns

success: boolean

fn ClearTranslations ()


Clear registered translations.

[source]


fn SetMouseCursorAlias (rml_name, recoil_name)


Converts the css names for cursors to the Recoil Engine names for cursors like RmlUi.SetMouseCursorAlias("pointer", 'Move'). Web devs tend to want to use specific words for pointer types.

[source]


Params

rml_name: string --name used in rml script
recoil_name: string --name used in recoil

fn SetDebugContext (context)


Set which context the debug inspector is meant to inspect.

[source]


Params

context: (string|RmlUi.Context)

field contexts


is RmlUi.Context[]
[source]

field version


is string
[source] RmlUi version

field key_identifier


is RmlUi.key_identifier

field key_modifier


is RmlUi.key_modifier

field font_weight


is RmlUi.font_weight

field default_action_phase


is RmlUi.default_action_phase

field RmlEventPhase


is RmlUi.RmlEventPhase

field EventParametersProxy


is RmlUi.EventParametersProxy

field Event


is RmlUi.Event

field RmlModalFlag


is RmlUi.RmlModalFlag

field RmlFocusFlag


is RmlUi.RmlFocusFlag

field Document


is RmlUi.Document

field Vector2i


is RmlUi.Vector2i

field Vector2f


is RmlUi.Vector2f
See: float2

field ElementForm


is RmlUi.ElementForm

field ElementFormControl


is RmlUi.ElementFormControl

field ElementFormControlInput


is RmlUi.ElementFormControlInput

field ElementFormControlSelect


is RmlUi.ElementFormControlSelect

field ElementFormControlTextArea


is RmlUi.ElementFormControlTextArea

field SolLuaDataModel


is RmlUi.SolLuaDataModel

table Script


fn Kill (killMessage)


[source]

Params

killMessage: string? --Kill message.

fn UpdateCallin (name)


[source]

Params

name: string

field NO_ACCESS_TEAM


is integer
[source]

field ALL_ACCESS_TEAM


is integer
[source]

fn GetName () -> name


[source]

Returns

name: string

fn GetSynced () -> synced


[source]

Returns

synced: boolean

fn GetFullCtrl () -> fullCtrl


[source]

Returns

fullCtrl: boolean

fn GetFullRead () -> fullRead


[source]

Returns

fullRead: boolean

fn GetCtrlTeam () -> teamID


[source]

Returns

teamID: integer

fn GetReadTeam () -> teamID


[source]

Returns

teamID: integer

fn GetReadAllyTeam () -> allyTeamID


[source]

Returns

allyTeamID: integer

fn GetSelectTeam () -> teamID


[source]

Returns

teamID: integer

fn GetGlobal () -> global


[source]

Returns

global: integer?

fn GetRegistry () -> registry


[source]

Returns

registry: integer?

fn DelayByFrames (frameDelay, fun)


[source]

Params

frameDelay: integer
fun: unknown

fn IsEngineMinVersion (minMajorVer, minMinorVer, minCommits) -> satisfiesMin


[source]

Params

minMajorVer: integer
minMinorVer: integer? --(Default: `0`)
minCommits: integer? --(Default: `0`)

Returns

satisfiesMin: boolean --`true` if the engine version is greater or equal to the specified version, otherwise `false`.

fn GetWatchUnit (unitDefID) -> watched


Query whether any callins are registered for a unitDefID.

[source]


See: Script.SetWatchUnit

Params

unitDefID: integer

Returns

watched: boolean --Watch status.

fn GetWatchFeature (featureDefID) -> watched


Query whether any callins are registered for a featureDefID.

[source]


See: Script.SetWatchFeature

Params

featureDefID: integer

Returns

watched: boolean --`true` if callins are registered, otherwise `false`.

fn GetWatchWeapon (weaponDefID) -> watched


Query whether any callins are registered for a weaponDefID.

[source]

Same as calling:

Script.GetWatchExplosion(weaponDefID) or Script.GetWatchProjectile(weaponDefID) or Script.GetWatchAllowTarget(weaponDefID)

See: Script.SetWatchWeapon

Params

weaponDefID: integer

Returns

watched: boolean --True if watch is enabled for any weaponDefID callins.

fn GetWatchExplosion (weaponDefID) -> watched


Query whether explosion callins are registered for a weaponDefID.

[source]


See: Script.SetWatchExplosion

Params

weaponDefID: integer

Returns

watched: boolean --`true` if callins are registered, otherwise `false`.

fn GetWatchProjectile (weaponDefID) -> watched


Query whether projectile callins are registered for a weaponDefID.

[source]


See: Script.SetWatchProjectile

Params

weaponDefID: integer

Returns

watched: boolean --`true` if callins are registered, otherwise `false`.

fn GetWatchAllowTarget (weaponDefID) -> watched


Query whether weapon targeting callins are registered for a weaponDefID.

[source]


See: Script.SetWatchAllowTarget

Params

weaponDefID: integer

Returns

watched: boolean --`true` if callins are registered, otherwise `false`.

fn SetWatchUnit (unitDefID, watch)


Register or deregister unitDefID for expensive callins.

[source]


See: Script.GetWatchUnit Callins:UnitFeatureCollision Callins:UnitUnitCollision Callins:UnitMoveFailed

Params

unitDefID: integer
watch: boolean --Whether to register or deregister.

fn SetWatchFeature (featureDefID, watch)


Register or deregister featureDefID for expensive callins.

[source]


See: Script.GetWatchFeature Callins:UnitFeatureCollision

Params

featureDefID: integer
watch: boolean --Whether to register or deregister.

fn SetWatchWeapon (weaponDefID, watch)


Register or deregister weaponDefID for all expensive callins.

[source]

Equivalent to calling:

Script.SetWatchExplosion(weaponDefID)
Script.SetWatchProjectile(weaponDefID)
Script.SetWatchAllowTarget(weaponDefID)

Generally it’s better to use those methods to avoid registering uneeded callins.


See: Script.GetWatchWeapon Script.SetWatchExplosion Script.SetWatchProjectile Script.SetWatchAllowTarget

Params

weaponDefID: integer
watch: boolean --Whether to register or deregister.

fn SetWatchExplosion (weaponDefID, watch)


Register or deregister weaponDefID for explosion callins.

[source]


See: Script.GetWatchExplosion Callins:Explosion

Params

weaponDefID: integer
watch: boolean --Whether to register or deregister.

fn SetWatchProjectile (weaponDefID, watch)


Register or deregister weaponDefID for expensive projectile callins.

[source]


See: Script.GetWatchProjectile Callins:ProjectileCreated Callins:ProjectileDestroyed

Params

weaponDefID: integer --weaponDefID for weapons or -1 to watch for debris.
watch: boolean --Whether to register or deregister.

fn SetWatchAllowTarget (weaponDefID, watch)


Register or deregister weaponDefID for weapon targeting callins.

[source]


See: Script.GetWatchAllowTarget SyncedCallins:AllowWeaponTargetCheck SyncedCallins:AllowWeaponTarget SyncedCallins:AllowWeaponInterceptTarget

Params

weaponDefID: integer
watch: boolean --Whether to register or deregister.

table Spring


fn IsReplay () -> isReplay


[source]

Returns

isReplay: boolean?

fn GetReplayLength () -> timeInSeconds


[source]

Returns

timeInSeconds: number?

fn GetGameName () -> name


[source]

Returns

name: string

fn GetMenuName () -> name


[source]

Returns

name: string --name .. version from Modinfo.lua. E.g. "Spring: 1944 test-5640-ac2d15b".

fn GetProfilerTimeRecord (profilerName, frameData) -> total, current, max_dt, time_pct, peak_pct, frameData


[source]

Params

profilerName: string
frameData: boolean? --(Default: `false`)

Returns

total: number --in ms
current: number --in ms
max_dt: number
time_pct: number
peak_pct: number
frameData: table<number,number>? --Table where key is the frame index and value is duration.

fn GetProfilerRecordNames () -> profilerNames


[source]

Returns

profilerNames: string[]

fn GetLuaMemUsage () -> luaHandleAllocedMem, luaHandleNumAllocs, luaGlobalAllocedMem, luaGlobalNumAllocs, luaUnsyncedGlobalAllocedMem, luaUnsyncedGlobalNumAllocs, luaSyncedGlobalAllocedMem, luaSyncedGlobalNumAllocs


[source]

Returns

luaHandleAllocedMem: number --in kilobytes
luaHandleNumAllocs: number --divided by 1000
luaGlobalAllocedMem: number --in kilobytes
luaGlobalNumAllocs: number --divided by 1000
luaUnsyncedGlobalAllocedMem: number --in kilobytes
luaUnsyncedGlobalNumAllocs: number --divided by 1000
luaSyncedGlobalAllocedMem: number --in kilobytes
luaSyncedGlobalNumAllocs: number --divided by 1000

fn GetVidMemUsage () -> usedMem, availableMem


[source]

Returns

usedMem: number --in MB
availableMem: number --in MB

fn GetTimer () ->


Get a timer with millisecond resolution

[source]


Returns

: integer

fn GetTimerMicros () ->


Get a timer with microsecond resolution

[source]


Returns

: integer

fn GetFrameTimer (lastFrameTime) ->


Get a timer for the start of the frame

[source]

This should give better results for camera interpolations


Params

lastFrameTime: boolean? --(Default: `false`) whether to use last frame time instead of last frame start

Returns

: integer

fn DiffTimers (endTimer, startTimer, returnMs, fromMicroSecs) -> timeAmount


[source]

Params

endTimer: integer
startTimer: integer
returnMs: boolean? --(Default: `false`) whether to return `timeAmount` in milliseconds as opposed to seconds
fromMicroSecs: boolean? --(Default: `false`) whether timers are in microseconds instead of milliseconds

Returns

timeAmount: number

fn GetNumDisplays () -> numDisplays


[source]

Returns

numDisplays: number --as returned by `SDL_GetNumVideoDisplays`

fn GetViewGeometry () -> viewSizeX, viewSizeY, viewPosX, viewPosY


Get main view geometry (map and game rendering)

[source]


Returns

viewSizeX: number --in px
viewSizeY: number --in px
viewPosX: number --offset from leftmost screen left border in px
viewPosY: number --offset from bottommost screen bottom border in px

fn GetDualViewGeometry () -> dualViewSizeX, dualViewSizeY, dualViewPosX, dualViewPosY


Get dual view geometry (minimap when enabled)

[source]


Returns

dualViewSizeX: number --in px
dualViewSizeY: number --in px
dualViewPosX: number --offset from leftmost screen left border in px
dualViewPosY: number --offset from bottommost screen bottom border in px

fn GetWindowGeometry () -> winSizeX, winSizeY, winPosX, winPosY, windowBorderTop, windowBorderLeft, windowBorderBottom, windowBorderRight


Get main window geometry

[source]


Returns

winSizeX: number --in px
winSizeY: number --in px
winPosX: number --in px
winPosY: number --in px
windowBorderTop: number --in px
windowBorderLeft: number --in px
windowBorderBottom: number --in px
windowBorderRight: number --in px

fn GetWindowDisplayMode () -> width, height, bits, refresh


Get main window display mode

[source]


Returns

width: number --in px
height: number --in px
bits: number --per pixel
refresh: number --rate in Hz

fn GetScreenGeometry (displayIndex, queryUsable) -> screenSizeX, screenSizeY, screenPosX, screenPosY, windowBorderTop, windowBorderLeft, windowBorderBottom, windowBorderRight, screenUsableSizeX, screenUsableSizeY, screenUsablePosX, screenUsablePosY


Get screen geometry

[source]


Params

displayIndex: number? --(Default: `-1`)
queryUsable: boolean? --(Default: `false`)

Returns

screenSizeX: number --in px
screenSizeY: number --in px
screenPosX: number --in px
screenPosY: number --in px
windowBorderTop: number --in px
windowBorderLeft: number --in px
windowBorderBottom: number --in px
windowBorderRight: number --in px
screenUsableSizeX: number? --in px
screenUsableSizeY: number? --in px
screenUsablePosX: number? --in px
screenUsablePosY: number? --in px

fn GetMiniMapGeometry () -> minimapPosX, minimapPosY, minimapSizeX, minimapSizeY, minimized, maximized


Get minimap geometry

[source]


Returns

minimapPosX: number --in px
minimapPosY: number --in px
minimapSizeX: number --in px
minimapSizeY: number --in px
minimized: boolean
maximized: boolean

fn GetMiniMapRotation () -> amount


Get minimap rotation

[source]


Returns

amount: number --in radians

fn GetMiniMapDualScreen () -> position


[source]

Returns

position: (“left”|“right”|false) --`"left"` or `"right"` when dual screen is enabled, otherwise `false`.

fn GetSelectionBox () -> left, top, right, bottom


Get vertices from currently active selection box

[source]

Returns nil when selection box is inactive


See: Spring.GetUnitsInScreenRectangle

Returns

left: number?
top: number?
right: number?
bottom: number?

fn GetDrawSelectionInfo () ->


[source]

Returns

: boolean

fn IsAboveMiniMap (x, y) -> isAbove


[source]

Params

x: number
y: number

Returns

isAbove: boolean

fn GetDrawFrame () -> low_16bit, high_16bit


[source]

Returns

low_16bit: number
high_16bit: number

fn GetFrameTimeOffset () -> offset


[source]

Ideally, when running 30hz sim, and 60hz rendering, the draw frames should have and offset of either 0.0 frames, or 0.5 frames.

When draw frames are not integer multiples of sim frames, some interpolation happens, and this timeoffset shows how far along it is.


Returns

offset: number? --of the current draw frame from the last sim frame, expressed in fractions of a frame

fn GetLastUpdateSeconds () -> lastUpdateSeconds


[source]

Returns

lastUpdateSeconds: number?

fn GetVideoCapturingMode () -> allowRecord


[source]

Returns

allowRecord: boolean

fn IsUnitAllied (unitID) -> isAllied


[source]

Params

unitID: integer

Returns

isAllied: boolean? --nil with unitID cannot be parsed

fn IsUnitSelected (unitID) -> isSelected


[source]

Params

unitID: integer

Returns

isSelected: boolean? --nil when unitID cannot be parsed

fn GetUnitLuaDraw (unitID) -> draw


[source]

Params

unitID: integer

Returns

draw: boolean? --nil when unitID cannot be parsed

fn GetUnitNoDraw (unitID) -> nil


[source]

Params

unitID: integer

Returns

nil: boolean? --when unitID cannot be parsed

fn GetUnitEngineDrawMask (unitID) -> nil


[source]

Params

unitID: integer

Returns

nil: boolean? --when unitID cannot be parsed

fn GetUnitAlwaysUpdateMatrix (unitID) -> nil


[source]

Params

unitID: integer

Returns

nil: boolean? --when unitID cannot be parsed

fn GetUnitDrawFlag (unitID) -> nil


[source]

Params

unitID: integer

Returns

nil: number? --when unitID cannot be parsed

fn GetUnitNoMinimap (unitID) -> nil


[source]

Params

unitID: integer

Returns

nil: boolean? --when unitID cannot be parsed

fn GetUnitNoGroup (unitID) -> noGroup


Check if a unit is not allowed to be added to a group by a player.

[source]


Params

unitID: integer

Returns

noGroup: boolean? --`true` if the unit is not allowed to be added to a group, `false` if it is allowed to be added to a group, or `nil` when `unitID` is not valid.

fn GetUnitNoSelect (unitID) -> noSelect


[source]

Params

unitID: integer

Returns

noSelect: boolean? --`nil` when `unitID` cannot be parsed.

fn UnitIconGetDraw (unitID) -> drawIcon


[source]

Params

unitID: integer

Returns

drawIcon: boolean?

fn GetUnitSelectionVolumeData (unitID) -> scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, volumeType, useContHitTest, getPrimaryAxis, ignoreHits


[source]

Params

unitID: integer

Returns

scaleX: number? --nil when unitID cannot be parsed
scaleY: number
scaleZ: number
offsetX: number
offsetY: number
offsetZ: number
volumeType: number
useContHitTest: number
getPrimaryAxis: number
ignoreHits: boolean

fn GetFeatureLuaDraw (featureID) -> nil


[source]

Params

featureID: integer

Returns

nil: boolean? --when featureID cannot be parsed

fn GetFeatureNoDraw (featureID) -> nil


[source]

Params

featureID: integer

Returns

nil: boolean? --when featureID cannot be parsed

fn GetFeatureEngineDrawMask (featureID) -> nil


[source]

Params

featureID: integer

Returns

nil: boolean? --when featureID cannot be parsed

fn GetFeatureAlwaysUpdateMatrix (featureID) -> nil


[source]

Params

featureID: integer

Returns

nil: boolean? --when featureID cannot be parsed

fn GetFeatureDrawFlag (featureID) -> nil


[source]

Params

featureID: integer

Returns

nil: number? --when featureID cannot be parsed

fn GetFeatureSelectionVolumeData (featureID) -> scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, volumeType, useContHitTest, getPrimaryAxis, ignoreHits


[source]

Params

featureID: integer

Returns

scaleX: number? --nil when unitID cannot be parsed
scaleY: number
scaleZ: number
offsetX: number
offsetY: number
offsetZ: number
volumeType: number
useContHitTest: number
getPrimaryAxis: number
ignoreHits: boolean

fn GetUnitTransformMatrix (unitID) -> m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44


[source]

Params

unitID: integer

Returns

m11: number? --nil when unitID cannot be parsed
m12: number
m13: number
m14: number
m21: number
m22: number
m23: number
m24: number
m31: number
m32: number
m33: number
m34: number
m41: number
m42: number
m43: number
m44: number

fn GetFeatureTransformMatrix (featureID) -> m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44


[source]

Params

featureID: integer

Returns

m11: number? --nil when featureID cannot be parsed
m12: number
m13: number
m14: number
m21: number
m22: number
m23: number
m24: number
m31: number
m32: number
m33: number
m34: number
m41: number
m42: number
m43: number
m44: number

fn IsUnitInView (unitID) -> inView


[source]

Params

unitID: integer

Returns

inView: boolean? --nil when unitID cannot be parsed

fn IsUnitVisible (unitID, radius, checkIcon) -> isVisible


[source]

Params

unitID: integer
radius: number? --unitRadius when not specified
checkIcon: boolean

Returns

isVisible: boolean? --nil when unitID cannot be parsed

fn IsUnitIcon (unitID) -> isUnitIcon


[source]

Params

unitID: integer

Returns

isUnitIcon: boolean? --nil when unitID cannot be parsed

fn IsAABBInView (minX, minY, minZ, maxX, maxY, maxZ) -> inView


[source]

Params

minX: number
minY: number
minZ: number
maxX: number
maxY: number
maxZ: number

Returns

inView: boolean

fn IsSphereInView (posX, posY, posZ, radius) -> inView


[source]

Params

posX: number
posY: number
posZ: number
radius: number? --(Default: `0`)

Returns

inView: boolean

fn GetUnitViewPosition (unitID, midPos) -> x, y, z


[source]

Params

unitID: integer
midPos: boolean? --(Default: `false`)

Returns

x: number? --nil when unitID cannot be parsed
y: number
z: number

fn GetVisibleUnits (teamID, radius, icons) -> unitIDs


[source]

Params

teamID: integer? --(Default: `-1`)
radius: number? --(Default: `30`)
icons: boolean? --(Default: `true`)

Returns

unitIDs: number[]?

fn GetVisibleFeatures (teamID, radius, icons, geos) -> featureIDs


[source]

Params

teamID: integer? --(Default: `-1`)
radius: number? --(Default: `30`)
icons: boolean? --(Default: `true`)
geos: boolean? --(Default: `true`)

Returns

featureIDs: number[]?

fn GetVisibleProjectiles (allyTeamID, addSyncedProjectiles, addWeaponProjectiles, addPieceProjectiles) -> projectileIDs


[source]

Params

allyTeamID: integer? --(Default: `-1`)
addSyncedProjectiles: boolean? --(Default: `true`)
addWeaponProjectiles: boolean? --(Default: `true`)
addPieceProjectiles: boolean? --(Default: `true`)

Returns

projectileIDs: number[]?

fn GetRenderUnits (drawMask, sendMask) -> featureIDs, drawFlags


[source]

Params

drawMask: DrawMask --(Default: `0`) Filter objects by their draw flags.
sendMask: true --Whether to send objects draw flags as second return

Returns

featureIDs: integer[]
drawFlags: DrawFlag[]

fn GetRenderUnits (drawMask, sendMask) -> featureIDs


[source]

Params

drawMask: DrawMask --(Default: `0`) Filter objects by their draw flags.
sendMask: false? --Whether to send objects draw flags as second return

Returns

featureIDs: integer[]

fn GetRenderUnitsDrawFlagChanged (sendMask) -> ids, unitDrawFlags


[source]

Gets a list of IDs of units that have had their draw flags changed, and the corresponding flags.


Params

sendMask: true --Whether to send objects draw flags as second return.

Returns

ids: integer[]
unitDrawFlags: DrawFlag[]

fn GetRenderUnitsDrawFlagChanged (sendMask) -> ids


[source]

Gets a list of IDs of units that have had their draw flags changed, and the corresponding flags.


Params

sendMask: false? --Whether to send objects draw flags as second return.

Returns

ids: integer[]

fn GetRenderFeatures (drawMask, sendMask) -> featureIDs, drawFlags


[source]

Params

drawMask: DrawMask --(Default: `0`) Filter objects by their draw flags.
sendMask: true --Whether to send objects draw flags as second return

Returns

featureIDs: integer[]
drawFlags: DrawFlag[]

fn GetRenderFeatures (drawMask, sendMask) -> featureIDs


[source]

Params

drawMask: DrawMask --(Default: `0`) Filter objects by their draw flags.
sendMask: false? --Whether to send objects draw flags as second return

Returns

featureIDs: integer[]

fn GetRenderFeaturesDrawFlagChanged (sendMask) -> ids, unitDrawFlags


[source]

Gets a list of IDs of features that have had their draw flags changed, and the corresponding flags.


Params

sendMask: true --Whether to send objects draw flags as second return.

Returns

ids: integer[]
unitDrawFlags: DrawFlag[]

fn GetRenderFeaturesDrawFlagChanged (sendMask) -> ids


[source]

Gets a list of IDs of features that have had their draw flags changed, and the corresponding flags.


Params

sendMask: false? --Whether to send objects draw flags as second return.

Returns

ids: integer[]

fn ClearUnitsPreviousDrawFlag ()


[source]

fn ClearFeaturesPreviousDrawFlag ()


[source]

fn GetUnitsInScreenRectangle (left, top, right, bottom, allegiance) -> unitIDs


Get units inside a rectangle area on the map

[source]


Params

left: number
top: number
right: number
bottom: number
allegiance: number? --(Default: `-1`) teamID when > 0, when < 0 one of AllUnits = -1, MyUnits = -2, AllyUnits = -3, EnemyUnits = -4

Returns

unitIDs: number[]?

fn GetFeaturesInScreenRectangle (left, top, right, bottom) -> featureIDs


Get features inside a rectangle area on the map

[source]


Params

left: number
top: number
right: number
bottom: number

Returns

featureIDs: number[]?

fn GetLocalPlayerID () -> playerID


[source]

Returns

playerID: integer

fn GetLocalTeamID () -> teamID


[source]

Returns

teamID: integer

fn GetLocalAllyTeamID () -> allyTeamID


[source]

Returns

allyTeamID: integer

fn GetSpectatingState () -> spectating, spectatingFullView, spectatingFullSelect


[source]

Returns

spectating: boolean
spectatingFullView: boolean
spectatingFullSelect: boolean

fn GetSelectedUnits () -> unitIDs


[source]

Returns

unitIDs: number[]

fn GetSelectedUnitsSorted () -> where, the


Get selected units aggregated by unitDefID

[source]


Returns

where: table<number,number[]> --keys are unitDefIDs and values are unitIDs
the: integer --number of unitDefIDs

fn GetSelectedUnitsCounts () -> unitsCounts, the


Get an aggregate count of selected units per unitDefID

[source]


Returns

unitsCounts: table<number,number> --where keys are unitDefIDs and values are counts
the: integer --number of unitDefIDs

fn GetSelectedUnitsCount () -> selectedUnitsCount


Returns the amount of selected units

[source]


Returns

selectedUnitsCount: number

fn GetBoxSelectionByEngine () -> isHandledByEngine


Get if selection box is handled by engine.

[source]


See: Spring.GetSelectionBox Spring.SetBoxSelectionByEngine

Returns

isHandledByEngine: boolean --`true` if the engine will select units inside selection box on release, otherwise `false`.

fn IsGUIHidden () ->


[source]

Returns

: boolean

fn HaveShadows () -> shadowsLoaded


[source]

Returns

shadowsLoaded: boolean

fn HaveAdvShading () -> useAdvShading, groundUseAdvShading


[source]

Returns

useAdvShading: boolean
groundUseAdvShading: boolean

fn GetWaterMode () -> waterRendererID, waterRendererName


[source]
See: rts/Rendering/Env/IWater.h

Returns

waterRendererID: integer
waterRendererName: string

fn GetMapDrawMode () ->


[source]

Returns

: (“normal”|“height”|“metal”|“pathTraversability”|“los”)

fn GetMapSquareTexture (texSquareX, texSquareY, lodMin, luaTexName, lodMax) -> success


[source]

Params

texSquareX: number
texSquareY: number
lodMin: number
luaTexName: string
lodMax: number? --(Default: lodMin)

Returns

success: boolean?

fn GetLosViewColors () -> always, LOS, radar, jam, radar2


[source]

Returns

always: rgb
LOS: rgb
radar: rgb
jam: rgb
radar2: rgb

fn GetNanoProjectileParams () -> rotVal, rotVel, rotAcc, rotValRng, rotVelRng, rotAccRng


[source]

Returns

rotVal: number --in degrees
rotVel: number --in degrees
rotAcc: number --in degrees
rotValRng: number --in degrees
rotVelRng: number --in degrees
rotAccRng: number --in degrees

fn GetCameraNames () -> indexByName


Get available cameras.

[source]


Returns

indexByName: table<string,integer> --Table where where keys are names and values are indices.

fn GetCameraState (useTable) -> name, depends


[source]

Params

useTable: false

Returns

name: CameraName
depends: any … --on the current controller mode.

fn GetCameraState (useTable) -> cameraState


[source]

Params

useTable: true? --(Default: `true`) Return a table instead of multiple values.

Returns

cameraState: CameraState

fn GetCameraPosition () -> posX, posY, posZ


[source]

Returns

posX: number
posY: number
posZ: number

fn GetCameraDirection () -> dirX, dirY, dirZ


[source]

Returns

dirX: number
dirY: number
dirZ: number

fn GetCameraRotation () -> rotX, rotY, rotZ


Get camera rotation in radians.

[source]


Returns

rotX: number --Rotation around X axis in radians.
rotY: number --Rotation around Y axis in radians.
rotZ: number --Rotation around Z axis in radians.

fn GetCameraFOV () -> vFOV, hFOV


[source]

Returns

vFOV: number
hFOV: number

fn GetCameraVectors () ->


[source]

Returns

: CameraVectors

fn WorldToScreenCoords (x, y, z) -> viewPortX, viewPortY, viewPortZ


[source]

Params

x: number
y: number
z: number

Returns

viewPortX: number
viewPortY: number
viewPortZ: number

fn TraceScreenRay (screenX, screenY, onlyCoords, useMinimap, includeSky, ignoreWater, heightOffset) -> description, unitID, featureID, coords


Get information about a ray traced from screen to world position

[source]

Extended to allow a custom plane, parameters are (0, 1, 0, D=0) where D is the offset D can be specified in the third argument (if all the bools are false) or in the seventh (as shown).

Intersection coordinates are returned in t[4],t[5],t[6] when the ray goes offmap and includeSky is true), or when no unit or feature is hit (or onlyCoords is true).

This will only work for units & objects with the default collision sphere. Per Piece collision and custom collision objects are not supported.

The unit must be selectable, to appear to a screen trace ray.


Params

screenX: number --position on x axis in mouse coordinates (origin on left border of view)
screenY: number --position on y axis in mouse coordinates (origin on top border of view)
onlyCoords: boolean? --(Default: `false`) return only description (1st return value) and coordinates (2nd return value)
useMinimap: boolean? --(Default: `false`) if position arguments are contained by minimap, use the minimap corresponding world position
includeSky: boolean? --(Default: `false`)
ignoreWater: boolean? --(Default: `false`)
heightOffset: number? --(Default: `0`)

Returns

description: string? --of traced position
unitID: (number|string|xyz)? --or feature, position triple when onlyCoords=true
featureID: (number|string)? --or ground
coords: xyz?

fn GetPixelDir (x, y) -> dirX, dirY, dirZ


[source]

Params

x: number
y: number

Returns

dirX: number
dirY: number
dirZ: number

fn GetTeamColor (teamID) -> r, g, b, a


[source]

Params

teamID: integer

Returns

r: number? --factor from 0 to 1
g: number? --factor from 0 to 1
b: number? --factor from 0 to 1
a: number? --factor from 0 to 1

fn GetTeamOrigColor (teamID) -> r, g, b, a


[source]

Params

teamID: integer

Returns

r: number? --factor from 0 to 1
g: number? --factor from 0 to 1
b: number? --factor from 0 to 1
a: number? --factor from 0 to 1

fn GetDrawSeconds () -> time


[source]

Returns

time: integer --Time in seconds.

fn GetSoundDevices () -> devices


[source]

Returns

devices: SoundDeviceSpec[] --Sound devices.

fn GetSoundStreamTime () -> playTime, time


[source]

Returns

playTime: number
time: number

fn GetSoundEffectParams ()


[source]

fn GetFPS () -> fps


[source]

Returns

fps: number

fn GetGameSpeed () -> wantedSpeedFactor, speedFactor, paused


[source]

Returns

wantedSpeedFactor: number
speedFactor: number
paused: boolean

fn GetGameState (maxLatency) -> doneLoading, isSavedGame, isClientPaused, isSimLagging


[source]

Params

maxLatency: number? --(Default: `500`) used for `isSimLagging` return parameter

Returns

doneLoading: boolean
isSavedGame: boolean
isClientPaused: boolean
isSimLagging: boolean

fn GetActiveCommand () -> cmdIndex, cmdID, cmdType, cmdName


[source]

Returns

cmdIndex: number?
cmdID: integer?
cmdType: number?
cmdName: string?

fn GetDefaultCommand () -> cmdIndex, cmdID, cmdType, cmdName


[source]

Returns

cmdIndex: integer?
cmdID: integer?
cmdType: integer?
cmdName: string?

fn GetActiveCmdDescs () -> cmdDescs


[source]

Returns

cmdDescs: CommandDescription[]

fn GetActiveCmdDesc (cmdIndex) ->


[source]

Params

cmdIndex: integer

Returns

: CommandDescription?

fn GetCmdDescIndex (cmdID) -> cmdDescIndex


[source]

Params

cmdID: integer

Returns

cmdDescIndex: integer?

fn GetBuildFacing () -> buildFacing


[source]

Returns

buildFacing: FacingInteger

fn GetBuildSpacing () -> buildSpacing


[source]

Returns

buildSpacing: number

fn GetGatherMode () -> gatherMode


[source]

Returns

gatherMode: number

fn GetActivePage () -> activePage, maxPage


[source]

Returns

activePage: number
maxPage: number

fn GetMouseState () -> x, y, lmbPressed, mmbPressed, rmbPressed, offscreen, mmbScroll


[source]

Returns

x: number
y: number
lmbPressed: number --left mouse button pressed
mmbPressed: number --middle mouse button pressed
rmbPressed: number --right mouse button pressed
offscreen: boolean
mmbScroll: boolean

fn GetMouseCursor () -> cursorName, cursorScale


[source]

Returns

cursorName: string
cursorScale: number

fn GetMouseStartPosition (button) -> x, y, camPosX, camPosY, camPosZ, dirX, dirY, dirZ


[source]

Params

button: number

Returns

x: number
y: number
camPosX: number
camPosY: number
camPosZ: number
dirX: number
dirY: number
dirZ: number

fn GetMouseButtonsPressed (button1, ...) -> Pressed


[source]

Get pressed status for specific buttons.


Params

button1: integer --Index of the first button.
...: integer --Indices for more buttons.

Returns

Pressed: boolean … --status for the buttons.

fn GetClipboard () -> text


[source]

Returns

text: string

fn IsUserWriting () ->


[source]

Returns

: boolean

fn GetLastMessagePositions () -> message


[source]

Returns

message: xyz[] --positions

fn GetConsoleBuffer (maxLines) -> buffer


[source]

Params

maxLines: number

Returns

buffer: { priority: integer, text: string }[]

fn GetCurrentTooltip () -> tooltip


[source]

Returns

tooltip: string

fn GetKeyFromScanSymbol (scanSymbol) -> keyName


[source]

Params

scanSymbol: string

Returns

keyName: string

fn GetKeyState (keyCode) -> pressed


[source]

Params

keyCode: number

Returns

pressed: boolean

fn GetModKeyState () -> alt, ctrl, meta, shift


[source]

Returns

alt: boolean
ctrl: boolean
meta: boolean
shift: boolean

fn GetPressedKeys () -> where


[source]

Returns

where: table<(number|string),true> --keys are keyCodes or key names

fn GetPressedScans () -> where


[source]

Returns

where: table<(number|string),true> --keys are scanCodes or scan names

fn GetInvertQueueKey () -> queueKey


[source]

Returns

queueKey: number?

fn GetKeyCode (keySym) -> keyCode


[source]

Params

keySym: string

Returns

keyCode: number

fn GetKeySymbol (keyCode) -> keyCodeName, keyCodeDefaultName


[source]

Params

keyCode: number

Returns

keyCodeName: string
keyCodeDefaultName: string --name when there are not aliases

fn GetScanSymbol (scanCode) -> scanCodeName, scanCodeDefaultName


[source]

Params

scanCode: number

Returns

scanCodeName: string
scanCodeDefaultName: string --name when there are not aliases

fn GetKeyBindings (keySet1, keySet2) ->


[source]

Params

keySet1: string? --filters keybindings bound to this keyset
keySet2: string? --OR bound to this keyset

Returns

: KeyBinding[]

fn GetActionHotKeys (actionName) -> hotkeys


[source]

Params

actionName: string

Returns

hotkeys: string[]?

fn GetGroupList () -> where


[source]

Returns

where: table<number,number>? --keys are groupIDs and values are counts

fn GetSelectedGroup () -> groupID


[source]

Returns

groupID: integer

fn GetUnitGroup (unitID) -> groupID


[source]

Params

unitID: integer

Returns

groupID: integer?

fn GetGroupUnits (groupID) -> unitIDs


[source]

Params

groupID: integer

Returns

unitIDs: number[]?

fn GetGroupUnitsSorted (groupID) -> where


[source]

Params

groupID: integer

Returns

where: table<number,number[]>? --keys are unitDefIDs and values are unitIDs

fn GetGroupUnitsCounts (groupID) -> where


[source]

Params

groupID: integer

Returns

where: table<number,number>? --keys are unitDefIDs and values are counts

fn GetGroupUnitsCount (groupID) -> groupSize


[source]

Params

groupID: integer

Returns

groupSize: number?

fn GetPlayerRoster (sortType, showPathingPlayers) -> playerTable


[source]

Params

sortType: number? --return unsorted if unspecified. Disabled = 0, Allies = 1, TeamID = 2, PlayerName = 3, PlayerCPU = 4, PlayerPing = 5
showPathingPlayers: boolean? --(Default: `false`)

Returns

playerTable: Roster[]?

fn GetPlayerTraffic (playerID, packetID) -> traffic


[source]

Params

playerID: integer
packetID: integer?

Returns

traffic: number

fn GetPlayerStatistics (playerID) -> mousePixels, mouseClicks, keyPresses, numCommands, unitCommands


[source]

Params

playerID: integer

Returns

mousePixels: number? --nil when invalid playerID
mouseClicks: number
keyPresses: number
numCommands: number
unitCommands: number

fn GetConfigParams () ->


[source]

Returns

: Configuration[]

fn GetConfigInt (name, default) -> configInt


[source]

Params

name: string
default: number? --(Default: `0`)

Returns

configInt: number?

fn GetConfigFloat (name, default) -> configFloat


[source]

Params

name: string
default: number? --(Default: `0`)

Returns

configFloat: number?

fn GetConfigString (name, default) -> configString


[source]

Params

name: string
default: string? --(Default: `""`)

Returns

configString: number?

fn GetLogSections () -> sections


[source]

Returns

sections: table<string,number> --where keys are names and loglevel are values. E.g. `{ "KeyBindings" = LOG.INFO, "Font" = LOG.INFO, "Sound" = LOG.WARNING, ... }`

fn GetAllGroundDecals () -> decalIDs


[source]

Returns

decalIDs: number[]

fn GetGroundDecalMiddlePos (decalID) -> posX, posZ


[source]

Params

decalID: integer

Returns

posX: number?
posZ: number

fn GetGroundDecalQuadPos (decalID) -> posTL.x, posTL.z, posTR.x, posTR.z, posBR.x, posBR.z, posBL.x, posBL.z


[source]

Params

decalID: integer

Returns

posTL.x: number?
posTL.z: number
posTR.x: number
posTR.z: number
posBR.x: number
posBR.z: number
posBL.x: number
posBL.z: number

fn GetGroundDecalSizeAndHeight (decalID) -> sizeX, sizeY, projCubeHeight


[source]

Params

decalID: integer

Returns

sizeX: number?
sizeY: number
projCubeHeight: number

fn GetGroundDecalRotation (decalID) -> rotation


[source]

Params

decalID: integer

Returns

rotation: number? --Rotation in radians.

fn GetGroundDecalTexture (decalID, isMainTex) -> texture


[source]

Params

decalID: integer
isMainTex: boolean? --(Default: `true`) If `false`, return the normal/glow map.

Returns

texture: string?

fn GetGroundDecalTextures (isMainTex, addFilenames) -> textureNames


[source]
See: Spring.GetGroundDecalTexture

Params

isMainTex: boolean? --(Default: `nil`). If `nil` - no filtering is done, if `false` - return normal/glow textures, if `true` - return main color textures.
addFilenames: boolean? --(Default: `false`). If `true` add the texture filenames in the second table

Returns

textureNames: string[] --All textures on the atlas and available for use in `SetGroundDecalTexture`.

fn SetGroundDecalTextureParams (decalID) -> texWrapDistance, texTraveledDistance


[source]

Params

decalID: integer

Returns

texWrapDistance: number? --If non-zero, sets the mode to repeat the texture along the left-right direction of the decal every texWrapFactor elmos.
texTraveledDistance: number --Shifts the texture repetition defined by texWrapFactor so the texture of a next line in the continuous multiline can start where the previous finished. For that it should collect all elmo lengths of the previously set multiline segments.

fn GetGroundDecalAlpha (decalID) -> alpha, alphaFalloff


[source]

Params

decalID: integer

Returns

alpha: number? --Between 0 and 1
alphaFalloff: number --Between 0 and 1, per second

fn GetGroundDecalNormal (decalID) -> normal.x, normal.y, normal.z


[source]

If all three equal 0, the decal follows the normals of ground at midpoint


Params

decalID: integer

Returns

normal.x: number?
normal.y: number
normal.z: number

fn GetGroundDecalTint (decalID) -> tintR, tintG, tintB, tintA


[source]

Gets the tint of the ground decal. A color of (0.5, 0.5, 0.5, 0.5) is effectively no tint


Params

decalID: integer

Returns

tintR: number?
tintG: number
tintB: number
tintA: number

fn GetGroundDecalMisc (decalID) -> dotElimExp, refHeight, minHeight, maxHeight, forceHeightMode


[source]

Returns less important parameters of a ground decal


Params

decalID: integer

Returns

dotElimExp: number?
refHeight: number
minHeight: number
maxHeight: number
forceHeightMode: number

fn GetGroundDecalCreationFrame (decalID) -> creationFrameMin, creationFrameMax


[source]

Min can be not equal to max for “gradient” style decals, e.g. unit tracks


Params

decalID: integer

Returns

creationFrameMin: number?
creationFrameMax: number

fn GetGroundDecalOwner (decalID) -> value


[source]

Params

decalID: integer

Returns

value: integer? --If owner is a unit, then this is `unitID`, if owner is a feature it is `featureID + MAX_UNITS`. If there is no owner, then `nil`.

fn GetGroundDecalType (decalID) -> type


[source]

Params

decalID: integer

Returns

type: (“explosion”|“plate”|“lua”|“track”|“unknown”)?

fn GetSyncedGCInfo (collectGC) -> GC


[source]

Params

collectGC: boolean? --(Default: `false`) collect before returning metric

Returns

GC: number? --values are expressed in Kbytes: #bytes/2^10

fn SolveNURBSCurve (groupID) -> unitIDs


[source]

Params

groupID: integer

Returns

unitIDs: number[]?

fn Ping (pingTag) ->


Send a ping request to the server

[source]


Params

pingTag: number

Returns

: nil

fn SendCommands (commands)


[source]

Params

commands: string[]

fn SendCommands (command, ...) ->


[source]

Params

command: string
...: string --additional commands

Returns

: nil

fn SendPublicChat (message) ->


Sends a chat message to everyone (players and spectators).

[source]


Params

message: string

Returns

: nil

fn SendAllyChat (message) ->


Sends a chat message to the sender’s ally team (if a spectator, to other spectators).

[source]


Params

message: string

Returns

: nil

fn SendSpectatorChat (message) ->


Sends a chat message to spectators. Works even if you’re a player.

[source]


Params

message: string

Returns

: nil

fn SendPrivateChat (message, playerID) ->


Sends a private chat message to a specific player ID.

[source]


Params

message: string
playerID: integer

Returns

: nil

fn SendMessage (message) ->


[source]

Params

message: string

Returns

: nil

fn SendMessageToSpectators (message) ->


[source]

Params

message: string --``"`<PLAYER#>`"`` where `#` is a player ID. This will be replaced with the player's name. e.g. ```lua Spring.SendMessage("`<PLAYER1>` did something") -- "ProRusher did something" ```

Returns

: nil

fn SendMessageToPlayer (playerID, message) ->


[source]

Params

playerID: integer
message: string

Returns

: nil

fn SendMessageToTeam (teamID, message) ->


[source]

Params

teamID: integer
message: string

Returns

: nil

fn SendMessageToAllyTeam (allyID, message) ->


[source]

Params

allyID: integer
message: string

Returns

: nil

fn LoadSoundDef (soundfile) -> success


Loads a SoundDefs file, the format is the same as in gamedata/sounds.lua.

[source]


Params

soundfile: string

Returns

success: boolean

fn PlaySoundFile (soundfile, volume, posx, posy, posz, speedx, speedy, speedz, channel) -> playSound


[source]

Params

soundfile: string
volume: number? --(Default: 1.0)
posx: number?
posy: number?
posz: number?
speedx: number?
speedy: number?
speedz: number?
channel: SoundChannel? --(Default: `0|"general"`)

Returns

playSound: boolean

fn PlaySoundStream (oggfile, volume, enqueue) -> success


Allows to play an Ogg Vorbis (.OGG) and mp3 compressed sound file.

[source]

Multiple sound streams may be played at once.


Params

oggfile: string
volume: number? --(Default: 1.0)
enqueue: boolean?

Returns

success: boolean

fn StopSoundStream () ->


Terminates any SoundStream currently running.

[source]


Returns

: nil

fn PauseSoundStream () ->


Pause any SoundStream currently running.

[source]


Returns

: nil

fn SetSoundStreamVolume (volume) ->


Set volume for SoundStream

[source]


Params

volume: number

Returns

: nil

fn SetSoundEffectParams ()


[source]

fn AddWorldIcon (cmdID, posX, posY, posZ) ->


[source]

Params

cmdID: integer
posX: number
posY: number
posZ: number

Returns

: nil

fn AddWorldText (text, posX, posY, posZ) ->


[source]

Params

text: string
posX: number
posY: number
posZ: number

Returns

: nil

fn AddWorldUnit (unitDefID, posX, posY, posZ, teamID, facing) ->


[source]

Params

unitDefID: integer
posX: number
posY: number
posZ: number
teamID: integer
facing: FacingInteger

Returns

: nil

fn DrawUnitCommands (unitID)


[source]

Params

unitID: integer

fn DrawUnitCommands (unitIDs, tableOrArray)


[source]

Params

unitIDs: integer[] --Unit ids.
tableOrArray: false? --Set to `true` if the unit IDs should be read from the keys of `unitIDs`.

fn DrawUnitCommands (unitIDs, tableOrArray) ->


[source]

Params

unitIDs: table<integer,any> --Table with unit IDs as keys.
tableOrArray: true --Set to `false` if the unit IDs should be read from the values of `unitIDs`.

Returns

: nil

fn SetCameraTarget (x, y, z, transTime) ->


For Spring Engine XZ represents horizontal, from north west corner of map and Y vertical, from water level and rising.

[source]


Params

x: number
y: number
z: number
transTime: number?

Returns

: nil

fn SetCameraOffset (posX, posY, posZ, tiltX, tiltY, tiltZ) ->


[source]

Params

posX: number? --(Default: `0`)
posY: number? --(Default: `0`)
posZ: number? --(Default: `0`)
tiltX: number? --(Default: `0`)
tiltY: number? --(Default: `0`)
tiltZ: number? --(Default: `0`)

Returns

: nil

fn SetCameraState (cameraState, transitionTime, transitionTimeFactor, transitionTimeExponent) -> set


Set camera state.

[source]


Params

cameraState: CameraState --The fields must be consistent with the name/mode and current/new camera mode.
transitionTime: number? --(Default: `0`) in nanoseconds
transitionTimeFactor: number?
transitionTimeExponent: number?

Returns

set: boolean --`true` when applied without errors, otherwise `false`.

fn RunDollyCamera (runtime) ->


Runs Dolly Camera

[source]


Params

runtime: number --Runtime in milliseconds.

Returns

: nil

fn PauseDollyCamera (fraction) ->


Pause Dolly Camera

[source]


Params

fraction: number --Fraction of the total runtime to pause at, 0 to 1 inclusive. A null value pauses at current percent

Returns

: nil

fn ResumeDollyCamera () ->


Resume Dolly Camera

[source]


Returns

: nil

fn SetDollyCameraPosition (x, y, z) ->


Sets Dolly Camera Position

[source]


Params

x: number
y: number
z: number

Returns

: nil

fn SetDollyCameraCurve (degree, cpoints, knots) ->


Sets Dolly Camera movement Curve

[source]


Params

degree: number
cpoints: ControlPoint[] --NURBS control point positions.
knots: table

Returns

: nil

fn SetDollyCameraMode (mode) ->


Sets Dolly Camera movement mode

[source]


Params

mode: (1|2) --`1` static position, `2` nurbs curve

Returns

: nil

fn SetDollyCameraRelativeMode (relativeMode) ->


Sets Dolly Camera movement curve to world relative or look target relative

[source]


Params

relativeMode: number --`1` world, `2` look target

Returns

: nil

fn SetDollyCameraLookCurve (degree, cpoints, knots) ->


Sets Dolly Camera Look Curve

[source]


Params

degree: number
cpoints: ControlPoint[] --NURBS control point positions.
knots: table

Returns

: nil

fn SetDollyCameraLookPosition (x, y, z) ->


Sets Dolly Camera Look Position

[source]


Params

x: number
y: number
z: number

Returns

: nil

fn SetDollyCameraLookUnit (unitID) ->


Sets target unit for Dolly Camera to look towards

[source]


Params

unitID: integer --The unit to look at.

Returns

: nil

fn SelectUnit (unitID, append) ->


Selects a single unit

[source]


Params

unitID: integer?
append: boolean? --(Default: `false`) Append to current selection.

Returns

: nil

fn DeselectUnit (unitID) ->


[source]

Params

unitID: integer

Returns

: nil

fn DeselectUnitArray (unitIDs) ->


Deselects multiple units.

[source]


Params

unitIDs: integer[] --Table with unit IDs as values.

Returns

: nil

fn DeselectUnitMap (unitMap) ->


Deselects multiple units.

[source]


Params

unitMap: table<integer,any> --Table with unit IDs as keys.

Returns

: nil

fn SelectUnitArray (unitIDs, append) ->


Selects multiple units, or appends to selection. Accepts a table with unitIDs as values

[source]


Params

unitIDs: integer[] --Table with unit IDs as values.
append: boolean? --(Default: `false`) append to current selection

Returns

: nil

fn SelectUnitMap (unitMap, append) ->


Selects multiple units, or appends to selection. Accepts a table with unitIDs as keys

[source]


Params

unitMap: table<integer,any> --Table with unit IDs as keys.
append: boolean? --(Default: `false`) append to current selection

Returns

: nil

fn AddMapLight (lightParams) -> lightHandle


[source]

requires MaxDynamicMapLights > 0


Params

lightParams: LightParams

Returns

lightHandle: integer

fn AddModelLight (lightParams) -> lightHandle


[source]

requires MaxDynamicMapLights > 0


Params

lightParams: LightParams

Returns

lightHandle: number

fn UpdateMapLight (lightHandle, lightParams) -> success


[source]

Params

lightHandle: number
lightParams: LightParams

Returns

success: boolean

fn UpdateModelLight (lightHandle, lightParams) -> success


[source]

Params

lightHandle: number
lightParams: LightParams

Returns

success: boolean

fn AddLightTrackingTarget ()


[source]

fn SetMapLightTrackingState (lightHandle, unitOrProjectileID, enableTracking, unitOrProjectile) -> success


Set a map-illuminating light to start/stop tracking the position of a moving object (unit or projectile)

[source]


Params

lightHandle: number
unitOrProjectileID: integer
enableTracking: boolean
unitOrProjectile: boolean

Returns

success: boolean

fn SetModelLightTrackingState (lightHandle, unitOrProjectileID, enableTracking, unitOrProjectile) -> success


Set a model-illuminating light to start/stop tracking the position of a moving object (unit or projectile)

[source]


Params

lightHandle: number
unitOrProjectileID: integer
enableTracking: boolean
unitOrProjectile: boolean

Returns

success: boolean

fn SetMapShader (standardShaderID, deferredShaderID) ->


[source]

The ID’s must refer to valid programs returned by gl.CreateShader. Passing in a value of 0 will cause the respective shader to revert back to its engine default. Custom map shaders that declare a uniform ivec2 named “texSquare” can sample from the default diffuse texture(s), which are always bound to TU 0.


Params

standardShaderID: integer
deferredShaderID: integer

Returns

: nil

fn SetMapSquareTexture (texSqrX, texSqrY, luaTexName) -> success


[source]

Params

texSqrX: number
texSqrY: number
luaTexName: string

Returns

success: boolean

fn SetMapShadingTexture (texType, texName) -> success


[source]

Params

texType: string
texName: string

Returns

success: boolean

fn SetSkyBoxTexture (texName) ->


[source]

Params

texName: string

Returns

: nil

fn SetUnitNoDraw (unitID, noDraw) ->


[source]

Params

unitID: integer
noDraw: boolean

Returns

: nil

fn SetUnitEngineDrawMask (unitID, drawMask) ->


[source]

Params

unitID: integer
drawMask: number

Returns

: nil

fn SetUnitAlwaysUpdateMatrix (unitID, alwaysUpdateMatrix) ->


[source]

Params

unitID: integer
alwaysUpdateMatrix: boolean

Returns

: nil

fn SetUnitNoMinimap (unitID, unitNoMinimap) ->


[source]

Params

unitID: integer
unitNoMinimap: boolean

Returns

: nil

fn SetMiniMapRotation (rotation) ->


[source]

Params

rotation: number --amount in radians

Returns

: nil

fn SetUnitNoGroup (unitID, unitNoGroup)


[source]

Params

unitID: integer
unitNoGroup: boolean --Whether unit can be added to selection groups

fn SetUnitNoSelect (unitID, unitNoSelect) ->


[source]

Params

unitID: integer
unitNoSelect: boolean --whether unit can be selected or not

Returns

: nil

fn SetUnitLeaveTracks (unitID, unitLeaveTracks) ->


[source]

Params

unitID: integer
unitLeaveTracks: boolean --whether unit leaves tracks on movement

Returns

: nil

fn SetUnitSelectionVolumeData (unitID, featureID, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, vType, tType, Axis) ->


[source]

Params

unitID: integer
featureID: integer
scaleX: number
scaleY: number
scaleZ: number
offsetX: number
offsetY: number
offsetZ: number
vType: number
tType: number
Axis: number

Returns

: nil

fn SetFeatureNoDraw (featureID, noDraw) ->


[source]

Params

featureID: integer
noDraw: boolean

Returns

: nil

fn SetFeatureEngineDrawMask (featureID, engineDrawMask) ->


[source]

Params

featureID: integer
engineDrawMask: number

Returns

: nil

fn SetFeatureAlwaysUpdateMatrix (featureID, alwaysUpdateMat) ->


[source]

Params

featureID: integer
alwaysUpdateMat: number

Returns

: nil

fn SetFeatureFade (featureID, allow) ->


Control whether a feature will fade or not when zoomed out.

[source]


Params

featureID: integer
allow: boolean

Returns

: nil

fn SetFeatureSelectionVolumeData (featureID, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, vType, tType, Axis) ->


[source]

Params

featureID: integer
scaleX: number
scaleY: number
scaleZ: number
offsetX: number
offsetY: number
offsetZ: number
vType: number
tType: number
Axis: number

Returns

: nil

fn AddUnitIcon (iconName, texFile, size, dist, radAdjust) -> added


[source]

Params

iconName: string
texFile: string
size: number?
dist: number?
radAdjust: number?

Returns

added: boolean

fn FreeUnitIcon (iconName) -> freed


[source]

Params

iconName: string

Returns

freed: boolean?

fn UnitIconSetDraw (unitID, drawIcon) ->


[source]

Use Spring.SetUnitIconDraw instead.


Params

unitID: integer
drawIcon: boolean

Returns

: nil

fn SetUnitIconDraw (unitID, drawIcon) ->


[source]

Params

unitID: integer
drawIcon: boolean

Returns

: nil

fn SetUnitDefIcon (unitDefID, iconName) ->


[source]

Params

unitDefID: integer
iconName: string

Returns

: nil

fn SetUnitDefImage (unitDefID, image) ->


[source]

Params

unitDefID: integer
image: string --luaTexture|texFile

Returns

: nil

fn ExtractModArchiveFile (modfile) -> extracted


[source]

Params

modfile: string

Returns

extracted: boolean

fn CreateDir (path) -> dirCreated


[source]

Params

path: string

Returns

dirCreated: boolean?

fn SetActiveCommand (action, actionExtra) -> commandSet


[source]

Params

action: string
actionExtra: string?

Returns

commandSet: boolean?

fn SetActiveCommand (cmdIndex, button, leftClick, rightClick, alt, ctrl, meta, shift) -> commandSet


[source]

Params

cmdIndex: number
button: number? --(Default: `1`)
leftClick: boolean?
rightClick: boolean?
alt: boolean?
ctrl: boolean?
meta: boolean?
shift: boolean?

Returns

commandSet: boolean?

fn LoadCmdColorsConfig (config) ->


[source]

Params

config: string

Returns

: nil

fn LoadCtrlPanelConfig (config) ->


[source]

Params

config: string

Returns

: nil

fn ForceLayoutUpdate () ->


[source]

Returns

: nil

fn SetDrawSelectionInfo (enable) ->


Disables the “Selected Units x” box in the GUI.

[source]


Params

enable: boolean

Returns

: nil

fn SetBoxSelectionByEngine (state) ->


[source]

Params

state: boolean

Returns

: nil

fn SetTeamColor (teamID, r, g, b) ->


[source]

Params

teamID: integer
r: number
g: number
b: number

Returns

: nil

fn AssignMouseCursor (cmdName, iconFileName, overwrite, hotSpotTopLeft) -> assigned


Changes/creates the cursor of a single CursorCmd.

[source]


Params

cmdName: string
iconFileName: string --not the full filename, instead it is like this: Wanted filename: Anims/cursorattack_0.bmp => iconFileName: cursorattack
overwrite: boolean? --(Default: `true`)
hotSpotTopLeft: boolean? --(Default: `false`)

Returns

assigned: boolean?

fn ReplaceMouseCursor (oldFileName, newFileName, hotSpotTopLeft) -> assigned


Mass replace all occurrences of the cursor in all CursorCmds.

[source]


Params

oldFileName: string
newFileName: string
hotSpotTopLeft: boolean? --(Default: `false`)

Returns

assigned: boolean?

fn SetCustomCommandDrawData (cmdID, cmdReference, color, showArea) ->


Register your custom cmd so it gets visible in the unit’s cmd queue

[source]


Params

cmdID: integer
cmdReference: (string|integer)? --The name or ID of an icon for command. Pass `nil` to clear draw data for command.
color: rgba? --(Default: white)
showArea: boolean? --(Default: `false`)

Returns

: nil

fn WarpMouse (x, y) ->


[source]

Params

x: number
y: number

Returns

: nil

fn SetMouseCursor (cursorName, cursorScale) ->


[source]

Params

cursorName: string
cursorScale: number? --(Default: `1.0`)

Returns

: nil

fn SetLosViewColors (always, LOS, radar, jam, radar2) ->


[source]

Params

always: rgb
LOS: rgb
radar: rgb
jam: rgb
radar2: rgb

Returns

: nil

fn SetNanoProjectileParams (rotVal, rotVel, rotAcc, rotValRng, rotVelRng, rotAccRng) ->


[source]

Params

rotVal: number? --(Default: `0`) in degrees
rotVel: number? --(Default: `0`) in degrees
rotAcc: number? --(Default: `0`) in degrees
rotValRng: number? --(Default: `0`) in degrees
rotVelRng: number? --(Default: `0`) in degrees
rotAccRng: number? --(Default: `0`) in degrees

Returns

: nil

fn SetConfigInt (name, value, useOverlay) ->


[source]

Params

name: string
value: integer
useOverlay: boolean? --(Default: `false`) If `true`, the value will only be set in memory, and not be restored for the next game.

Returns

: nil

fn SetConfigFloat (name, value, useOverlay) ->


[source]

Params

name: string
value: number
useOverlay: boolean? --(Default: `false`) If `true`, the value will only be set in memory, and not be restored for the next game.

Returns

: nil

fn SetConfigString (name, value, useOverlay) ->


[source]

Params

name: string
value: string
useOverlay: boolean? --(Default: `false`) If `true`, the value will only be set in memory, and not be restored for the next game.

Returns

: nil

fn Quit () ->


Closes the application

[source]


Returns

: nil

fn SetUnitGroup (unitID, groupID) ->


[source]

Params

unitID: integer
groupID: integer --the group number to be assigned, or -1 for deassignment

Returns

: nil

fn GiveOrder (cmdID, params, options, timeout) ->


Give order to selected units.

[source]


Params

cmdID: (CMD|integer) --The command ID.
params: CreateCommandParams --Parameters for the given command.
options: CreateCommandOptions?
timeout: integer? --Absolute frame number. The command will be discarded after this frame. Only respected by mobile units.

Returns

: boolean

fn GiveOrderToUnit (unitID, cmdID, params, options, timeout) ->


Give order to specific unit.

[source]


Params

unitID: integer
cmdID: (CMD|integer) --The command ID.
params: CreateCommandParams? --Parameters for the given command.
options: CreateCommandOptions?
timeout: integer? --Absolute frame number. The command will be discarded after this frame. Only respected by mobile units.

Returns

: boolean

fn GiveOrderToUnitMap (unitMap, cmdID, params, options, timeout) -> orderGiven


Give order to multiple units, specified by table keys.

[source]


Params

unitMap: table<integer,any> --A table with unit IDs as keys.
cmdID: (CMD|integer) --The command ID.
params: CreateCommandParams? --Parameters for the given command.
options: CreateCommandOptions?
timeout: integer? --Absolute frame number. The command will be discarded after this frame. Only respected by mobile units.

Returns

orderGiven: boolean

fn GiveOrderToUnitArray (unitIDs, cmdID, params, options, timeout) -> ordersGiven


Give order to an array of units.

[source]


Params

unitIDs: integer[] --Array of unit IDs.
cmdID: (CMD|integer) --The command ID.
params: CreateCommandParams? --Parameters for the given command.
options: CreateCommandOptions?
timeout: integer? --Absolute frame number. The command will be discarded after this frame. Only respected by mobile units.

Returns

ordersGiven: boolean --`true` if any orders were sent, otherwise `false`.

fn GiveOrderArrayToUnit (unitID, commands) -> ordersGiven


[source]

Params

unitID: integer --Unit ID.
commands: CreateCommand[]

Returns

ordersGiven: boolean --`true` if any orders were sent, otherwise `false`.

fn GiveOrderArrayToUnitMap (unitMap, commands) -> ordersGiven


[source]

Params

unitMap: table<integer,any> --A table with unit IDs as keys.
commands: CreateCommand[]

Returns

ordersGiven: boolean --`true` if any orders were sent, otherwise `false`.

fn GiveOrderArrayToUnitArray (unitIDs, commands, pairwise) -> ordersGiven


[source]

Params

unitIDs: integer[] --Array of unit IDs.
commands: CreateCommand[]
pairwise: boolean? --(Default: `false`) When `false`, assign all commands to each unit. When `true`, assign commands according to index between units and cmds arrays. If `len(unitArray) < len(cmdArray)` only the first `len(unitArray)` commands will be assigned, and vice-versa.

Returns

ordersGiven: boolean --`true` if any orders were sent, otherwise `false`.

fn SetBuildSpacing (spacing) ->


[source]

Params

spacing: number

Returns

: nil

fn SetBuildFacing (facing) ->


[source]

Params

facing: FacingInteger

Returns

: nil

fn SendLuaUIMsg (message, mode) ->


[source]

Params

message: string
mode: string --"s"/"specs" | "a"/"allies"

Returns

: nil

fn SendLuaGaiaMsg (message) ->


[source]

Params

message: string

Returns

: nil

fn SendLuaRulesMsg (message) ->


[source]

Params

message: string

Returns

: nil

fn SendLuaMenuMsg (msg)


[source]

Params

msg: string

fn SetShareLevel (resource, shareLevel) ->


[source]

Params

resource: string --metal | energy
shareLevel: number

Returns

: nil

fn ShareResources (teamID, units) ->


[source]

Params

teamID: integer
units: string

Returns

: nil

fn ShareResources (teamID, resource, amount) ->


[source]

Params

teamID: integer
resource: string --metal | energy
amount: number

Returns

: nil

fn SetLastMessagePosition (x, y, z) ->


[source]

Params

x: number
y: number
z: number

Returns

: nil

fn MarkerAddPoint (x, y, z, text, localOnly) ->


[source]

Params

x: number
y: number
z: number
text: string? --(Default: `""`)
localOnly: boolean?

Returns

: nil

fn MarkerAddLine (x1, y1, z1, x2, y2, z2, localOnly, playerId) ->


[source]

Params

x1: number
y1: number
z1: number
x2: number
y2: number
z2: number
localOnly: boolean? --(Default: `false`)
playerId: number?

Returns

: nil

fn MarkerErasePosition (x, y, z, unused, localOnly, playerId, alwaysErase) ->


[source]

Issue an erase command for markers on the map.


Params

x: number
y: number
z: number
unused: nil --This argument is ignored.
localOnly: boolean? --(Default: `false`) do not issue a network message, erase only for the current player
playerId: number? --when not specified it uses the issuer playerId
alwaysErase: boolean? --(Default: `false`) erase any marker when `localOnly` and current player is spectating. Allows spectators to erase players markers locally

Returns

: nil

fn SetAtmosphere (params)


Set atmosphere parameters

[source]


Params

params: AtmosphereParams

fn SetSunDirection (dirX, dirY, dirZ, intensity) ->


[source]

Params

dirX: number
dirY: number
dirZ: number
intensity: number? --(Default: `1.0`)

Returns

: nil

fn SetSunLighting (params)


Modify sun lighting parameters.

Spring.SetSunLighting({groundAmbientColor = {1, 0.1, 1}, groundDiffuseColor = {1, 0.1, 1} })

[source]


Params

params: { groundAmbientColor: rgb, groundDiffuseColor: rgb }

fn SetMapRenderingParams (params) ->


Allows to change map rendering params at runtime.

[source]


Params

params: MapRenderingParams

Returns

: nil

fn ForceTesselationUpdate (normal, shadow) -> updated


[source]

Params

normal: boolean? --(Default: `true`)
shadow: boolean? --(Default: `false`)

Returns

updated: boolean

fn SendSkirmishAIMessage (aiTeam, message) -> ai_processed


[source]

Params

aiTeam: number
message: string

Returns

ai_processed: boolean?

fn SetLogSectionFilterLevel (sectionName, logLevel) ->


[source]

Params

sectionName: string
logLevel: (string|number)?

Returns

: nil

fn GarbageCollectCtrl (itersPerBatch, numStepsPerIter, minStepsPerIter, maxStepsPerIter, minLoopRunTime, maxLoopRunTime, baseRunTimeMult, baseMemLoadMult) ->


[source]

Params

itersPerBatch: integer?
numStepsPerIter: integer?
minStepsPerIter: integer?
maxStepsPerIter: integer?
minLoopRunTime: number?
maxLoopRunTime: number?
baseRunTimeMult: number?
baseMemLoadMult: number?

Returns

: nil

fn SetAutoShowMetal (autoShow) ->


[source]

Params

autoShow: boolean

Returns

: nil

fn SetDrawSky (drawSky) ->


[source]

Params

drawSky: boolean

Returns

: nil

fn SetDrawWater (drawWater) ->


[source]

Params

drawWater: boolean

Returns

: nil

fn SetDrawGround (drawGround) ->


[source]

Params

drawGround: boolean

Returns

: nil

fn SetDrawGroundDeferred (drawGroundDeferred, drawGroundForward) ->


[source]

Params

drawGroundDeferred: boolean
drawGroundForward: boolean? --allows disabling of the forward pass

Returns

: nil

fn SetDrawModelsDeferred (drawUnitsDeferred, drawFeaturesDeferred, drawUnitsForward, drawFeaturesForward) ->


[source]

Params

drawUnitsDeferred: boolean
drawFeaturesDeferred: boolean
drawUnitsForward: boolean? --allows disabling of the respective forward passes
drawFeaturesForward: boolean? --allows disabling of the respective forward passes

Returns

: nil

fn SetVideoCapturingMode (allowCaptureMode) ->


This doesn’t actually record the game in any way, it just regulates the framerate and interpolations.

[source]


Params

allowCaptureMode: boolean

Returns

: nil

fn SetVideoCapturingTimeOffset (timeOffset) ->


[source]

Params

timeOffset: boolean

Returns

: nil

fn SetWaterParams (waterParams) ->


Does not need cheating enabled.

Allows to change water params (mostly BumpWater ones) at runtime. You may want to set BumpWaterUseUniforms in your springrc to 1, then you don’t even need to restart BumpWater via /water 4.

[source]


Params

waterParams: WaterParams

Returns

: nil

fn PreloadUnitDefModel (unitDefID) ->


[source]

Allow the engine to load the unit’s model (and texture) in a background thread. Wreckages and buildOptions of a unit are automatically preloaded.


Params

unitDefID: integer

Returns

: nil

fn PreloadFeatureDefModel (featureDefID) ->


[source]

Params

featureDefID: integer

Returns

: nil

fn PreloadSoundItem (name) ->


[source]

Params

name: string

Returns

: nil

fn LoadModelTextures (modelName) -> success


[source]

Params

modelName: string

Returns

success: boolean?

fn CreateGroundDecal () -> decalID


[source]

Returns

decalID: number?

fn DestroyGroundDecal (decalID) -> delSuccess


[source]

Params

decalID: integer

Returns

delSuccess: boolean

fn SetGroundDecalPosAndDims (decalID, midPosX, midPosZ, sizeX, sizeZ, projCubeHeight) -> decalSet


[source]

Params

decalID: integer
midPosX: number? --(Default: currMidPosX)
midPosZ: number? --(Default: currMidPosZ)
sizeX: number? --(Default: currSizeX)
sizeZ: number? --(Default: currSizeZ)
projCubeHeight: number? --(Default: calculateProjCubeHeight)

Returns

decalSet: boolean

fn SetGroundDecalQuadPosAndHeight (decalID, posTL, posTR, posBR, posBL, projCubeHeight) -> decalSet


[source]

Use for non-rectangular decals


Params

decalID: integer
posTL: xz? --(Default: currPosTL)
posTR: xz? --(Default: currPosTR)
posBR: xz? --(Default: currPosBR)
posBL: xz? --(Default: currPosBL)
projCubeHeight: number? --(Default: calculateProjCubeHeight)

Returns

decalSet: boolean

fn SetGroundDecalRotation (decalID, rot) -> decalSet


[source]

Params

decalID: integer
rot: number? --(Default: random) in radians

Returns

decalSet: boolean

fn SetGroundDecalTexture (decalID, textureName, isMainTex) -> decalSet


[source]

Params

decalID: integer
textureName: string --The texture has to be on the atlas which seems to mean it's defined as an explosion, unit tracks, or building plate decal on some unit already (no arbitrary textures)
isMainTex: boolean? --(Default: `true`) If false, it sets the normals/glow map

Returns

decalSet: boolean?

fn SetGroundDecalTextureParams (decalID, texWrapDistance, texTraveledDistance) -> decalSet


[source]

Params

decalID: integer
texWrapDistance: number? --(Default: currTexWrapDistance) if non-zero sets the mode to repeat the texture along the left-right direction of the decal every texWrapFactor elmos
texTraveledDistance: number? --(Default: currTexTraveledDistance) shifts the texture repetition defined by texWrapFactor so the texture of a next line in the continuous multiline can start where the previous finished. For that it should collect all elmo lengths of the previously set multiline segments.

Returns

decalSet: boolean?

fn SetGroundDecalAlpha (decalID, alpha, alphaFalloff) -> decalSet


[source]

Params

decalID: integer
alpha: number? --(Default: currAlpha) Between 0 and 1
alphaFalloff: number? --(Default: currAlphaFalloff) Between 0 and 1, per second

Returns

decalSet: boolean

fn SetGroundDecalNormal (decalID, normalX, normalY, normalZ) -> decalSet


[source]

Sets projection cube normal to orient in 3D space. In case the normal (0,0,0) then normal is picked from the terrain


Params

decalID: integer
normalX: number? --(Default: `0`)
normalY: number? --(Default: `0`)
normalZ: number? --(Default: `0`)

Returns

decalSet: boolean

fn SetGroundDecalTint (decalID, tintColR, tintColG, tintColB, tintColA) -> decalSet


[source]

Sets the tint of the ground decal. Color = 2 * textureColor * tintColor Respectively a color of (0.5, 0.5, 0.5, 0.5) is effectively no tint


Params

decalID: integer
tintColR: number? --(Default: curTintColR)
tintColG: number? --(Default: curTintColG)
tintColB: number? --(Default: curTintColB)
tintColA: number? --(Default: curTintColA)

Returns

decalSet: boolean

fn SetGroundDecalMisc (decalID, dotElimExp, refHeight, minHeight, maxHeight, forceHeightMode) -> decalSet


[source]

Sets varios secondary parameters of a decal


Params

decalID: integer
dotElimExp: number? --(Default: curValue) pow(max(dot(decalProjVector, SurfaceNormal), 0.0), dotElimExp), used to reduce decal artifacts on surfaces non-collinear with the projection vector
refHeight: number? --(Default: curValue)
minHeight: number? --(Default: curValue)
maxHeight: number? --(Default: curValue)
forceHeightMode: number? --(Default: curValue) in case forceHeightMode==1.0 ==> force relative height: midPoint.y = refHeight + clamp(midPoint.y - refHeight, minHeight); forceHeightMode==2.0 ==> force absolute height: midPoint.y = midPoint.y, clamp(midPoint.y, minHeight, maxHeight); other forceHeightMode values do not enforce the height of the center position

Returns

decalSet: boolean

fn SetGroundDecalCreationFrame (decalID, creationFrameMin, creationFrameMax) -> decalSet


[source]

Use separate min and max for “gradient” style decals such as tank tracks


Params

decalID: integer
creationFrameMin: number? --(Default: currCreationFrameMin)
creationFrameMax: number? --(Default: currCreationFrameMax)

Returns

decalSet: boolean

fn SDLSetTextInputRect (x, y, width, height) ->


[source]

Params

x: number
y: number
width: number
height: number

Returns

: nil

fn SDLStartTextInput () ->


[source]

Returns

: nil

fn SDLStopTextInput () ->


[source]

Returns

: nil

fn SetWindowGeometry (displayIndex, winRelPosX, winRelPosY, winSizeX, winSizeY, fullScreen, borderless) ->


[source]

Params

displayIndex: number
winRelPosX: number
winRelPosY: number
winSizeX: number
winSizeY: number
fullScreen: boolean
borderless: boolean

Returns

: nil

fn SetWindowMinimized () -> minimized


[source]

Returns

minimized: boolean

fn SetWindowMaximized () -> maximized


[source]

Returns

maximized: boolean

fn Reload (startScript) ->


[source]

Params

startScript: string --the CONTENT of the script.txt spring should use to start.

Returns

: nil

fn Restart (commandline_args, startScript) ->


[source]

If this call returns, something went wrong


Params

commandline_args: string --commandline arguments passed to spring executable.
startScript: string

Returns

: nil

fn Start (commandline_args, startScript) ->


Launches a new Spring instance without terminating the existing one.

[source]

If this call returns, something went wrong


Params

commandline_args: string --commandline arguments passed to spring executable.
startScript: string --the CONTENT of the script.txt spring should use to start (if empty, no start-script is added, you can still point spring to your custom script.txt when you add the file-path to commandline_args.

Returns

: nil

fn SetWMIcon (iconFileName) ->


Sets the icon for the process which is seen in the OS task-bar and other places (default: spring-logo).

[source]

Note: has to be 24bit or 32bit. Note: on windows, it has to be 32x32 pixels in size (recommended for cross-platform) Note: *.bmp images have to be in BGR format (default for m$ ones). Note: *.ico images are not supported.


Params

iconFileName: string

Returns

: nil

fn SetWMCaption (title, titleShort) ->


Set the window title for the process

[source]


Params

title: string --(Default: `"Spring <version>"`)
titleShort: string? --(Default: `"Spring <version>"`) displayed in the OS task-bar . > [!NOTE] > shortTitle is only ever possibly used under X11 (Linux & OS X), but not > with QT (KDE) and never under Windows.

Returns

: nil

fn ClearWatchDogTimer (threadName) ->


[source]

Params

threadName: string? --(Default: main)

Returns

: nil

fn SetClipboard (text) ->


[source]

Params

text: string

Returns

: nil

fn Yield () -> when


Relinquish control of the game loading thread and OpenGL context back to the UI (LuaIntro).

[source]

Should be called after each widget/unsynced gadget is loaded in widget/gadget handler. Use it to draw screen updates and process windows events.


Returns

when: boolean --true caller should continue calling `Spring.Yield` during the widgets/gadgets load, when false it shouldn't call it any longer.

fn GetMetalMapSize () -> x, z


[source]

Returns

x: integer --X coordinate in worldspace / `Game.metalMapSquareSize`.
z: integer --Z coordinate in worldspace / `Game.metalMapSquareSize`.

fn GetMetalAmount (x, z) -> amount


Returns the amount of metal on a single square.

[source]


Params

x: integer --X coordinate in worldspace / `Game.metalMapSquareSize`.
z: integer --Z coordinate in worldspace / `Game.metalMapSquareSize`.

Returns

amount: number

fn SetMetalAmount (x, z, metalAmount) ->


Sets the amount of metal on a single square.

[source]


Params

x: integer --X coordinate in worldspace / `Game.metalMapSquareSize`.
z: integer --Z coordinate in worldspace / `Game.metalMapSquareSize`.
metalAmount: number --must be between 0 and 255*maxMetal (with maxMetal from the .smd or mapinfo.lua).

Returns

: nil

fn GetMetalExtraction (x, z) -> extraction


[source]

Params

x: integer --X coordinate in worldspace / `Game.metalMapSquareSize`.
z: integer --Z coordinate in worldspace / `Game.metalMapSquareSize`.

Returns

extraction: number

field MoveCtrl


is MoveCtrl
[source]

fn SetAlly (firstAllyTeamID, secondAllyTeamID, ally) ->


Changes the value of the (one-sided) alliance between: firstAllyTeamID -> secondAllyTeamID.

[source]


Params

firstAllyTeamID: integer
secondAllyTeamID: integer
ally: boolean

Returns

: nil

fn SetAllyTeamStartBox (allyTeamID, xMin, zMin, xMax, zMax) ->


Changes the start box position of an allyTeam.

[source]


Params

allyTeamID: integer
xMin: number --left start box boundary (elmos)
zMin: number --top start box boundary (elmos)
xMax: number --right start box boundary (elmos)
zMax: number --bottom start box boundary (elmos)

Returns

: nil

fn AssignPlayerToTeam (playerID, teamID) ->


Assigns a player to a team.

[source]


Params

playerID: integer
teamID: integer

Returns

: nil

fn SetGlobalLos (allyTeamID, globallos) ->


Changes access to global line of sight for a team and its allies.

[source]


Params

allyTeamID: integer
globallos: boolean

Returns

: nil

fn KillTeam (teamID) ->


Will declare a team to be dead (no further orders can be assigned to such teams units).

[source]

Gaia team cannot be killed.


Params

teamID: integer

Returns

: nil

fn GameOver (winningAllyTeamIDs) -> Number


Declare game over.

[source]


Params

winningAllyTeamIDs: integer[] --A list of winning ally team IDs. Pass multiple winners to declare a draw. Pass no arguments if undecided (e.g. when dropped from the host).

Returns

Number: integer --of accepted (valid) ally teams.

fn SetTidal (strength) ->


Set tidal strength

[source]


Params

strength: number

Returns

: nil

fn SetWind (minStrength, maxStrength) ->


Set wind strength

[source]


Params

minStrength: number
maxStrength: number

Returns

: nil

fn AddTeamResource (teamID, type, amount) ->


Adds metal or energy resources to the specified team.

[source]


Params

teamID: integer
type: ResourceName
amount: number

Returns

: nil

fn UseTeamResource (teamID, type, amount) -> hadEnough


Consumes metal or energy resources of the specified team.

[source]


Params

teamID: integer
type: ResourceName --Resource type.
amount: number --Amount of resource to use.

Returns

hadEnough: boolean

fn UseTeamResource (teamID, amount) -> hadEnough


Consumes metal and/or energy resources of the specified team.

[source]


Params

teamID: integer
amount: ResourceUsage

Returns

hadEnough: boolean

fn SetTeamResource (teamID, resource, amount) ->


[source]

Params

teamID: integer
resource: (ResourceName|StorageName)
amount: number

Returns

: nil

fn SetTeamShareLevel (teamID, type, amount) ->


Changes the resource amount for a team beyond which resources aren’t stored but transferred to other allied teams if possible.

[source]


Params

teamID: integer
type: ResourceName
amount: number

Returns

: nil

fn ShareTeamResource (teamID_src, teamID_recv, type, amount) ->


Transfers resources between two teams.

[source]


Params

teamID_src: integer
teamID_recv: integer
type: ResourceName
amount: number

Returns

: nil

fn SetGameRulesParam (paramName, paramValue, losAccess) ->


[source]

Params

paramName: string
paramValue: (number|string)? --numeric paramValues in quotes will be converted to number.
losAccess: losAccess?

Returns

: nil

fn SetTeamRulesParam (teamID, paramName, paramValue, losAccess) ->


[source]

Params

teamID: integer
paramName: string
paramValue: (number|string)? --numeric paramValues in quotes will be converted to number.
losAccess: losAccess?

Returns

: nil

fn SetPlayerRulesParam (playerID, paramName, paramValue, losAccess) ->


[source]

Params

playerID: integer
paramName: string
paramValue: (number|string)? --numeric paramValues in quotes will be converted to number.
losAccess: losAccess?

Returns

: nil

fn SetUnitRulesParam (unitID, paramName, paramValue, losAccess) ->


[source]

Params

unitID: integer
paramName: string
paramValue: (number|string)? --numeric paramValues in quotes will be converted to number.
losAccess: losAccess?

Returns

: nil

fn SetFeatureRulesParam (featureID, paramName, paramValue, losAccess) ->


[source]

Params

featureID: integer
paramName: string
paramValue: (number|string)? --numeric paramValues in quotes will be converted to number.
losAccess: losAccess?

Returns

: nil

fn CallCOBScript (unitID, funcName, retArgs, ...) ->


[source]

Params

unitID: integer
funcName: (integer|string)? --Function ID or name.
retArgs: integer --Number of values to return.
...: any --Arguments

Returns

: number …

fn GetCOBScriptID (unitID, funcName) -> funcID


[source]

Params

unitID: integer
funcName: string

Returns

funcID: integer?

fn CreateUnit (unitDef, posX, posY, posZ, facing, teamID, build, flattenGround, unitID, builderID) -> unitID


[source]
See: Spring.DestroyUnit

Params

unitDef: (string|integer) --UnitDef name or ID.
posX: number
posY: number
posZ: number
facing: Facing
teamID: integer
build: boolean? --(Default: `false`) The unit is created in "being built" state with zero `buildProgress`.
flattenGround: boolean? --(Default: `true`) The unit flattens ground, if it normally does so.
unitID: integer? --Request a specific unitID.
builderID: integer?

Returns

unitID: integer? --The ID of the created unit, or `nil` if the unit could not be created.

fn DestroyUnit (unitID, selfd, reclaimed, attackerID, cleanupImmediately) ->


[source]
See: Spring.CreateUnit

Params

unitID: integer
selfd: boolean? --(Default: `false`) makes the unit act like it self-destructed.
reclaimed: boolean? --(Default: `false`) don't show any DeathSequences, don't leave a wreckage. This does not give back the resources to the team!
attackerID: integer?
cleanupImmediately: boolean? --(Default: `false`) stronger version of reclaimed, removes the unit unconditionally and makes its ID available for immediate reuse (otherwise it takes a few frames)

Returns

: nil

fn TransferUnit (unitID, newTeamID, given) ->


[source]

Params

unitID: integer
newTeamID: integer
given: boolean? --(Default: `true`) if false, the unit is captured.

Returns

: nil

fn SetUnitCosts (unitID, where) ->


[source]

Params

unitID: integer
where: table<number,number> --keys and values are, respectively and in this order: buildTime=amount, metalCost=amount, energyCost=amount

Returns

: nil

fn SetUnitResourcing (unitID, res, amount) ->


[source]

Params

unitID: integer
res: string
amount: number

Returns

: nil

fn SetUnitResourcing (unitID, res) ->


[source]

Params

unitID: integer
res: table<string,number> --keys are: "[u|c][u|m][m|e]" unconditional | conditional, use | make, metal | energy. Values are amounts

Returns

: nil

fn SetUnitStorage (unitID, res, amount)


[source]

Params

unitID: integer
res: string
amount: number

fn SetUnitStorage (unitID, res)


[source]

Params

unitID: integer
res: ResourceUsage --keys are: "[m|e]" metal | energy. Values are amounts

fn SetUnitTooltip (unitID, tooltip) ->


[source]

Params

unitID: integer
tooltip: string

Returns

: nil

fn SetUnitHealth (unitID, health) ->


[source]

Note, if your game’s custom shading framework doesn’t support reverting into nanoframes then reverting into nanoframes via the “build” tag will fail to render properly.


See: SetUnitHealthAmounts

Params

unitID: integer
health: (number|SetUnitHealthAmounts) --If a number, sets the units health to that value. Pass a table to update health, capture progress, paralyze damage, and build progress.

Returns

: nil

fn SetUnitMaxHealth (unitID, maxHealth) ->


[source]

Params

unitID: integer
maxHealth: number

Returns

: nil

fn SetUnitStockpile (unitID, stockpile, buildPercent) ->


[source]

Params

unitID: integer
stockpile: number?
buildPercent: number?

Returns

: nil

fn SetUnitUseWeapons (unitID, forceUseWeapons, allowUseWeapons) ->


[source]

Params

unitID: integer
forceUseWeapons: number?
allowUseWeapons: number?

Returns

: nil

fn SetUnitWeaponState (unitID, weaponNum, states) ->


[source]

Params

unitID: integer
weaponNum: number
states: WeaponState

Returns

: nil

fn SetUnitWeaponState (unitID, weaponNum, key, value) ->


[source]

Params

unitID: integer
weaponNum: number
key: string
value: number

Returns

: nil

fn SetUnitWeaponDamages (unitID, weaponNum, damages) ->


[source]

Params

unitID: integer
weaponNum: (number|“selfDestruct”|“explode”)
damages: WeaponDamages

Returns

: nil

fn SetUnitWeaponDamages (unitID, weaponNum, key, value) ->


[source]

Params

unitID: integer
weaponNum: (number|“selfDestruct”|“explode”)
key: string
value: number

Returns

: nil

fn SetUnitMaxRange (unitID, maxRange) ->


[source]

Params

unitID: integer
maxRange: number

Returns

: nil

fn SetUnitExperience (unitID, experience) ->


[source]
See: Spring.AddUnitExperience Spring.GetUnitExperience

Params

unitID: integer
experience: number

Returns

: nil

fn AddUnitExperience (unitID, deltaExperience) ->


[source]
See: Spring.SetUnitExperience Spring.GetUnitExperience

Params

unitID: integer
deltaExperience: number --Can be negative to subtract, but the unit will never have negative total afterwards

Returns

: nil

fn SetUnitArmored (unitID, armored, armorMultiple) ->


[source]

Params

unitID: integer
armored: boolean?
armorMultiple: number?

Returns

: nil

fn SetUnitLosMask (unitID, allyTeam, losTypes)


Set visibility status mask for a unit and team

Use this to allow or disallow a unit from having its visibility status against a certain team updated by the engine.

[source]


See: Spring.SetUnitLosState

Params

unitID: integer
allyTeam: number
losTypes: (LosTable|LosMask|integer) --A bitmask of `LosMask` bits or a table. True bits disable engine updates to visibility.

fn SetUnitLosState (unitID, allyTeam, losTypes)


Set current visibility status for a unit and team

Note this state will not be persisted if the visibility state is not masked.

Use it to change visibility state, once you set the unit to not receive engine visibility updates.

A few notes on certain bits:

  • contradar: True when the unit entered los at some point, remains set until radar is lost. Useful for tracking the unit type in radar, if you lost los you still know what unit type that radar dot refers to.
  • prevlos: True when the unit has entered los at least once, useful for tracking building locations (controls whether a ghost appears or not in the location)

[source]


See: Spring.SetUnitLosMask

Params

unitID: integer
allyTeam: number
losTypes: (LosTable|LosMask|integer) --A bitmask of `LosMask` bits or a table

fn SetUnitCloak (unitID, cloak, cloakArg) ->


[source]

If the 2nd argument is a number, the value works like this: 1:=normal cloak 2:=for free cloak (cost no E) 3:=for free + no decloaking (except the unit is stunned) 4:=ultimate cloak (no ecost, no decloaking, no stunned decloak)

The decloak distance is only changed:

  • if the 3th argument is a number or a boolean.
  • if the boolean is false it takes the default decloak distance for that unitdef,
  • if the boolean is true it takes the absolute value of it.

Params

unitID: integer
cloak: (boolean|number)
cloakArg: (boolean|number)

Returns

: nil

fn SetUnitStealth (unitID, stealth) ->


[source]

Params

unitID: integer
stealth: boolean

Returns

: nil

fn SetUnitSonarStealth (unitID, sonarStealth) ->


[source]

Params

unitID: integer
sonarStealth: boolean

Returns

: nil

fn SetUnitSeismicSignature (unitID, seismicSignature) ->


[source]

Params

unitID: integer
seismicSignature: number

Returns

: nil

fn SetUnitLeavesGhost (leavesGhost, leaveDeadGhost)


Set whether unit leaves static radar ghosts.

[source]


Params

leavesGhost: boolean
leaveDeadGhost: boolean? --(Default: `false`) leave a dead ghost behind if disabling and the unit had a live static ghost.

fn SetUnitAlwaysVisible (unitID, alwaysVisible) ->


[source]

Params

unitID: integer
alwaysVisible: boolean

Returns

: nil

fn SetUnitUseAirLos (unitID, useAirLos) ->


[source]

Params

unitID: integer
useAirLos: boolean

Returns

: nil

fn SetUnitMetalExtraction (unitID, depth, range) ->


[source]

Params

unitID: integer
depth: number --corresponds to metal extraction rate
range: number? --similar to "extractsMetal" in unitDefs.

Returns

: nil

fn SetUnitHarvestStorage (unitID, metal) ->


See also harvestStorage UnitDef tag.

[source]


Params

unitID: integer
metal: number

Returns

: nil

fn SetUnitBuildParams (unitID, paramName, value) ->


[source]

Params

unitID: integer
paramName: string --one of `buildRange`|`buildDistance`|`buildRange3D`
value: (number|boolean) --boolean when `paramName` is `buildRange3D`, otherwise number.

Returns

: nil

fn SetUnitBuildSpeed (builderID, buildSpeed, repairSpeed, reclaimSpeed, captureSpeed, terraformSpeed) ->


[source]

Params

builderID: integer
buildSpeed: number
repairSpeed: number?
reclaimSpeed: number?
captureSpeed: number?
terraformSpeed: number?

Returns

: nil

fn SetUnitNanoPieces (builderID, pieces) ->


[source]

This saves a lot of engine calls, by replacing: function script.QueryNanoPiece() return currentpiece end Use it!


Params

builderID: integer
pieces: table

Returns

: nil

fn SetUnitBlocking (unitID, isBlocking, isSolidObjectCollidable, isProjectileCollidable, isRaySegmentCollidable, crushable, blockEnemyPushing, blockHeightChanges) -> isBlocking


[source]

Params

unitID: integer
isBlocking: boolean? --If `true` add this unit to the `GroundBlockingMap`, but only if it collides with solid objects (or is being set to collide with the `isSolidObjectCollidable` argument). If `false`, remove this unit from the `GroundBlockingMap`. No change if `nil`.
isSolidObjectCollidable: boolean? --Enable or disable collision with solid objects, or no change if `nil`.
isProjectileCollidable: boolean? --Enable or disable collision with projectiles, or no change if `nil`.
isRaySegmentCollidable: boolean? --Enable or disable collision with ray segments, or no change if `nil`.
crushable: boolean? --Enable or disable crushable, or no change if `nil`.
blockEnemyPushing: boolean? --Enable or disable blocking enemy pushing, or no change if `nil`.
blockHeightChanges: boolean? --Enable or disable blocking height changes, or no change if `nil`.

Returns

isBlocking: boolean

fn SetUnitCrashing (unitID, crashing) -> success


[source]

Params

unitID: integer
crashing: boolean

Returns

success: boolean

fn SetUnitShieldState (unitID, weaponID, enabled, power) ->


[source]

Params

unitID: integer
weaponID: integer? --(Default: `-1`)
enabled: boolean?
power: number?

Returns

: nil

fn SetUnitShieldRechargeDelay (unitID, weaponID, rechargeTime) ->


[source]

Params

unitID: integer
weaponID: integer? --(optional if the unit only has one shield)
rechargeTime: number? --(in seconds; emulates a regular hit if nil)

Returns

: nil

fn SetUnitFlanking (unitID, type, arg1, y, z) ->


[source]

Params

unitID: integer
type: string --"dir"|"minDamage"|"maxDamage"|"moveFactor"|"mode"
arg1: number --x|minDamage|maxDamage|moveFactor|mode
y: number? --only when type is "dir"
z: number? --only when type is "dir"

Returns

: nil

fn SetUnitPhysicalStateBit (unitID, Physical) ->


[source]

Params

unitID: integer
Physical:

Returns

: nil

fn GetUnitPhysicalState (unitID) -> Unit


[source]

Params

unitID: integer

Returns

Unit: number --'s PhysicalState bitmask

fn SetUnitNeutral (unitID, neutral) -> setNeutral


[source]

Params

unitID: integer
neutral: boolean

Returns

setNeutral: boolean?

fn SetUnitTarget (unitID, enemyUnitID, dgun, userTarget, weaponNum) -> success


Defines a unit’s target.

[source]


Params

unitID: integer
enemyUnitID: integer? --when nil drops the units current target.
dgun: boolean? --(Default: `false`)
userTarget: boolean? --(Default: `false`)
weaponNum: number? --(Default: `-1`)

Returns

success: boolean

fn SetUnitTarget (unitID, x, y, z, dgun, userTarget, weaponNum) -> success


[source]

Params

unitID: integer
x: number? --when nil or not passed it will drop target and ignore other parameters
y: number?
z: number?
dgun: boolean? --(Default: `false`)
userTarget: boolean? --(Default: `false`)
weaponNum: number? --(Default: `-1`)

Returns

success: boolean

fn SetUnitMidAndAimPos (unitID, mpX, mpY, mpZ, apX, apY, apZ, relative) -> success


[source]

Params

unitID: integer
mpX: number --new middle positionX of unit
mpY: number --new middle positionY of unit
mpZ: number --new middle positionZ of unit
apX: number --new positionX that enemies aim at on this unit
apY: number --new positionY that enemies aim at on this unit
apZ: number --new positionZ that enemies aim at on this unit
relative: boolean? --(Default: `false`) are the new coordinates relative to world (false) or unit (true) coordinates? Also, note that apy is inverted!

Returns

success: boolean

fn SetUnitRadiusAndHeight (unitID, radius, height) -> success


[source]

Params

unitID: integer
radius: number
height: number

Returns

success: boolean

fn SetUnitBuildeeRadius (unitID, build) ->


[source]

Sets the unit’s radius for when targeted by build, repair, reclaim-type commands.


Params

unitID: integer
build: number --radius for when targeted by build, repair, reclaim-type commands.

Returns

: nil

fn SetUnitPieceParent (unitID, AlteredPiece, ParentPiece) ->


Changes the pieces hierarchy of a unit by attaching a piece to a new parent.

[source]


Params

unitID: integer
AlteredPiece: number
ParentPiece: number

Returns

: nil

fn SetUnitPieceMatrix (unitID, pieceNum, matrix) ->


Sets the local (i.e. parent-relative) matrix of the given piece.

[source]

If any of the first three elements are non-zero, and also blocks all script animations from modifying it until {0, 0, 0} is passed.


Params

unitID: integer
pieceNum: number
matrix: number[] --an array of 16 floats

Returns

: nil

fn SetUnitCollisionVolumeData (unitID, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, vType, tType, Axis) -> enum


[source]

Params

unitID: integer
scaleX: number
scaleY: number
scaleZ: number
offsetX: number
offsetY: number
offsetZ: number
vType: number
tType: number
Axis: number

Returns

enum: nil --COLVOL_TYPES { COLVOL_TYPE_DISABLED = -1, COLVOL_TYPE_ELLIPSOID = 0, COLVOL_TYPE_CYLINDER, COLVOL_TYPE_BOX, COLVOL_TYPE_SPHERE, COLVOL_NUM_TYPES // number of non-disabled collision volume types }; enum COLVOL_TESTS { COLVOL_TEST_DISC = 0, COLVOL_TEST_CONT = 1, COLVOL_NUM_TESTS = 2 // number of tests }; enum COLVOL_AXES { COLVOL_AXIS_X = 0, COLVOL_AXIS_Y = 1, COLVOL_AXIS_Z = 2, COLVOL_NUM_AXES = 3 // number of collision volume axes };

fn SetUnitPieceCollisionVolumeData (unitID, pieceIndex, enable, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, volumeType, primaryAxis) ->


[source]

Params

unitID: integer
pieceIndex: number
enable: boolean
scaleX: number
scaleY: number
scaleZ: number
offsetX: number
offsetY: number
offsetZ: number
volumeType: number?
primaryAxis: number?

Returns

: nil

fn SetUnitPieceVisible (unitID, pieceIndex, visible) ->


[source]

Params

unitID: integer
pieceIndex: number
visible: boolean

Returns

: nil

fn SetUnitSensorRadius (unitID, type, radius) -> New


[source]

Params

unitID: integer
type: (“los”|“airLos”|“radar”|“sonar”|“seismic”|“radarJammer”…)
radius: number

Returns

New: number? --radius, or `nil` if unit is invalid.

fn SetUnitPosErrorParams (unitID, posErrorVectorX, posErrorVectorY, posErrorVectorZ, posErrorDeltaX, posErrorDeltaY, posErrorDeltaZ, nextPosErrorUpdate) ->


Sets a unit’s radar wobble

Controls how much a unit’s radar dot will wobble. Note that setting this above the allyTeam’s default wobble may result in the edgemost dot positions failing to register in ray traces, i.e. things like native “is under cursor” checks and some Lua interfaces.

[source]


Params

unitID: integer
posErrorVectorX: number
posErrorVectorY: number
posErrorVectorZ: number
posErrorDeltaX: number
posErrorDeltaY: number
posErrorDeltaZ: number
nextPosErrorUpdate: number?

Returns

: nil

fn SetUnitMoveGoal (unitID, goalX, goalY, goalZ, goalRadius, moveSpeed, moveRaw) ->


Used by default commands to get in build-, attackrange etc.

[source]


Params

unitID: integer
goalX: number
goalY: number
goalZ: number
goalRadius: number?
moveSpeed: number?
moveRaw: boolean?

Returns

: nil

fn SetUnitLandGoal (unitID, goalX, goalY, goalZ, goalRadius) ->


Used in conjunction with Spring.UnitAttach et al. to re-implement old airbase & fuel system in Lua.

[source]


Params

unitID: integer
goalX: number
goalY: number
goalZ: number
goalRadius: number?

Returns

: nil

fn ClearUnitGoal (unitID) ->


[source]

Params

unitID: integer

Returns

: nil

fn SetUnitPhysics (unitID, posX, posY, posZ, velX, velY, velZ, rotX, rotY, rotZ, dragX, dragY, dragZ) ->


[source]

Params

unitID: integer
posX: number
posY: number
posZ: number
velX: number
velY: number
velZ: number
rotX: number
rotY: number
rotZ: number
dragX: number
dragY: number
dragZ: number

Returns

: nil

fn SetUnitMass (unitID, mass) ->


[source]

Params

unitID: integer
mass: number

Returns

: nil

fn SetUnitPosition (unitID, x, z, floating) ->


Set unit position (2D)

[source]

Sets a unit’s position in 2D, at terrain height.


Params

unitID: integer
x: number
z: number
floating: boolean? --(Default: `false`) If true, over water the position is on surface. If false, on seafloor.

Returns

: nil

fn SetUnitPosition (unitID, x, y, z) ->


Set unit position (3D)

[source]

Sets a unit’s position in 3D, at an arbitrary height.


Params

unitID: integer
x: number
y: number
z: number

Returns

: nil

fn SetUnitRotation (unitID, pitch, yaw, roll) ->


[source]

Note: PYR order


Params

unitID: integer
pitch: number --Rotation in X axis
yaw: number --Rotation in Y axis
roll: number --Rotation in Z axis

Returns

: nil

fn SetUnitDirection (unitID, frontx, fronty, frontz) ->


[source]

Set unit front direction vector. The vector is normalized in the engine.


Params

unitID: integer
frontx: number
fronty: number
frontz: number

Returns

: nil

fn SetUnitDirection (unitID, frontx, fronty, frontz, rightx, righty, rightz) ->


[source]

Set unit front and right direction vectors.

Both vectors will be normalized in the engine.


Params

unitID: integer
frontx: number
fronty: number
frontz: number
rightx: number
righty: number
rightz: number

Returns

: nil

fn SetUnitHeadingAndUpDir (unitID, heading, upx, upy, upz) ->


[source]

Use this call to set up unit direction in a robust way. If unit was completely upright, new {upx, upy, upz} direction will be used as new “up” vector, the rotation set by “heading” will remain preserved.


Params

unitID: integer
heading: Heading
upx: number
upy: number
upz: number

Returns

: nil

fn SetUnitVelocity (unitID, velX, velY, velZ)


Set the velocity of a Unit

[source]


See: Spring.SetUnitMoveCtrl for disabling/enabling this control

Params

unitID: integer
velX: number --in elmos/frame
velY: number --in elmos/frame
velZ: number --in elmos/frame

fn SetFactoryBuggerOff (unitID, buggerOff, offset, radius, relHeading, spherical, forced) -> buggerOff


[source]

Params

unitID: integer
buggerOff: boolean?
offset: number?
radius: number?
relHeading: Heading?
spherical: boolean?
forced: boolean?

Returns

buggerOff: number?

fn BuggerOff (x, y, z, radius, teamID, spherical, forced, excludeUnitID, excludeUnitDefIDs) ->


[source]

Params

x: number
y: number
z: number? --uses ground height when unspecified
radius: number
teamID: integer
spherical: boolean? --(Default: `true`)
forced: boolean? --(Default: `true`)
excludeUnitID: integer?
excludeUnitDefIDs: number[]?

Returns

: nil

fn AddFeatureDamage (featureID, damage, paralyze, attackerID, weaponID, impulseX, impulseY, impulseZ)


Apply damage to feature

[source]

Will trigger FeaturePreDamaged and FeatureDamaged callins.

Won’t do anything if paralyze is not zero, the feature is already marked for deletion, or in void.

If health goes below 0 and featureDef is destructable the feature will be deleted and a wreck created.


See: SyncedCallins:FeaturePreDamaged SyncedCallins:FeatureDamaged

Params

featureID: integer
damage: number
paralyze: number? --(Default: `0`) equals to the paralyzetime in the WeaponDef.
attackerID: integer? --(Default: `-1`)
weaponID: integer? --(Default: `-1`)
impulseX: number?
impulseY: number?
impulseZ: number?

fn AddUnitDamage (unitID, damage, paralyze, attackerID, weaponID, impulseX, impulseY, impulseZ) ->


[source]

Params

unitID: integer
damage: number
paralyze: number? --(Default: `0`) equals to the paralyzetime in the WeaponDef.
attackerID: integer? --(Default: `-1`)
weaponID: integer? --(Default: `-1`)
impulseX: number?
impulseY: number?
impulseZ: number?

Returns

: nil

fn AddUnitImpulse (unitID, x, y, z, decayRate) ->


[source]

Params

unitID: integer
x: number
y: number
z: number
decayRate: number?

Returns

: nil

fn AddUnitSeismicPing (unitID, pindSize) ->


[source]

Params

unitID: integer
pindSize: number

Returns

: nil

fn AddUnitResource (unitID, resource, amount) ->


[source]

Params

unitID: integer
resource: string --"m" | "e"
amount: number

Returns

: nil

fn UseUnitResource (unitID, resource, amount) -> okay


[source]

Params

unitID: integer
resource: ResourceName
amount: number

Returns

okay: boolean?

fn UseUnitResource (unitID, resources) -> okay


[source]

Params

unitID: integer
resources: ResourceUsage

Returns

okay: boolean?

fn AddObjectDecal (unitID) ->


[source]

Params

unitID: integer

Returns

: nil

fn RemoveObjectDecal (unitID) ->


[source]

Params

unitID: integer

Returns

: nil

fn AddGrass (x, z) ->


[source]

Params

x: number
z: number

Returns

: nil

fn RemoveGrass (x, z) ->


[source]

Params

x: number
z: number

Returns

: nil

fn CreateFeature (featureDef, x, y, z, heading, teamID, featureID) -> featureID


[source]

Params

featureDef: (string|integer) --name or id
x: number
y: number
z: number
heading: Heading?
teamID: integer?
featureID: integer?

Returns

featureID: integer? --returns nil if creation was unsuccessful

fn DestroyFeature (featureID) ->


[source]

Params

featureID: integer

Returns

: nil

fn TransferFeature (featureID, teamID) ->


Feature Control

[source]


Params

featureID: integer
teamID: integer

Returns

: nil

fn SetFeatureAlwaysVisible (featureID, enable) ->


[source]

Params

featureID: integer
enable: boolean

Returns

: nil

fn SetFeatureUseAirLos (featureID, useAirLos) ->


[source]

Params

featureID: integer
useAirLos: boolean

Returns

: nil

fn SetFeatureHealth (featureID, health, checkDestruction) ->


[source]

Params

featureID: integer
health: number
checkDestruction: boolean? --(Default: `false`) Whether to destroy feature if feature goes below 0 health.

Returns

: nil

fn SetFeatureMaxHealth (featureID, maxHealth) ->


[source]

Params

featureID: integer
maxHealth: number --minimum 0.1

Returns

: nil

fn SetFeatureReclaim (featureID, reclaimLeft) ->


[source]

Params

featureID: integer
reclaimLeft: number

Returns

: nil

fn SetFeatureResources (featureID, metal, energy, reclaimTime, reclaimLeft, featureDefMetal, featureDefEnergy) ->


[source]

Params

featureID: integer
metal: number
energy: number
reclaimTime: number?
reclaimLeft: number?
featureDefMetal: number?
featureDefEnergy: number?

Returns

: nil

fn SetFeatureResurrect (featureID, unitDef, facing, progress) ->


[source]

Params

featureID: integer
unitDef: (string|integer) --Can be a number id or a string name, this allows cancelling resurrection by passing `-1`.
facing: Facing? --(Default: `"south"`)
progress: number? --Set the level of progress.

Returns

: nil

fn SetFeatureMoveCtrl (featureID, enabled, initialVelocityX, initialVelocityY, initialVelocityZ, accelerationX, accelerationY, accelerationZ)


Enable feature movement control.

[source]


Params

featureID: integer
enabled: true --Enable feature movement.
initialVelocityX: number? --Initial velocity on X axis, or `nil` for no change.
initialVelocityY: number? --Initial velocity on Y axis, or `nil` for no change.
initialVelocityZ: number? --Initial velocity on Z axis, or `nil` for no change.
accelerationX: number? --Acceleration per frame on X axis, or `nil` for no change.
accelerationY: number? --Acceleration per frame on Y axis, or `nil` for no change.
accelerationZ: number? --Acceleration per frame on Z axis, or `nil` for no change.

fn SetFeatureMoveCtrl (featureID, enabled, velocityMaskX, velocityMaskY, velocityMaskZ, impulseMaskX, impulseMaskY, impulseMaskZ, movementMaskX, movementMaskY, movementMaskZ)


Disable feature movement control.

Optional parameter allow physics vectors to build when not using MoveCtrl.

It is necessary to unlock feature movement on x, z axis before changing feature physics.

For example:

-- Unlock all movement before setting velocity.
Spring.SetFeatureMoveCtrl(featureID,false,1,1,1,1,1,1,1,1,1)

-- Set velocity.
Spring.SetFeatureVelocity(featureID,10,0,10)

[source]


Params

featureID: integer
enabled: false --Disable feature movement.
velocityMaskX: number? --Lock velocity change in X dimension when not using `MoveCtrl`. `0` to lock, non-zero to allow, or `nil` to for no change.
velocityMaskY: number? --Lock velocity change in Y dimension when not using `MoveCtrl`. `0` to lock, non-zero to allow, or `nil` to for no change.
velocityMaskZ: number? --Lock velocity change in Z dimension when not using `MoveCtrl`. `0` to lock, non-zero to allow, or `nil` to for no change.
impulseMaskX: number? --Lock impulse in X dimension when not using `MoveCtrl`. `0` to lock, non-zero to allow, or `nil` to for no change.
impulseMaskY: number? --Lock impulse in Y dimension when not using `MoveCtrl`. `0` to lock, non-zero to allow, or `nil` to for no change.
impulseMaskZ: number? --Lock impulse in Z dimension when not using `MoveCtrl`. `0` to lock, non-zero to allow, or `nil` to for no change.
movementMaskX: number? --Lock move in X dimension when not using `MoveCtrl`. `0` to lock the axis, non-zero to allow, or `nil` for no change.
movementMaskY: number? --Lock move in Y dimension when not using `MoveCtrl`. `0` to lock the axis, non-zero to allow, or `nil` for no change.
movementMaskZ: number? --Lock move in Z dimension when not using `MoveCtrl`. `0` to lock the axis, non-zero to allow, or `nil` for no change.

fn SetFeaturePhysics (featureID, posX, posY, posZ, velX, velY, velZ, rotX, rotY, rotZ, dragX, dragY, dragZ) ->


[source]

Params

featureID: integer
posX: number
posY: number
posZ: number
velX: number
velY: number
velZ: number
rotX: number
rotY: number
rotZ: number
dragX: number
dragY: number
dragZ: number

Returns

: nil

fn SetFeatureMass (featureID, mass) ->


[source]

Params

featureID: integer
mass: number

Returns

: nil

fn SetFeaturePosition (featureID, x, y, z, snapToGround) ->


[source]

Params

featureID: integer
x: number
y: number
z: number
snapToGround: boolean?

Returns

: nil

fn SetFeatureRotation (featureID, pitch, yaw, roll) ->


[source]

Note: PYR order


Params

featureID: integer
pitch: number --Rotation in X axis
yaw: number --Rotation in Y axis
roll: number --Rotation in Z axis

Returns

: nil

fn SetFeatureDirection (featureID, frontx, fronty, frontz) ->


[source]

Set feature front direction vector. The vector is normalized in the engine.


Params

featureID: integer
frontx: number
fronty: number
frontz: number

Returns

: nil

fn SetFeatureDirection (featureID, frontx, fronty, frontz, rightx, righty, rightz) ->


[source]

Set feature front and right direction vectors.

Both vectors will be normalized in the engine.


Params

featureID: integer
frontx: number
fronty: number
frontz: number
rightx: number
righty: number
rightz: number

Returns

: nil

fn SetFeatureHeadingAndUpDir (featureID, heading, upx, upy, upz) ->


[source]

Use this call to set up feature direction in a robust way. If feature was completely upright, new {upx, upy, upz} direction will be used as new “up” vector, the rotation set by “heading” will remain preserved.


Params

featureID: integer
heading: Heading
upx: number
upy: number
upz: number

Returns

: nil

fn SetFeatureVelocity (featureID, velX, velY, velZ)


Set the velocity of a Feature

[source]


See: Spring.SetFeatureMoveCtrl for disabling/enabling this control

Params

featureID: integer
velX: number --in elmos/frame
velY: number --in elmos/frame
velZ: number --in elmos/frame

fn SetFeatureBlocking (featureID, isBlocking, isSolidObjectCollidable, isProjectileCollidable, isRaySegmentCollidable, crushable, blockEnemyPushing, blockHeightChanges) -> isBlocking


[source]

Params

featureID: integer
isBlocking: boolean? --If `true` add this feature to the `GroundBlockingMap`, but only if it collides with solid objects (or is being set to collide with the `isSolidObjectCollidable` argument). If `false`, remove this feature from the `GroundBlockingMap`. No change if `nil`.
isSolidObjectCollidable: boolean? --Enable or disable collision with solid objects, or no change if `nil`.
isProjectileCollidable: boolean? --Enable or disable collision with projectiles, or no change if `nil`.
isRaySegmentCollidable: boolean? --Enable or disable collision with ray segments, or no change if `nil`.
crushable: boolean? --Enable or disable crushable, or no change if `nil`.
blockEnemyPushing: boolean? --Enable or disable blocking enemy pushing, or no change if `nil`.
blockHeightChanges: boolean? --Enable or disable blocking height changes, or no change if `nil`.

Returns

isBlocking: boolean

fn SetFeatureNoSelect (featureID, noSelect) ->


[source]

Params

featureID: integer
noSelect: boolean

Returns

: nil

fn SetFeatureMidAndAimPos (featureID, mpX, mpY, mpZ, apX, apY, apZ, relative) -> success


[source]

Check Spring.SetUnitMidAndAimPos for further explanation of the arguments.


Params

featureID: integer
mpX: number
mpY: number
mpZ: number
apX: number
apY: number
apZ: number
relative: boolean?

Returns

success: boolean

fn SetFeatureRadiusAndHeight (featureID, radius, height) -> success


[source]

Params

featureID: integer
radius: number
height: number

Returns

success: boolean

fn SetFeatureCollisionVolumeData (featureID, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, vType, tType, Axis) ->


[source]

Check Spring.SetUnitCollisionVolumeData for further explanation of the arguments.


Params

featureID: integer
scaleX: number
scaleY: number
scaleZ: number
offsetX: number
offsetY: number
offsetZ: number
vType: number
tType: number
Axis: number

Returns

: nil

fn SetFeaturePieceCollisionVolumeData (featureID, pieceIndex, enable, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, Axis, volumeType, primaryAxis) ->


[source]

Params

featureID: integer
pieceIndex: number
enable: boolean
scaleX: number
scaleY: number
scaleZ: number
offsetX: number
offsetY: number
offsetZ: number
Axis: number
volumeType: number
primaryAxis: number?

Returns

: nil

fn SetFeaturePieceVisible (featureID, pieceIndex, visible) ->


[source]

Params

featureID: integer
pieceIndex: number
visible: boolean

Returns

: nil

fn SetFeatureFireTime (featureID, fireTime)


Set the fire timer for a feature.

[source]

Starts or resets an internal feature fire timer, when reaching zero the feature will be destroyed.


Params

featureID: integer
fireTime: number --in seconds

fn SetFeatureSmokeTime (featureID, smokeTime)


Set the smoke timer for a feature.

[source]

If different than zero, starts emitting smoke until the timer counts down to zero.

Setting to zero will stop smoke emission by the feature.

The smoke timer affects both the duration and size of the smoke particles.


Params

featureID: integer
smokeTime: number --in seconds

fn CreateUnitWreck (unitID, wreckLevel, doSmoke) -> featureID


Create a wreck from a unit

[source]


Params

unitID: integer
wreckLevel: integer? --(Default: `1`) Wreck index to use.
doSmoke: boolean? --(Default: `true`) Wreck emits smoke when `true`.

Returns

featureID: integer? --The wreck featureID, or nil if it couldn't be created or unit doesn't exist.

fn CreateFeatureWreck (featureID, wreckLevel, doSmoke) -> featureID


Create a wreck from a feature

[source]


Params

featureID: integer
wreckLevel: integer? --(Default: `1`) Wreck index to use.
doSmoke: boolean? --(Default: `false`) Wreck emits smoke when `true`.

Returns

featureID: integer? --The wreck featureID, or nil if it couldn't be created or unit doesn't exist.

fn SetProjectileAlwaysVisible (projectileID, alwaysVisible) ->


[source]

Params

projectileID: integer
alwaysVisible: boolean

Returns

: nil

fn SetProjectileUseAirLos (projectileID, useAirLos) ->


[source]

Params

projectileID: integer
useAirLos: boolean

Returns

: nil

fn SetProjectileMoveControl (projectileID, enable)


Set whether engine should process position and speed for a projectile

Contrary to Spring.SetFeatureMoveCtrl, speed and position for projectiles can be set regardless of whether this method has been called or not.

Passing true merely skips engine updating velocity and position.

[source]


Params

projectileID: integer
enable: boolean

fn SetProjectilePosition (projectileID, posX, posY, posZ)


Set the position of a projectile

[source]


Params

projectileID: integer
posX: number? --(Default: `0`)
posY: number? --(Default: `0`)
posZ: number? --(Default: `0`)

fn SetProjectileVelocity (projectileID, velX, velY, velZ)


Set the velocity of a projectile

Note

Differently from features, Spring.SetProjectileMoveControl is not required to have been called to make use of this method, but often used in conjunction.

[source]


See: Spring.SetProjectileMoveControl

Params

projectileID: integer
velX: number --in elmos/frame
velY: number --in elmos/frame
velZ: number --in elmos/frame

fn SetProjectileCollision (projectileID)


[source]

Params

projectileID: integer

fn SetProjectileTarget (projectileID, targetID, targetType) -> validTarget


Set projectile target (object)

[source]


Params

projectileID: integer
targetID: number
targetType: ProjectileTargetType

Returns

validTarget: boolean?

fn SetProjectileTarget (projectileID, posX, posY, posZ) -> validTarget


Set projectile target (position)

[source]


Params

projectileID: integer
posX: number
posY: number
posZ: number

Returns

validTarget: boolean?

fn SetProjectileTimeToLive (projectileID, ttl)


Set Time To Live for a projectile

[source]


Params

projectileID: integer
ttl: number --Remaining time to live in frames

fn SetProjectileIsIntercepted (projectileID)


[source]

Params

projectileID: integer

fn SetProjectileDamages (unitID, weaponNum, key, value)


[source]

Params

unitID: integer
weaponNum: integer
key: string
value: number

fn SetProjectileIgnoreTrackingError (projectileID, ignore)


[source]

Params

projectileID: integer
ignore: boolean

fn SetProjectileGravity (projectileID, grav) ->


[source]

Params

projectileID: integer
grav: number? --(Default: `0`)

Returns

: nil

fn SetPieceProjectileParams (projectileID, explosionFlags, spinAngle, spinSpeed, spinVectorX, spinVectorY, spinVectorZ)


Set piece projectile params

Non passed or nil args don’t set params.

[source]


Params

projectileID: integer
explosionFlags: number?
spinAngle: number?
spinSpeed: number?
spinVectorX: number?
spinVectorY: number?
spinVectorZ: number?

fn SetProjectileCEG (projectileID, ceg_name) ->


[source]

Params

projectileID: integer
ceg_name: string

Returns

: nil

fn UnitFinishCommand (unitID)


[source]

Params

unitID: integer

fn GiveOrderToUnit (unitID, cmdID, params, options, timeout) -> unitOrdered


[source]

Params

unitID: integer
cmdID: (CMD|integer) --The command ID.
params: CreateCommandParams? --Parameters for the given command.
options: CreateCommandOptions?
timeout: integer? --Absolute frame number. The command will be discarded after this frame. Only respected by mobile units.

Returns

unitOrdered: boolean

fn GiveOrderToUnitMap (unitMap, cmdID, params, options, timeout) -> unitsOrdered


Give order to multiple units, specified by table keys.

[source]


Params

unitMap: table<integer,any> --A table with unit IDs as keys.
cmdID: (CMD|integer) --The command ID.
params: CreateCommandParams? --Parameters for the given command.
options: CreateCommandOptions?
timeout: integer? --Absolute frame number. The command will be discarded after this frame. Only respected by mobile units.

Returns

unitsOrdered: integer --The number of units ordered.

fn GiveOrderToUnitArray (unitIDs, cmdID, params, options, timeout) -> unitsOrdered


[source]

Params

unitIDs: integer[] --An array of unit IDs.
cmdID: (CMD|integer) --The command ID.
params: CreateCommandParams? --Parameters for the given command.
options: CreateCommandOptions?
timeout: integer? --Absolute frame number. The command will be discarded after this frame. Only respected by mobile units.

Returns

unitsOrdered: integer --The number of units ordered.

fn GiveOrderArrayToUnit (unitID, commands) -> ordersGiven


[source]

Params

unitID: integer
commands: CreateCommand[]

Returns

ordersGiven: boolean

fn GiveOrderArrayToUnitMap (unitMap, commands) -> unitsOrdered


[source]

Params

unitMap: table<integer,any> --A table with unit IDs as keys.
commands: CreateCommand[]

Returns

unitsOrdered: integer --The number of units ordered.

fn GiveOrderArrayToUnitArray (unitIDs, commands, pairwise) -> unitsOrdered


[source]

Params

unitIDs: integer[] --Array of unit IDs.
commands: CreateCommand[]
pairwise: boolean? --(Default: `false`) When `false`, assign all commands to each unit. When `true`, assign commands according to index between units and cmds arrays. If `len(unitArray) < len(cmdArray)` only the first `len(unitArray)` commands will be assigned, and vice-versa.

Returns

unitsOrdered: integer --The number of units ordered.

fn LevelHeightMap (x, z, height)


Set the height of a point in the world.

[source]


Params

x: number
z: number
height: number

fn LevelHeightMap (x1, z1, x2, z2, height) ->


Set the height of a rectangle area in the world.

[source]


Params

x1: number
z1: number
x2: number
z2: number
height: number?

Returns

: nil

fn AdjustHeightMap (x, z, height)


Add height to a point in the world.

[source]


Params

x: number
z: number
height: number

fn AdjustHeightMap (x1, z1, x2, z2, height) ->


Add height to a rectangle in the world.

[source]


Params

x1: number
z1: number
x2: number
z2: number
height: number?

Returns

: nil

fn RevertHeightMap (x, z, height)


Restore map height at a point in the world.

[source]


Params

x: number
z: number
height: number

fn RevertHeightMap (x1, z1, x2, z2, height) ->


Restore map height of a rectangle area in the world.

[source]


Params

x1: number
z1: number
x2: number
z2: number
height: number?

Returns

: nil

fn AddHeightMap (x, z, height) -> newHeight


Can only be called in Spring.SetHeightMapFunc

[source]


Params

x: number
z: number
height: number

Returns

newHeight: integer?

fn SetHeightMap (x, z, height, terraform) -> absHeightDiff


[source]

Can only be called in Spring.SetHeightMapFunc.


Params

x: number
z: number
height: number
terraform: number? --(Default: `1`) Scaling factor.

Returns

absHeightDiff: integer? --If `0`, nothing will be changed (the terraform starts), if `1` the terraform will be finished.

fn SetHeightMapFunc (luaFunction, arg, ...) -> absTotalHeightMapAmountChanged


[source]

Example code:

function Spring.SetHeightMapFunc(function()
  for z=0,Game.mapSizeZ, Game.squareSize do
    for x=0,Game.mapSizeX, Game.squareSize do
      Spring.SetHeightMap( x, z, 200 + 20 * math.cos((x + z) / 90) )
    end
  end
end)

Params

luaFunction: function
arg: number
...: number

Returns

absTotalHeightMapAmountChanged: integer?

fn LevelOriginalHeightMap (x, z, height)


Set the height of a point in the original map height cache.

[source]


Params

x: number
z: number
height: number

fn LevelOriginalHeightMap (x1, z1, x2, z2, height)


Set the height of a rectangle area in the original map height cache.

[source]


Params

x1: number
z1: number
x2: number
z2: number
height: number

fn AdjustOriginalHeightMap (x, z, height)


Add height to a point in the original map height cache.

[source]


Params

x: number
z: number
height: number

fn AdjustOriginalHeightMap (x1, z1, x2, z2, height)


Add height to a rectangle area in the original map height cache.

[source]


Params

x1: number
z1: number
x2: number
z2: number
height: number

fn RevertOriginalHeightMap (x, z, height)


Restore original map height at a point in the world.

[source]


Params

x: number
z: number
height: number

fn RevertOriginalHeightMap (x1, z1, x2, z2, height) ->


Restore original map height over a rectangle in the world.

[source]


Params

x1: number
z1: number
x2: number
z2: number
height: number?

Returns

: nil

fn AddOriginalHeightMap (x, y, height) ->


[source]

Can only be called in Spring.SetOriginalHeightMapFunc


Params

x: number
y: number
height: number

Returns

: nil

fn SetOriginalHeightMap (x, y, height, factor) ->


[source]

Can only be called in Spring.SetOriginalHeightMapFunc


Params

x: number
y: number
height: number
factor: number?

Returns

: nil

fn SetOriginalHeightMapFunc (heightMapFunc) ->


[source]

Cannot recurse on itself


Params

heightMapFunc: function

Returns

: nil

fn RebuildSmoothMesh () ->


[source]

Heightmap changes normally take up to 25s to propagate to the smooth mesh. Use to force a mapwide update immediately.


Returns

: nil

fn LevelSmoothMesh (x, z, height)


[source]

Params

x: number
z: number
height: number

fn LevelSmoothMesh (x1, z1, x2, z2, height)


[source]

Params

x1: number
z1: number
x2: number
z2: number
height: number

fn AdjustSmoothMesh (x, z, height)


[source]

Params

x: number
z: number
height: number

fn AdjustSmoothMesh (x1, z1, x2, z2, height)


[source]

Params

x1: number
z1: number
x2: number
z2: number
height: number

fn RevertSmoothMesh (x, z, origFactor)


[source]

Params

x: number
z: number
origFactor: number

fn RevertSmoothMesh (x1, z1, x2, z2, origFactor)


[source]

Params

x1: number
z1: number
x2: number
z2: number
origFactor: number

fn AddSmoothMesh (x, z, height) -> height


Can only be called in Spring.SetSmoothMeshFunc.

[source]


Params

x: number
z: number
height: number

Returns

height: number? --The new height, or `nil` if coordinates are invalid.

fn SetSmoothMesh (x, z, height, terraform) -> The


Can only be called in Spring.SetSmoothMeshFunc.

[source]


Params

x: number
z: number
height: number
terraform: number? --(Default: `1`)

Returns

The: number? --absolute height difference, or `nil` if coordinates are invalid.

fn SetSmoothMeshFunc (luaFunction, arg, ...) -> absTotalHeightMapAmountChanged


[source]

Params

luaFunction: function
arg: any
...: any

Returns

absTotalHeightMapAmountChanged: number?

fn SetMapSquareTerrainType (x, z, newType) -> oldType


[source]

Params

x: number
z: number
newType: number

Returns

oldType: integer?

fn SetTerrainTypeData (typeIndex, speedTanks, speedKBOts, speedHovers, speedShips) ->


[source]

Params

typeIndex: number
speedTanks: number? --(Default: nil)
speedKBOts: number? --(Default: nil)
speedHovers: number? --(Default: nil)
speedShips: number? --(Default: nil)

Returns

: boolean? --true

fn SetSquareBuildingMask (x, z, mask) -> See


[source]

Params

x: number
z: number
mask: number

Returns

See: nil --also buildingMask unitdef tag.

fn UnitWeaponFire (unitID, weaponID) ->


[source]

Params

unitID: integer
weaponID: integer

Returns

: nil

fn UnitWeaponHoldFire (unitID, weaponID) ->


[source]

Params

unitID: integer
weaponID: integer

Returns

: nil

fn ForceUnitCollisionUpdate (unitID) ->


Prevent collision checks from working on outdated data

There’s a rare edge case that requires units to be in specific positions and being shot by specific weapons but which can result in shots ghosting through the unit. This is because the unit’s collision volume is stale. The movement.unitQuadPositionUpdateRate modrule controls this behaviour and can guarantee 100% correctness if set to 1, but the default value is 3 and large-scale games generally don’t want to set it so low. This function lets you guarantee success for important weapons regardless of how high the normal update rate is set.

[source]


Params

unitID: integer

Returns

: nil

fn UnitAttach (transporterID, passengerID, pieceNum) ->


[source]

Params

transporterID: integer
passengerID: integer
pieceNum: number

Returns

: nil

fn UnitDetach (passengerID) ->


[source]

Params

passengerID: integer

Returns

: nil

fn UnitDetachFromAir (passengerID) ->


[source]

Params

passengerID: integer

Returns

: nil

fn SetUnitLoadingTransport (passengerID, transportID) ->


Disables collisions between the two units to allow colvol intersection during the approach.

[source]


Params

passengerID: integer
transportID: integer

Returns

: nil

fn SpawnProjectile (weaponDefID, projectileParams) -> projectileID


[source]

Params

weaponDefID: integer
projectileParams: ProjectileParams

Returns

projectileID: integer?

fn DeleteProjectile (projectileID) ->


Silently removes projectiles (no explosion).

[source]


Params

projectileID: integer

Returns

: nil

fn SpawnExplosion (posX, posY, posZ, dirX, dirY, dirZ, explosionParams) ->


[source]

Params

posX: number? --(Default: `0`)
posY: number? --(Default: `0`)
posZ: number? --(Default: `0`)
dirX: number? --(Default: `0`)
dirY: number? --(Default: `0`)
dirZ: number? --(Default: `0`)
explosionParams: ExplosionParams

Returns

: nil

fn SpawnCEG (cegname, posX, posY, posZ, dirX, dirY, dirZ, radius, damage) -> success, cegID


[source]

Params

cegname: string
posX: number? --(Default: `0`)
posY: number? --(Default: `0`)
posZ: number? --(Default: `0`)
dirX: number? --(Default: `0`)
dirY: number? --(Default: `0`)
dirZ: number? --(Default: `0`)
radius: number? --(Default: `0`)
damage: number? --(Default: `0`)

Returns

success: boolean?
cegID: integer

fn SpawnSFX (unitID, sfxID, posX, posY, posZ, dirX, dirY, dirZ, radius, damage, absolute) -> success


Equal to the UnitScript versions of EmitSFX, but takes position and direction arguments (in either unit- or piece-space) instead of a piece index.

[source]


Params

unitID: integer? --(Default: `0`)
sfxID: integer? --(Default: `0`)
posX: number? --(Default: `0`)
posY: number? --(Default: `0`)
posZ: number? --(Default: `0`)
dirX: number? --(Default: `0`)
dirY: number? --(Default: `0`)
dirZ: number? --(Default: `0`)
radius: number? --(Default: `0`)
damage: number? --(Default: `0`)
absolute: boolean?

Returns

success: boolean?

fn SetNoPause (noPause) ->


[source]

Params

noPause: boolean

Returns

: nil

fn SetExperienceGrade (expGrade, ExpPowerScale, ExpHealthScale, ExpReloadScale) ->


Defines how often Callins.UnitExperience will be called.

[source]


Params

expGrade: number
ExpPowerScale: number?
ExpHealthScale: number?
ExpReloadScale: number?

Returns

: nil

fn SetRadarErrorParams (allyTeamID, allyteamErrorSize, baseErrorSize, baseErrorMult) ->


[source]

Params

allyTeamID: integer
allyteamErrorSize: number
baseErrorSize: number?
baseErrorMult: number?

Returns

: nil

fn EditUnitCmdDesc (unitID, cmdDescID, cmdArray)


[source]

Params

unitID: integer
cmdDescID: integer
cmdArray: CommandDescription

fn InsertUnitCmdDesc (unitID, index, cmdDesc)


Insert a command description at a specific index.

[source]


Params

unitID: integer
index: integer
cmdDesc: CommandDescription

fn InsertUnitCmdDesc (unitID, cmdDesc)


Insert a command description at the last position.

[source]


Params

unitID: integer
cmdDesc: CommandDescription

fn RemoveUnitCmdDesc (unitID, cmdDescID)


[source]

Params

unitID: integer
cmdDescID: integer?

fn IsCheatingEnabled () -> enabled


[source]

Returns

enabled: boolean

fn IsGodModeEnabled () -> enabled


[source]

Returns

enabled: boolean

fn IsDevLuaEnabled () -> enabled


[source]

Returns

enabled: boolean

fn IsEditDefsEnabled () -> enabled


[source]

Returns

enabled: boolean

fn IsNoCostEnabled () -> enabled


[source]

Returns

enabled: boolean

fn GetGlobalLos (teamID) -> enabled


[source]

Params

teamID: integer?

Returns

enabled: boolean

fn AreHelperAIsEnabled () -> enabled


[source]

Returns

enabled: boolean

fn FixedAllies () -> enabled


[source]

Returns

enabled: boolean?

fn IsGameOver () -> isGameOver


[source]

Returns

isGameOver: boolean

fn GetGameFrame () -> t1, t2


[source]

Returns

t1: number --frameNum % dayFrames
t2: number --frameNum / dayFrames

fn GetGameSeconds () -> seconds


[source]

Returns

seconds: number

fn GetTidal () -> tidalStrength


[source]

Returns

tidalStrength: number

fn GetWind () -> windSpeedX, windSpeedY, windSpeedZ, windStrength, windDirX, windDirY, windDirZ


[source]

Returns

windSpeedX: number
windSpeedY: number --(Always 0)
windSpeedZ: number
windStrength: number --(Length of windSpeed)
windDirX: number --(Normalized windSpeed)
windDirY: number --(Always 0)
windDirZ: number

fn GetGameRulesParams () -> rulesParams


[source]

Returns

rulesParams: RulesParams --map with rules names as key and values as values

fn GetTeamRulesParams (teamID) -> rulesParams


[source]

Params

teamID: integer

Returns

rulesParams: RulesParams --map with rules names as key and values as values

fn GetPlayerRulesParams (playerID) -> rulesParams


[source]

Params

playerID: integer

Returns

rulesParams: RulesParams --map with rules names as key and values as values

fn GetUnitRulesParams (unitID) -> rulesParams


[source]

Params

unitID: integer

Returns

rulesParams: RulesParams --map with rules names as key and values as values

fn GetFeatureRulesParams (featureID) -> rulesParams


[source]

Params

featureID: integer

Returns

rulesParams: RulesParams --map with rules names as key and values as values

fn GetGameRulesParam (ruleRef) ->


[source]

Params

ruleRef: (number|string) --the rule index or name

Returns

: number? --|string value

fn GetTeamRulesParam (teamID, ruleRef) -> value


[source]

Params

teamID: integer
ruleRef: (number|string) --the rule index or name

Returns

value: (number|string)?

fn GetPlayerRulesParam (playerID, ruleRef) -> value


[source]

Params

playerID: integer
ruleRef: (number|string) --the rule index or name

Returns

value: (number|string)?

fn GetUnitRulesParam (unitID, ruleRef) -> value


[source]

Params

unitID: integer
ruleRef: (number|string) --the rule index or name

Returns

value: (number|string)?

fn GetFeatureRulesParam (featureID, ruleRef) -> value


[source]

Params

featureID: integer
ruleRef: (number|string) --the rule index or name

Returns

value: (number|string)?

fn GetMapOption (mapOption) -> value


[source]

Params

mapOption: string

Returns

value: string --Value of `modOption`.

fn GetMapOptions () -> mapOptions


[source]

Returns

mapOptions: table<string,string> --Table with options names as keys and values as values.

fn GetModOption (modOption) -> value


[source]

Params

modOption: string

Returns

value: string --Value of `modOption`.

fn GetModOptions () -> modOptions


[source]

Returns

modOptions: table<string,string> --Table with options names as keys and values as values.

fn GetHeadingFromVector (x, z) -> heading


[source]

Params

x: number
z: number

Returns

heading: number

fn GetVectorFromHeading (heading) -> x, z


[source]

Params

heading: number

Returns

x: number
z: number

fn GetFacingFromHeading (heading) -> facing


[source]

Params

heading: number

Returns

facing: FacingInteger

fn GetHeadingFromFacing (facing) -> heading


[source]

Params

facing: FacingInteger

Returns

heading: number

fn GetSideData (sideName) -> startUnit, caseName


[source]

Params

sideName: string --Case-insensitive side name.

Returns

startUnit: string?
caseName: string? --Original case side name.

fn GetSideData (sideID) -> sideName, startUnit, caseName


[source]

Params

sideID: integer

Returns

sideName: string? --Lowercase side name.
startUnit: string?
caseName: string? --Original case side name.

fn GetSideData () -> sideArray


[source]

Returns

sideArray: SideSpec[]

fn GetGaiaTeamID () -> teamID


[source]

Returns

teamID: integer

fn GetAllyTeamStartBox (allyID) -> xMin, zMin, xMax, zMax


[source]

Params

allyID: integer

Returns

xMin: number?
zMin: number?
xMax: number?
zMax: number?

fn GetTeamStartPosition (teamID) -> x, y, x


[source]

Params

teamID: integer

Returns

x: number?
y: number?
x: number?

fn GetMapStartPositions () -> array


[source]

Returns

array: float3[] --of positions indexed by teamID

fn GetAllyTeamList () -> allyTeamIDs


[source]

Returns

allyTeamIDs: integer[]

fn GetTeamList (allyTeamID) -> teamIDs


Get all team IDs.

[source]


Params

allyTeamID: -1? --(Default: `-1`)

Returns

teamIDs: number[] --List of team IDs.

fn GetTeamList (allyTeamID) -> teamIDs


Get team IDs in a specific ally team.

[source]


Params

allyTeamID: integer --The ally team ID to filter teams by. A value less than 0 will return all teams.

Returns

teamIDs: number[]? --List of team IDs or `nil` if `allyTeamID` is invalid.

fn GetPlayerList (teamID, active) -> list


[source]

Params

teamID: integer? --(Default: `-1`) to filter by when >= 0
active: boolean? --(Default: `false`) whether to filter only active teams

Returns

list: number[]? --of playerIDs

fn GetTeamInfo (teamID, getTeamKeys) -> teamID, leader, isDead, hasAI, side, allyTeam, incomeMultiplier, customTeamKeys


[source]

Params

teamID: integer
getTeamKeys: boolean? --(Default: `true`) whether to return the customTeamKeys table

Returns

teamID: integer?
leader: number
isDead: number
hasAI: number
side: string
allyTeam: number
incomeMultiplier: number
customTeamKeys: table<string,string> --when getTeamKeys is true, otherwise nil

fn GetTeamAllyTeamID (teamID) -> allyTeamID


[source]

Params

teamID: integer

Returns

allyTeamID: integer?

fn GetTeamResources (teamID, resource) -> currentLevel, storage, pull, income, expense, share, sent, received, excess


[source]

Params

teamID: integer
resource: ResourceName

Returns

currentLevel: number?
storage: number
pull: number
income: number
expense: number
share: number
sent: number
received: number
excess: number

fn GetTeamUnitStats (teamID) -> killed, died, capturedBy, capturedFrom, received, sent


[source]

Params

teamID: integer

Returns

killed: number?
died: number
capturedBy: number
capturedFrom: number
received: number
sent: number

fn GetTeamResourceStats (teamID, resource) -> used, produced, excessed, received, sent


[source]

Params

teamID: integer
resource: ResourceName

Returns

used: number?
produced: number
excessed: number
received: number
sent: number

fn GetTeamDamageStats (teamID) -> damageDealt, damageReceived


Gets team damage dealt/received totals

[source]

Returns a team’s damage stats. Note that all damage is counted, including self-inflicted and unconfirmed out-of-sight.


Params

teamID: integer

Returns

damageDealt: number
damageReceived: number

fn GetTeamStatsHistory (teamID) -> historyCount


Get the number of history entries.

[source]


Params

teamID: integer

Returns

historyCount: integer? --The number of history entries, or `nil` if unable to resolve team.

fn GetTeamStatsHistory (teamID, startIndex, endIndex) -> The


Get team stats history.

[source]


Params

teamID: integer
startIndex: integer
endIndex: integer? --(Default: startIndex)

Returns

The: TeamStats[] --team stats history, or `nil` if unable to resolve team.

fn GetTeamLuaAI (teamID) ->


[source]

Params

teamID: integer

Returns

: string

fn GetTeamMaxUnits (teamID) -> maxUnits, currentUnits


Returns a team’s unit cap.

Also returns the current unit count for readable teams as the 2nd value.

[source]


Params

teamID: integer

Returns

maxUnits: number
currentUnits: number?

fn GetPlayerInfo (playerID, getPlayerOpts) -> name, active, spectator, teamID, allyTeamID, pingTime, cpuUsage, country, rank, hasSkirmishAIsInTeam, playerOpts, desynced


[source]

Params

playerID: integer
getPlayerOpts: boolean? --(Default: `true`) whether to return custom player options

Returns

name: string
active: boolean
spectator: boolean
teamID: integer
allyTeamID: integer
pingTime: number
cpuUsage: number
country: string
rank: number
hasSkirmishAIsInTeam: boolean
playerOpts: { [string]: string } --when playerOpts is true
desynced: boolean

fn GetPlayerControlledUnit (playerID) ->


Returns unit controlled by player on FPS mode

[source]


Params

playerID: integer

Returns

: number?

fn GetAIInfo (teamID) -> skirmishAIID, name, hostingPlayerID, shortName, version, options


[source]

Params

teamID: integer

Returns

skirmishAIID: integer
name: string
hostingPlayerID: integer
shortName: string --When synced `"SYNCED_NOSHORTNAME"`, otherwise the AI shortname or `"UNKNOWN"`.
version: string --When synced `"SYNCED_NOVERSION"`, otherwise the AI version or `"UNKNOWN"`.
options: table<string,string>

fn GetAllyTeamInfo (allyTeamID) ->


[source]

Params

allyTeamID: integer

Returns

: table<string,string>?

fn AreTeamsAllied (teamID1, teamID2) ->


[source]

Params

teamID1: number
teamID2: number

Returns

: boolean?

fn ArePlayersAllied (playerID1, playerID2) ->


[source]

Params

playerID1: number
playerID2: number

Returns

: boolean?

fn GetAllUnits () -> unitIDs


Get a list of all unitIDs

[source]

Note that when called from a widget, this also returns units that are only radar blips.

For units that are radar blips, you may want to check if they are in los, as GetUnitDefID() will still return true if they have previously been seen.


See: UnsyncedRead.GetVisibleUnits

Returns

unitIDs: number[]

fn GetTeamUnits (teamID) -> unitIDs


[source]

Params

teamID: integer

Returns

unitIDs: number[]?

fn GetTeamUnitsSorted (teamID) -> unitsByDef


[source]

Params

teamID: integer

Returns

unitsByDef: table<integer,integer> --A table where keys are unitDefIDs and values are unitIDs

fn GetTeamUnitsCounts (teamID) -> countByUnit


[source]

Params

teamID: integer

Returns

countByUnit: table<number,number>? --A table where keys are unitDefIDs and values are counts.

fn GetTeamUnitsByDefs (teamID, unitDefIDs) -> unitIDs


[source]

Params

teamID: integer
unitDefIDs: (number|number[])

Returns

unitIDs: number[]?

fn GetTeamUnitDefCount (teamID, unitDefID) -> count


[source]

Params

teamID: integer
unitDefID: integer

Returns

count: number?

fn GetTeamUnitCount (teamID) -> count


[source]

Params

teamID: integer

Returns

count: number?

fn GetUnitsInRectangle (xmin, zmin, xmax, zmax, allegiance) -> unitIDs


[source]

Params

xmin: number
zmin: number
xmax: number
zmax: number
allegiance: number?

Returns

unitIDs: number[]

fn GetUnitsInBox (xmin, ymin, zmin, xmax, ymax, zmax, allegiance) -> unitIDs


[source]

Params

xmin: number
ymin: number
zmin: number
xmax: number
ymax: number
zmax: number
allegiance: number?

Returns

unitIDs: number[]

fn GetUnitsInCylinder (x, z, radius) -> unitIDs


[source]

Params

x: number
z: number
radius: number

Returns

unitIDs: number[]

fn GetUnitsInSphere (x, y, z, radius) -> unitIDs


[source]

Params

x: number
y: number
z: number
radius: number

Returns

unitIDs: number[]

fn GetUnitsInPlanes (planes, allegiance) -> unitIDs


[source]

Plane normals point towards accepted space, so the acceptance criteria for each plane is:

radius     = unit radius
px, py, pz = unit position
[(nx * px) + (ny * py) + (nz * pz) + (d - radius)]  <=  0

Params

planes: Plane[]
allegiance: integer?

Returns

unitIDs: integer[]

fn GetUnitArrayCentroid (units) -> centerX, centerY, centerZ


Returns the centroid of an array of units

Returns nil for an empty array

[source]


Params

units: table --{ unitID, unitID, ... }

Returns

centerX: number
centerY: number
centerZ: number

fn GetUnitMapCentroid (units) -> centerX, centerY, centerZ


Returns the centroid of a map of units

Returns nil for an empty map

[source]


Params

units: table --{ [unitID] = true, [unitID] = true, ... }

Returns

centerX: number
centerY: number
centerZ: number

fn GetUnitNearestAlly (unitID, range) -> unitID


[source]

Params

unitID: integer
range: number? --(Default: `1.0e9`)

Returns

unitID: integer?

fn GetUnitNearestEnemy (unitID, range, useLOS) -> unitID


[source]

Params

unitID: integer
range: number? --(Default: `1.0e9`)
useLOS: boolean? --(Default: `true`)

Returns

unitID: integer?

fn GetFeaturesInRectangle (xmin, zmin, xmax, zmax) -> featureIDs


[source]

Params

xmin: number
zmin: number
xmax: number
zmax: number

Returns

featureIDs: number[]

fn GetFeaturesInSphere (x, y, z, radius) -> featureIDs


[source]

Params

x: number
y: number
z: number
radius: number

Returns

featureIDs: number[]

fn GetFeaturesInCylinder (x, z, radius, allegiance) -> featureIDs


[source]

Params

x: number
z: number
radius: number
allegiance: number?

Returns

featureIDs: number[]

fn GetProjectilesInRectangle (xmin, zmin, xmax, zmax, excludeWeaponProjectiles, excludePieceProjectiles) -> projectileIDs


[source]

Params

xmin: number
zmin: number
xmax: number
zmax: number
excludeWeaponProjectiles: boolean? --(Default: `false`)
excludePieceProjectiles: boolean? --(Default: `false`)

Returns

projectileIDs: number[]

fn GetProjectilesInSphere (x, y, z, radius, excludeWeaponProjectiles, excludePieceProjectiles) -> projectileIDs


[source]

Params

x: number
y: number
z: number
radius: number
excludeWeaponProjectiles: boolean? --(Default: false)
excludePieceProjectiles: boolean? --(Default: false)

Returns

projectileIDs: number[]

fn ValidUnitID (unitID) ->


Get whether a unitID is valid

Dead units are not valid.

[source]


Params

unitID: integer

Returns

: boolean

fn GetUnitStates (unitID) ->


[source]

Params

unitID: integer

Returns

: UnitState

fn GetUnitArmored (unitID) -> armored, armorMultiple


[source]

Params

unitID: integer

Returns

armored: boolean?
armorMultiple: number

fn GetUnitIsActive (unitID) -> isActive


[source]

Params

unitID: integer

Returns

isActive: boolean?

fn GetUnitIsCloaked (unitID) -> isCloaked


[source]

Params

unitID: integer

Returns

isCloaked: boolean?

fn GetUnitSeismicSignature (unitID) -> seismicSignature


[source]

Params

unitID: integer

Returns

seismicSignature: number?

fn GetUnitLeavesGhost () ->


Get whether unit leaves static radar ghosts.

[source]


Returns

: number?

fn GetUnitSelfDTime (unitID) -> selfDTime


[source]

Params

unitID: integer

Returns

selfDTime: integer?

fn GetUnitStockpile (unitID) -> numStockpiled, numStockpileQued, buildPercent


[source]

Params

unitID: integer

Returns

numStockpiled: integer?
numStockpileQued: integer?
buildPercent: number?

fn GetUnitSensorRadius (unitID, type) -> radius


[source]

Params

unitID: integer
type: string --one of los, airLos, radar, sonar, seismic, radarJammer, sonarJammer

Returns

radius: number?

fn GetUnitPosErrorParams (unitID, allyTeamID) -> posErrorVectorX, posErrorVectorY, posErrorVectorZ, posErrorDeltaX, posErrorDeltaY, posErrorDeltaZ, nextPosErrorUpdatebaseErrorMult, posErrorBit


[source]

Params

unitID: integer
allyTeamID: integer?

Returns

posErrorVectorX: number?
posErrorVectorY: number
posErrorVectorZ: number
posErrorDeltaX: number
posErrorDeltaY: number
posErrorDeltaZ: number
nextPosErrorUpdatebaseErrorMult: number
posErrorBit: boolean

fn GetUnitTooltip (unitID) ->


[source]

Params

unitID: integer

Returns

: string?

fn GetUnitDefID (unitID) ->


[source]

Params

unitID: integer

Returns

: number?

fn GetUnitTeam (unitID) ->


[source]

Params

unitID: integer

Returns

: number?

fn GetUnitAllyTeam (unitID) ->


[source]

Params

unitID: integer

Returns

: number?

fn GetUnitNeutral (unitID) ->


Checks if a unit is neutral (NOT Gaia!)

[source]

Note that a “neutral” unit can belong to any ally-team (ally, enemy, Gaia). To check if a unit is Gaia, check its owner team.


Params

unitID: integer

Returns

: boolean?

fn GetUnitHealth (unitID) -> health, maxHealth, paralyzeDamage, captureProgress, buildProgress


[source]

Params

unitID: integer

Returns

health: number?
maxHealth: number
paralyzeDamage: number
captureProgress: number
buildProgress: number --between 0.0-1.0

fn GetUnitIsDead (unitID) ->


[source]

Params

unitID: integer

Returns

: boolean?

fn GetUnitIsStunned (unitID) -> stunnedOrBuilt, stunned, beingBuilt


Checks whether a unit is disabled and can’t act

The first return value is a simple OR of the following ones, any of those conditions is sufficient to disable the unit.

Note that EMP and being transported are mechanically the same and thus lumped together. Use other callouts to differentiate them if you need to.

[source]


Params

unitID: integer

Returns

stunnedOrBuilt: boolean? --unit is disabled
stunned: boolean --unit is either stunned via EMP or being transported by a non-fireplatform
beingBuilt: boolean --unit is under construction

fn GetUnitIsBeingBuilt (unitID) -> beingBuilt, buildProgress


[source]

Params

unitID: integer

Returns

beingBuilt: boolean
buildProgress: number

fn GetUnitResources (unitID) -> metalMake, metalUse, energyMake, energyUse


[source]

Params

unitID: integer

Returns

metalMake: number?
metalUse: number
energyMake: number
energyUse: number

fn GetUnitStorage (unitID) -> Unit, Unit


[source]

Params

unitID: integer

Returns

Unit: number --'s metal storage
Unit: number --'s energy storage

fn GetUnitCosts (unitID) -> buildTime, metalCost, energyCost


[source]

Params

unitID: integer

Returns

buildTime: number?
metalCost: number
energyCost: number

fn GetUnitCostTable (unitID) -> cost, buildTime


[source]

Params

unitID: integer

Returns

cost: ResourceCost? --The cost of the unit, or `nil` if invalid.
buildTime: number? --The build time the unit, or `nil` if invalid.

fn GetUnitMetalExtraction (unitID) -> metalExtraction


[source]

Params

unitID: integer

Returns

metalExtraction: number?

fn GetUnitExperience (unitID) -> xp, limXp


[source]

Params

unitID: integer

Returns

xp: number --[0.0; +∞)
limXp: number --[0.0; 1.0) as experience approaches infinity

fn GetUnitHeight (unitID) ->


[source]

Params

unitID: integer

Returns

: number?

fn GetUnitRadius (unitID) ->


[source]

Params

unitID: integer

Returns

: number?

fn GetUnitBuildeeRadius (unitID) ->


[source]

Gets the unit’s radius for when targeted by build, repair, reclaim-type commands.


Params

unitID: integer

Returns

: number?

fn GetUnitMass (unitID) ->


[source]

Params

unitID: integer

Returns

: number?

fn GetUnitPosition (unitID, midPos, aimPos) -> basePointX, basePointY, basePointZ, midPointX, midPointY, midPointZ, aimPointX, aimPointY, aimPointZ


[source]

Params

unitID: integer
midPos: boolean? --(Default: `false`) return midpoint as well
aimPos: boolean? --(Default: `false`) return aimpoint as well

Returns

basePointX: number?
basePointY: number
basePointZ: number
midPointX: number?
midPointY: number
midPointZ: number
aimPointX: number?
aimPointY: number
aimPointZ: number

fn GetUnitBasePosition (unitID) -> posX, posY, posZ


[source]

The same as Spring.GetUnitPosition, but without the optional midpoint calculations.


See: Spring.GetUnitPosition

Params

unitID: integer

Returns

posX: number?
posY: number?
posZ: number?

fn GetUnitVectors (unitID) -> front, up, right


[source]

Params

unitID: integer

Returns

front: float3?
up: float3
right: float3

fn GetUnitRotation (unitID) -> pitch, yaw, roll


[source]

Note: PYR order


Params

unitID: integer

Returns

pitch: number --Rotation in X axis
yaw: number --Rotation in Y axis
roll: number --Rotation in Z axis

fn GetUnitDirection (unitID) -> frontDirX, frontDirY, frontDirZ, rightDirX, rightDirY, rightDirZ, upDirX, upDirY, upDirZ


[source]

Params

unitID: integer

Returns

frontDirX: number
frontDirY: number
frontDirZ: number
rightDirX: number
rightDirY: number
rightDirZ: number
upDirX: number
upDirY: number
upDirZ: number

fn GetUnitHeading (unitID, convertToRadians) -> heading


[source]

Params

unitID: integer
convertToRadians: boolean? --(Default: `false`)

Returns

heading: number

fn GetUnitVelocity (unitID)


[source]

Params

unitID: integer

fn GetUnitBuildFacing (unitID)


[source]

Params

unitID: integer

fn GetUnitIsBuilding (unitID) -> buildeeUnitID


Checks whether a unit is currently building another (NOT for checking if it’s a structure)

[source]

Works for both mobile builders and factories.


Params

unitID: integer

Returns

buildeeUnitID: integer --or nil

fn GetUnitWorkerTask (unitID) -> cmdID, targetID


Checks a builder’s current task

[source]

Checks what a builder is currently doing. This is not the same as Spring.GetUnitCurrentCommand, because you can have a command at the front of the queue and not be doing it (for example because the target is still too far away), and on the other hand you can also be doing a task despite not having it in front of the queue (for example you’re Guarding another builder who does). Also, it resolves the Repair command into either actual repair, or construction assist (in which case it returns the appropriate “build” command). Only build-related commands are returned (no Move or any custom commands).

The possible commands returned are repair, reclaim, resurrect, capture, restore, and build commands (negative buildee unitDefID).


Params

unitID: integer

Returns

cmdID: integer --of the relevant command
targetID: integer --if applicable (all except RESTORE)

fn GetUnitEffectiveBuildRange (unitID, buildeeDefID) -> effectiveBuildRange


[source]

Useful for setting move goals manually.


Params

unitID: integer
buildeeDefID: integer --or nil

Returns

effectiveBuildRange: number --counted to the center of prospective buildee; buildRange if buildee nil

fn GetUnitCurrentBuildPower (unitID)


[source]

Params

unitID: integer

fn GetUnitHarvestStorage (unitID) -> storedMetal, maxStoredMetal, storedEnergy, maxStoredEnergy


Get a unit’s carried resources

[source]

Checks resources being carried internally by the unit.


Params

unitID: integer

Returns

storedMetal: number
maxStoredMetal: number
storedEnergy: number
maxStoredEnergy: number

fn GetUnitBuildParams (unitID)


[source]

Params

unitID: integer

fn GetUnitInBuildStance (unitID) -> inBuildStance


Is builder in build stance

[source]

Checks if a builder is in build stance, i.e. can create nanoframes. Returns nil for non-builders.


Params

unitID: integer

Returns

inBuildStance: boolean

fn GetUnitNanoPieces (unitID) -> pieceArray


Get construction FX attachment points

[source]

Returns an array of pieces which represent construction points. Default engine construction FX (nano spray) will originate there.

Only works on builders and factories, returns nil (NOT empty table) for other units.


Params

unitID: integer

Returns

pieceArray: integer[]

fn GetUnitTransporter (unitID) -> transportUnitID


Get the transport carrying the unit

[source]

Returns the unit ID of the transport, if any. Returns nil if the unit is not being transported.


Params

unitID: integer

Returns

transportUnitID: integer?

fn GetUnitIsTransporting (unitID) -> transporteeArray


Get units being transported

[source]


Params

unitID: integer

Returns

transporteeArray: integer[]?

fn GetUnitShieldState (unitID, weaponNum) -> isEnabled, currentPower


[source]

Params

unitID: integer
weaponNum: number? --Optional if the unit has just one shield

Returns

isEnabled: number --Warning, number not boolean. 0 or 1
currentPower: number

fn GetUnitFlanking (unitID)


[source]

Params

unitID: integer

fn GetUnitMaxRange (unitID) -> maxRange


Get a unit’s engagement range

[source]

Returns the range at which a unit will stop to engage. By default this is the highest among the unit’s weapon ranges (hence name), but can be changed dynamically. Also note that unarmed units ignore this.


Params

unitID: integer

Returns

maxRange: number

fn GetUnitWeaponState (unitID, weaponNum, stateName) -> stateValue


Check the state of a unit’s weapon

[source]

Available states to poll: “reloadFrame” (frame on which the weapon will be ready to fire), “reloadSpeed” (reload time in seconds), “range” (in elmos), “autoTargetRangeBoost” (predictive aiming range buffer, in elmos), “projectileSpeed” (in elmos/frame), “reloadTimeXP” (reload time after XP bonus, in seconds), “reaimTime” (frames between AimWeapon calls), “burst” (shots in a burst), “burstRate” (delay between shots in a burst, in seconds), “projectiles” (projectiles per shot), “salvoLeft” (shots remaining in ongoing burst), “nextSalvo” (simframe of the next shot in an ongoing burst), “accuracy” (INaccuracy after XP bonus), “sprayAngle” (spray angle after XP bonus), “targetMoveError” (extra inaccuracy against moving targets, after XP bonus) “avoidFlags” (bitmask for targeting avoidance), “ttl” (number of seconds a projectile should live) “collisionFlags” (bitmask for collisions).

The state “salvoError” is an exception and returns a table: {x, y, z}, which represents the inaccuracy error of the ongoing burst.


Params

unitID: integer
weaponNum: number
stateName: string

Returns

stateValue: number

fn GetUnitWeaponDamages (unitID)


[source]

Params

unitID: integer

fn GetUnitWeaponVectors (unitID)


[source]

Params

unitID: integer

fn GetUnitWeaponTryTarget (unitID)


[source]

Params

unitID: integer

fn GetUnitWeaponTestTarget (unitID)


[source]

Params

unitID: integer

fn GetUnitWeaponTestRange (unitID)


[source]

Params

unitID: integer

fn GetUnitWeaponHaveFreeLineOfFire (unitID)


[source]

Params

unitID: integer

fn GetUnitWeaponCanFire (unitID)


[source]

Params

unitID: integer

fn GetUnitWeaponTarget (unitID, weaponNum) -> TargetType, isUserTarget


Checks a weapon’s target

Note that this doesn’t need to reflect the unit’s Attack orders or such, and that weapons can aim individually unless slaved.

[source]


Params

unitID: integer
weaponNum: integer

Returns

TargetType: 0 --none
isUserTarget: boolean

fn GetUnitWeaponTarget (unitID, weaponNum) -> TargetType, isUserTarget, targetUnitID


Checks a weapon’s target

Note that this doesn’t need to reflect the unit’s Attack orders or such, and that weapons can aim individually unless slaved.

[source]


Params

unitID: integer
weaponNum: integer

Returns

TargetType: 1 --unit
isUserTarget: boolean
targetUnitID: integer

fn GetUnitWeaponTarget (unitID, weaponNum) -> TargetType, isUserTarget, targetPosition


Checks a weapon’s target

Note that this doesn’t need to reflect the unit’s Attack orders or such, and that weapons can aim individually unless slaved.

[source]


Params

unitID: integer
weaponNum: integer

Returns

TargetType: 2 --position
isUserTarget: boolean
targetPosition: float3

fn GetUnitWeaponTarget (unitID, weaponNum) -> TargetType, isUserTarget, targetProjectileId


Checks a weapon’s target

Note that this doesn’t need to reflect the unit’s Attack orders or such, and that weapons can aim individually unless slaved.

[source]


Params

unitID: integer
weaponNum: integer

Returns

TargetType: 3 --projectileID
isUserTarget: boolean
targetProjectileId: integer

fn GetUnitEstimatedPath (unitID)


[source]

Params

unitID: integer

fn GetUnitLastAttacker (unitID)


[source]

Params

unitID: integer

fn GetUnitLastAttackedPiece (unitID)


[source]

Params

unitID: integer

fn GetUnitCollisionVolumeData (unitID)


[source]

Params

unitID: integer

fn GetUnitSeparation (unitID1, unitID2, direction, subtractRadii) ->


[source]

Params

unitID1: number
unitID2: number
direction: boolean? --(Default: `false`) to subtract from, default unitID1 - unitID2
subtractRadii: boolean? --(Default: `false`) whether units radii should be subtracted from the total

Returns

: number?

fn GetUnitFeatureSeparation (unitID)


[source]

Params

unitID: integer

fn GetUnitDefDimensions (unitDefID) -> dimensions


[source]

Params

unitDefID: integer

Returns

dimensions: UnitDefDimensions?

fn GetCEGID ()


[source]

fn GetUnitBlocking (unitID) -> isBlocking, isSolidObjectCollidable, isProjectileCollidable, isRaySegmentCollidable, crushable, blockEnemyPushing, blockHeightChanges


[source]

Params

unitID: integer

Returns

isBlocking: boolean?
isSolidObjectCollidable: boolean
isProjectileCollidable: boolean
isRaySegmentCollidable: boolean
crushable: boolean
blockEnemyPushing: boolean
blockHeightChanges: boolean

fn GetUnitMoveTypeData (unitID)


[source]

Params

unitID: integer

fn GetUnitCurrentCommand (unitID, cmdIndex) -> cmdID, options, tag, Command


Get a command from a units command queue.

For factories, this function uses the command queue automatically assigned to new units.

[source]


See: Spring.GetFactoryCommands for getting factory build queue commands

Params

unitID: integer --unitID when invalid this function returns nil.
cmdIndex: integer? --(Default: `0`) Command index to get. If negative will count from the end of the queue, e.g. -1 will be the last command.

Returns

cmdID: CMD?
options: (integer|CommandOptionBit)?
tag: integer?
Command: number? … --parameters.

fn GetUnitCommands (unitID, count) -> commands


Get the commands for a unit.

[source]

Same as Spring.GetCommandQueue


Params

unitID: integer
count: integer --Maximum amount of commands to return, `-1` returns all commands.

Returns

commands: Command[]

fn GetUnitCommands (unitID, count) -> The


Get the count of commands for a unit.

[source]


Params

unitID: integer
count: 0 --Returns the number of commands in the units queue.

Returns

The: integer --number of commands in the unit queue.

fn GetFactoryCommands (unitID, count) -> commands


Get the number or list of commands for a factory

[source]


See: Spring.GetFactoryCommandCount to get the count of commands. Spring.GetFactoryCounts to get command counts grouped by cmdID.

Params

unitID: integer
count: integer --Maximum amount of commands to return, `-1` returns all commands.

Returns

commands: Command[]

fn GetFactoryCommands (unitID, count) -> The


Get the count of commands for a factory.

[source]


See: Spring.GetFactoryCommandCount for replacement function.

Params

unitID: integer
count: 0 --Returns the number of commands in the factory queue.

Returns

The: integer --number of commands in the factory queue.

fn GetUnitCommandCount (unitID) -> The


Get the number of commands in a unit’s queue.

[source]


Params

unitID: integer

Returns

The: integer --number of commands in the unit's queue.

fn GetFactoryCommandCount (unitID) -> The


Get the number of commands in a factory queue.

[source]


See: Spring.GetFactoryCommands to get the factory commands. Spring.GetFactoryCounts to get command counts grouped by cmdID.

Params

unitID: integer

Returns

The: integer --number of commands in the factory queue.

fn GetFactoryBuggerOff (unitID)


[source]

Params

unitID: integer

fn GetFactoryCounts (unitID, count, addCmds) -> counts


Gets the build queue of a factory

[source]


Params

unitID: integer
count: integer? --(Default: `-1`) Number of commands to retrieve, `-1` for all.
addCmds: boolean? --(Default: `false`) Retrieve commands other than buildunit

Returns

counts: table<number,number>? --Build queue count by `unitDefID` or `-cmdID`, or `nil` if unit is not found.

fn GetCommandQueue (unitID, count) -> commands


Get the commands for a unit.

[source]

Same as Spring.GetUnitCommands


Params

unitID: integer
count: integer --Number of commands to return, `-1` returns all commands, `0` returns command count.

Returns

commands: Command[]

fn GetCommandQueue (unitID, count) -> cmdCount


Get the count of commands for a unit.

[source]

Same as Spring.GetUnitCommands


Params

unitID: integer
count: 0 --Returns the number of commands in the units queue.

Returns

cmdCount: integer --The number of commands in the unit queue.

fn GetFullBuildQueue (unitID) -> buildqueue


Returns the build queue

[source]


Params

unitID: integer

Returns

buildqueue: table<number,number>? --indexed by unitDefID with count values

fn GetRealBuildQueue (unitID) -> buildqueue


Returns the build queue cleaned of things the unit can’t build itself

[source]


Params

unitID: integer

Returns

buildqueue: table<number,number>? --indexed by unitDefID with count values

fn GetUnitCmdDescs (unitID)


[source]

Params

unitID: integer

fn FindUnitCmdDesc (unitID)


[source]

Params

unitID: integer

fn ValidFeatureID (featureID) ->


[source]

Params

featureID: integer

Returns

: boolean

fn GetAllFeatures () -> featureIDs


[source]

Returns

featureIDs: integer[]

fn GetFeatureDefID (featureID) ->


[source]

Params

featureID: integer

Returns

: number?

fn GetFeatureTeam (featureID) ->


[source]

Params

featureID: integer

Returns

: number?

fn GetFeatureAllyTeam (featureID) ->


[source]

Params

featureID: integer

Returns

: number?

fn GetFeatureHealth (featureID) -> health, defHealth, resurrectProgress


[source]

Params

featureID: integer

Returns

health: number?
defHealth: number
resurrectProgress: number

fn GetFeatureHeight (featureID) ->


[source]

Params

featureID: integer

Returns

: number?

fn GetFeatureRadius (featureID) ->


[source]

Params

featureID: integer

Returns

: number?

fn GetFeatureMass (featureID) ->


[source]

Params

featureID: integer

Returns

: number?

fn GetFeaturePosition (featureID) -> x, y, z


[source]

Params

featureID: integer

Returns

x: number?
y: number?
z: number?

fn GetFeatureSeparation (featureID1, featureID2, direction) ->


[source]

Params

featureID1: number
featureID2: number
direction: boolean? --(Default: `false`) to subtract from, default featureID1 - featureID2

Returns

: number?

fn GetFeatureRotation (featureID) -> pitch, yaw, roll


[source]

Note: PYR order


Params

featureID: integer

Returns

pitch: number? --Rotation in X axis
yaw: number? --Rotation in Y axis
roll: number? --Rotation in Z axis

fn GetFeatureDirection (featureID) -> frontDirX, frontDirY, frontDirZ, rightDirX, rightDirY, rightDirZ, upDirX, upDirY, upDirZ


[source]

Params

featureID: integer

Returns

frontDirX: number?
frontDirY: number?
frontDirZ: number?
rightDirX: number?
rightDirY: number?
rightDirZ: number?
upDirX: number?
upDirY: number?
upDirZ: number?

fn GetFeatureVelocity (featureID) -> x, y, z, w


[source]

Returns nil if no feature found with ID.


Params

featureID: integer

Returns

x: number?
y: number?
z: number?
w: number?

fn GetFeatureHeading (featureID)


[source]

Params

featureID: integer

fn GetFeatureResources (featureID) -> metal, defMetal, energy, defEnergy, reclaimLeft, reclaimTime


[source]

Params

featureID: integer

Returns

metal: number?
defMetal: number
energy: number
defEnergy: number
reclaimLeft: number
reclaimTime: number

fn GetFeatureBlocking (featureID) -> isBlocking, isSolidObjectCollidable, isProjectileCollidable, isRaySegmentCollidable, crushable, blockEnemyPushing, blockHeightChanges


[source]

Params

featureID: integer

Returns

isBlocking: boolean?
isSolidObjectCollidable: boolean?
isProjectileCollidable: boolean?
isRaySegmentCollidable: boolean?
crushable: boolean?
blockEnemyPushing: boolean?
blockHeightChanges: boolean?

fn GetFeatureNoSelect (featureID) ->


[source]

Params

featureID: integer

Returns

: boolean?

fn GetFeatureResurrect (featureID) -> featureDefName, buildFacing


[source]

Returns nil if no feature found with ID.


Params

featureID: integer

Returns

featureDefName: (string|"")?
buildFacing: FacingInteger --facing of footprint, 0 - 3

fn GetFeatureLastAttackedPiece (featureID) -> Last, frame


[source]

Params

featureID: integer

Returns

Last: (string|"")? --hit piece name
frame: integer? --it was last hit on, nil when featureID is not valid

fn GetFeatureCollisionVolumeData (featureID) ->


[source]

Params

featureID: integer

Returns

: CollisionVolumeData?

fn GetFeaturePieceCollisionVolumeData (featureID) ->


[source]

Params

featureID: integer

Returns

: CollisionVolumeData?

fn GetFeatureFireTime (featureID) -> fireTime


Get the feature current fire timer.

[source]


Params

featureID: integer

Returns

fireTime: number? --in seconds, nil when featureID is invalid.

fn GetFeatureSmokeTime (featureID) -> smokeTime


Get the feature current smoke timer.

[source]


Params

featureID: integer

Returns

smokeTime: number? --in seconds, nil when featureID is invalid.

fn GetProjectilePosition (projectileID) -> posX, posY, posZ


[source]

Params

projectileID: integer

Returns

posX: number?
posY: number?
posZ: number?

fn GetProjectileDirection (projectileID) -> dirX, dirY, dirZ


[source]

Params

projectileID: integer

Returns

dirX: number?
dirY: number?
dirZ: number?

fn GetProjectileVelocity (projectileID) -> velX, velY, velZ, velW


[source]

Params

projectileID: integer

Returns

velX: number?
velY: number?
velZ: number?
velW: number?

fn GetProjectileGravity (projectileID) ->


[source]

Params

projectileID: integer

Returns

: number?

fn GetPieceProjectileParams (projectileID) -> explosionFlags, spinAngle, spinSpeed, spinVectorX, spinVectorY, spinVectorZ


[source]

Params

projectileID: integer

Returns

explosionFlags: number? --encoded bitwise with SHATTER = 1, EXPLODE = 2, EXPLODE_ON_HIT = 2, FALL = 4, SMOKE = 8, FIRE = 16, NONE = 32, NO_CEG_TRAIL = 64, NO_HEATCLOUD = 128
spinAngle: number
spinSpeed: number
spinVectorX: number
spinVectorY: number
spinVectorZ: number

fn GetProjectileTarget (projectileID) -> targetTypeInt, target


[source]

Params

projectileID: integer

Returns

targetTypeInt: number? --where string.byte('g') := GROUND string.byte('u') := UNIT string.byte('f') := FEATURE string.byte('p') := PROJECTILE
target: (number|float3) --targetID or targetPos when targetTypeInt == string.byte('g')

fn GetProjectileIsIntercepted (projectileID) ->


[source]

Params

projectileID: integer

Returns

: boolean?

fn GetProjectileTimeToLive (projectileID) ->


[source]

Params

projectileID: integer

Returns

: number?

fn GetProjectileOwnerID (projectileID) ->


[source]

Params

projectileID: integer

Returns

: number?

fn GetProjectileTeamID (projectileID) ->


[source]

Params

projectileID: integer

Returns

: number?

fn GetProjectileAllyTeamID (projectileID) ->


[source]

Params

projectileID: integer

Returns

: number?

fn GetProjectileType (projectileID) -> weapon, piece


[source]

Params

projectileID: integer

Returns

weapon: boolean?
piece: boolean

fn GetProjectileDefID (projectileID) ->


[source]

Using this to get a weaponDefID is HIGHLY preferred to indexing WeaponDefNames via GetProjectileName


Params

projectileID: integer

Returns

: number?

fn GetProjectileDamages (projectileID, tag) ->


[source]

Params

projectileID: integer
tag: string --one of: "paralyzeDamageTime" "impulseFactor" "impulseBoost" "craterMult" "craterBoost" "dynDamageExp" "dynDamageMin" "dynDamageRange" "dynDamageInverted" "craterAreaOfEffect" "damageAreaOfEffect" "edgeEffectiveness" "explosionSpeed" - or - an armor type index to get the damage against it.

Returns

: number?

fn IsPosInMap (x, z) -> inPlayArea, inMap


[source]

Params

x: number
z: number

Returns

inPlayArea: boolean --whether the position is in the active play area
inMap: boolean --whether the position is in the full map area (currently this is the same as above)

fn GetGroundHeight (x, z) ->


Get ground height

On sea, this returns the negative depth of the seafloor

[source]


Params

x: number
z: number

Returns

: number

fn GetWaterPlaneLevel () -> waterPlaneLevel


Get water plane height

Water may at some point become shaped (rivers etc) but for now it is always a flat plane. Use this function instead of GetWaterLevel to denote you are relying on that assumption.

[source]


See: Spring.GetWaterLevel

Returns

waterPlaneLevel: number

fn GetWaterLevel (x, z) -> waterLevel


Get water level in a specific position

Water is currently a flat plane, so this returns the same value regardless of XZ. However water may become more dynamic at some point so by using this you are future-proof.

[source]


Params

x: number
z: number

Returns

waterLevel: number

fn GetGroundOrigHeight (x, z) ->


Get ground height as it was at game start

Returns the original height before the ground got deformed

[source]


Params

x: number
z: number

Returns

: number

fn GetGroundNormal (x, z, smoothed) -> normalX, normalY, normalZ, slope


[source]

Params

x: number
z: number
smoothed: boolean? --(Default: `false`) raw or smoothed center normal

Returns

normalX: number
normalY: number
normalZ: number
slope: number

fn GetGroundInfo (x, z) -> ix, iz, terrainTypeIndex, name, metalExtraction, hardness, tankSpeed, kbotSpeed, hoverSpeed, shipSpeed, receiveTracks


[source]

Params

x: number
z: number

Returns

ix: number
iz: number
terrainTypeIndex: number
name: string
metalExtraction: number
hardness: number
tankSpeed: number
kbotSpeed: number
hoverSpeed: number
shipSpeed: number
receiveTracks: boolean

fn GetGroundBlocked ()


[source]

fn GetGroundExtremes () -> initMinHeight, initMaxHeight, currMinHeight, currMaxHeight


[source]

Returns

initMinHeight: number
initMaxHeight: number
currMinHeight: number
currMaxHeight: number

fn GetTerrainTypeData (terrainTypeInfo) -> index, name, hardness, tankSpeed, kbotSpeed, hoverSpeed, shipSpeed, receiveTracks


[source]

Params

terrainTypeInfo: number

Returns

index: number
name: string
hardness: number
tankSpeed: number
kbotSpeed: number
hoverSpeed: number
shipSpeed: number
receiveTracks: boolean

fn GetGrass (x, z) ->


[source]

Params

x: number
z: number

Returns

: number

fn GetSmoothMeshHeight (x, z) -> height


[source]

Params

x: number
z: number

Returns

height: number

fn TestMoveOrder (unitDefID, posX, posY, posZ, dirX, dirY, dirZ, testTerrain, testObjects, centerOnly) ->


[source]

Params

unitDefID: integer
posX: number
posY: number
posZ: number
dirX: number? --(Default: `0.0`)
dirY: number? --(Default: `0.0`)
dirZ: number? --(Default: `0.0`)
testTerrain: boolean? --(Default: `true`)
testObjects: boolean? --(Default: `true`)
centerOnly: boolean? --(Default: `false`)

Returns

: boolean

fn TestBuildOrder (unitDefID, x, y, z, facing) -> blocking, featureID


[source]

Params

unitDefID: integer
x: number
y: number
z: number
facing: Facing

Returns

blocking: BuildOrderBlockedStatus
featureID: integer? --A reclaimable feature in the way.

fn Pos2BuildPos (unitDefID, posX, posY, posZ, buildFacing) -> buildPosX, buildPosY, buildPosZ


Snaps a position to the building grid

[source]


Params

unitDefID: integer
posX: number
posY: number
posZ: number
buildFacing: number? --(Default: `0`) one of SOUTH = 0, EAST = 1, NORTH = 2, WEST = 3

Returns

buildPosX: number
buildPosY: number
buildPosZ: number

fn ClosestBuildPos (teamID, unitDefID, posX, posY, posZ, searchRadius, minDistance, buildFacing) -> buildPosX, buildPosY, buildPosZ


[source]

Params

teamID: integer
unitDefID: integer
posX: number
posY: number
posZ: number
searchRadius: number
minDistance: number
buildFacing: number --one of SOUTH = 0, EAST = 1, NORTH = 2, WEST = 3

Returns

buildPosX: number
buildPosY: number
buildPosZ: number

fn GetPositionLosState (posX, posY, posZ, allyTeamID) -> inLosOrRadar, inLos, inRadar, inJammer


[source]

Params

posX: number
posY: number
posZ: number
allyTeamID: integer?

Returns

inLosOrRadar: boolean
inLos: boolean
inRadar: boolean
inJammer: boolean

fn IsPosInLos (posX, posY, posZ, allyTeamID) ->


[source]

Params

posX: number
posY: number
posZ: number
allyTeamID: integer?

Returns

: boolean

fn IsPosInRadar (posX, posY, posZ, allyTeamID) ->


[source]

Params

posX: number
posY: number
posZ: number
allyTeamID: integer?

Returns

: boolean

fn IsPosInAirLos (posX, posY, posZ, allyTeamID) ->


[source]

Params

posX: number
posY: number
posZ: number
allyTeamID: integer?

Returns

: boolean

fn GetUnitLosState (unitID, allyTeamID, raw) -> bitmask


Get unit los state (bitmask)

[source]


Params

unitID: integer
allyTeamID: integer?
raw: true --Return a bitmask.

Returns

bitmask: (LosMask|integer)? --A bitmask of `LosMask` bits

fn GetUnitLosState (unitID, allyTeamID, raw) -> los


Get unit los state (table)

[source]


Params

unitID: integer
allyTeamID: integer?
raw: false? --Return a table.

Returns

los: table<(“los”|“radar”…),boolean>? --A table of LOS state names as keys and booleans as values, or `nil` if `unitID` is invalid.

fn IsUnitInLos (unitID, allyTeamID) -> inLos


[source]

Params

unitID: integer
allyTeamID: integer

Returns

inLos: boolean

fn IsUnitInAirLos (unitID, allyTeamID) -> inAirLos


[source]

Params

unitID: integer
allyTeamID: integer

Returns

inAirLos: boolean

fn IsUnitInRadar (unitID, allyTeamID) -> inRadar


[source]

Params

unitID: integer
allyTeamID: integer

Returns

inRadar: boolean

fn IsUnitInJammer (unitID, allyTeamID) -> inJammer


[source]

Params

unitID: integer
allyTeamID: integer

Returns

inJammer: boolean

fn GetModelRootPiece (modelName) -> index


[source]

Params

modelName: string

Returns

index: number --of the root piece

fn GetModelPieceMap (modelName) -> pieceInfos


[source]

Params

modelName: string

Returns

pieceInfos: table<string,number>? --where keys are piece names and values are indices

fn GetModelPieceList (modelName) -> pieceNames


[source]

Params

modelName: string

Returns

pieceNames: string[]?

fn GetUnitRootPiece (unitID) -> index


[source]

Params

unitID: integer

Returns

index: number --of the root piece

fn GetUnitPieceMap (unitID) -> pieceInfos


[source]

Params

unitID: integer

Returns

pieceInfos: table<string,number>? --where keys are piece names and values are indices

fn GetUnitPieceList (unitID) -> pieceNames


[source]

Params

unitID: integer

Returns

pieceNames: string[]

fn GetUnitPieceInfo (unitID, pieceIndex) -> pieceInfo


[source]

Params

unitID: integer
pieceIndex: integer

Returns

pieceInfo: PieceInfo?

fn GetUnitPiecePosDir (unitID, pieceIndex) -> posX, posY, posZ, dirX, dirY, dirZ


[source]

Params

unitID: integer
pieceIndex: integer

Returns

posX: number?
posY: number
posZ: number
dirX: number
dirY: number
dirZ: number

fn GetUnitPiecePosition (unitID, pieceIndex) -> posX, posY, posZ


[source]

Params

unitID: integer
pieceIndex: integer

Returns

posX: number?
posY: number
posZ: number

fn GetUnitPieceDirection (unitID, pieceIndex) -> dirX, dirY, dirZ


[source]

Params

unitID: integer
pieceIndex: integer

Returns

dirX: number?
dirY: number
dirZ: number

fn GetUnitPieceMatrix (unitID) -> m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44


[source]

Params

unitID: integer

Returns

m11: number?
m12: number
m13: number
m14: number
m21: number
m22: number
m23: number
m24: number
m31: number
m32: number
m33: number
m34: number
m41: number
m42: number
m43: number
m44: number

fn GetFeatureRootPiece (featureID) -> index


[source]

Params

featureID: integer

Returns

index: number --of the root piece

fn GetFeaturePieceMap (featureID) -> pieceInfos


[source]

Params

featureID: integer

Returns

pieceInfos: table<string,number> --where keys are piece names and values are indices

fn GetFeaturePieceList (featureID) -> pieceNames


[source]

Params

featureID: integer

Returns

pieceNames: string[]

fn GetFeaturePieceInfo (featureID, pieceIndex) -> pieceInfo


[source]

Params

featureID: integer
pieceIndex: integer

Returns

pieceInfo: PieceInfo?

fn GetFeaturePiecePosDir (featureID, pieceIndex) -> posX, posY, posZ, dirX, dirY, dirZ


[source]

Params

featureID: integer
pieceIndex: integer

Returns

posX: number?
posY: number
posZ: number
dirX: number
dirY: number
dirZ: number

fn GetFeaturePiecePosition (featureID, pieceIndex) -> posX, posY, posZ


[source]

Params

featureID: integer
pieceIndex: integer

Returns

posX: number?
posY: number
posZ: number

fn GetFeaturePieceDirection (featureID, pieceIndex) -> dirX, dirY, dirZ


[source]

Params

featureID: integer
pieceIndex: integer

Returns

dirX: number?
dirY: number
dirZ: number

fn GetFeaturePieceMatrix (featureID) -> m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44


[source]

Params

featureID: integer

Returns

m11: number?
m12: number
m13: number
m14: number
m21: number
m22: number
m23: number
m24: number
m31: number
m32: number
m33: number
m34: number
m41: number
m42: number
m43: number
m44: number

fn GetUnitScriptPiece (unitID) -> pieceIndices


[source]

Params

unitID: integer

Returns

pieceIndices: integer[]

fn GetUnitScriptPiece (unitID, scriptPiece) -> pieceIndex


[source]

Params

unitID: integer
scriptPiece: integer

Returns

pieceIndex: integer

fn GetUnitScriptNames (unitID) -> where


[source]

Params

unitID: integer

Returns

where: table<string,number> --keys are piece names and values are piece indices

fn TraceRayGroundInDirection (posX, posY, posZ, dirX, dirY, dirZ, testWater) -> rayLength, posX, posY, posZ


Checks for a ground collision in given direction

[source]

Checks if there is surface (ground, optionally water) towards a vector and returns the distance to the closest hit and its position, if any.


Params

posX: number
posY: number
posZ: number
dirX: number
dirY: number
dirZ: number
testWater: boolean? --(Default: `true`)

Returns

rayLength: number
posX: number
posY: number
posZ: number

fn TraceRayGroundBetweenPositions (startX, startY, startZ, endX, endY, endZ, testWater) -> rayLength, posX, posY, posZ


Checks for a ground collision between two positions

[source]

Checks if there is surface (ground, optionally water) between two positions and returns the distance to the closest hit and its position, if any.


Params

startX: number
startY: number
startZ: number
endX: number
endY: number
endZ: number
testWater: boolean? --(Default: `true`)

Returns

rayLength: number
posX: number
posY: number
posZ: number

fn GetRadarErrorParams (allyTeamID) -> radarErrorSize, baseRadarErrorSize, baseRadarErrorMult


[source]

Params

allyTeamID: integer

Returns

radarErrorSize: number? --actual radar error size (when allyTeamID is allied to current team) or base radar error size
baseRadarErrorSize: number
baseRadarErrorMult: number

fn Echo (arg, ...) ->


Prints values in the spring chat console. Useful for debugging.

Hint: the default print() writes to STDOUT.

[source]


Params

arg: any
...: any

Returns

: nil

fn Log (section, logLevel, ...)


Logs a message to the logfile/console.

[source]


Params

section: string --Sets an arbitrary section. Level filtering can be applied per-section
logLevel: (LogLevel|LOG)? --(Default: `"notice"`)
...: string --messages

fn CallAsTeam (teamID, func, ...) -> The


Calls a function from given team’s PoV. In particular this makes callouts obey that team’s visibility rules.

[source]


Params

teamID: integer --Team ID.
func: fun(…) --The function to call.
...: any --Arguments to pass to the function.

Returns

The: any … --return values of the function.

fn CallAsTeam (options, func, ...) -> The


[source]

Params

options: CallAsTeamOptions --Options.
func: fun(…) --The function to call.
...: any --Arguments to pass to the function.

Returns

The: any … --return values of the function.

field SYNCED


is table<string,any>

Proxy table for reading synced global state in unsynced code.

Generally not recommended. Instead, listen to the same events as synced and build the table in parallel

Unsynced code can read from the synced global table (_G) using the SYNCED proxy table. e.g. _G.foo can be access from unsynced via SYNCED.foo.

This table makes a copy of the object on the other side, and only copies numbers, strings, bools and tables (recursively but with the type restriction), in particular this does not allow access to functions.

Note that this makes a copy on each access, so is very slow and will not reflect changes. Cache it, but remember to refresh.

[source]


table tracy


fn ZoneBegin (name)


Params

name: string

fn ZoneBeginN (name)


Params

name: string

fn ZoneBeginS (name)


Params

name: string

fn ZoneBeginNS (name)


Params

name: string

fn ZoneEnd ()


fn ZoneText (text)


Params

text: string

fn ZoneName (name)


Params

name: string

fn Message (text)


Params

text: string

fn LuaTracyPlotConfig (plotName, plotFormatType, stepwise, fill, color)


Configure custom appearance for a Tracy plot for use in debugging or profiling

[source]


Params

plotName: string --name of the plot to customize
plotFormatType: (“Number”|“Percentage”|“Memory”)? --(Default: `"Number"`)
stepwise: boolean? --(Default: `true`) stepwise chart
fill: boolean? --(Default: `false`) whether to fill color
color: integer? --(Default: `0xFFFFFF`) uint32 number as BGR color

fn LuaTracyPlot (plotName, plotValue)


Update a Tracy plot with a value

[source]


Params

plotName: string --Which LuaPlot should be updated
plotValue: number --the number to show on the Tracy plot

table VFS


Unified IO for archive and filesystem

The Virtual File System is a unified layer to access (read-only) the different archives used at runtime. So you can access map, game & config files via the same interface.

Overview

Although Spring can access the filesystem directly (via os module) it is more common that you would want to access files included with your game or Spring. Trouble is, most of these files are compressed into archives (.sdz/.sd7) so random access would generally be a difficult procedure. Fortunately, the Spring Lua system automatically provides access to mod and base files via the VFS module.

As an additional caveat, synced Lua cannot use the os and io modules, so using VFS is mandatory there to have any file access at all.

The VFS module doesn’t simply open archives though. What it does is map your game files, game dependencies and Spring content onto a virtual file tree. All archives start from the ‘roots’ of the tree and share the same virtual space, meaning that if two or more archives contain the same resource file name the resources overlap and only one of the files will be retrieved. Overlapping directories on the other hand are merged so the resulting virtual directory contains the contents of both. Here is an example of how this works:

Archive 1 (games/mygame.sd7)

textures
└── texture1.png
models
└── model1.mdl

Archive 2 (base/springcontent.sdz)

textures
├── texture1.png
├── texture2.png
└── texture3.png

VFS

textures
├── texture1.png
├── texture2.png
└── texture3.png
models
└── model1.mdl

This raises the question: If both archives have a texture1.png then which texture1.png is retreived via the VFS? The answer depends on the order the archives are loaded and the VFS mode (more on modes below). Generally however, each archive loaded overrides any archives loaded before it. The standard order of loading (from first to last) is:

  1. The automatic dependencies springcontent.sdz and maphelper.sdz.
  2. Dependencies listed in your modinfo.lua (or modinfo.tdf), in the order listed. Note that they are loaded fully and recursively, i.e. all the deeper dependencies of the 1st base-level dependency are loaded before the 2nd base-level dependency. This breaks the usual “loaded later overrides loaded earlier” priority if a dependency comes from multiple places, since only the first time an archive is loaded counts.
  3. Your mod archive.

Loose files (not within any archive) in the engine dir are also visible as if under the VFS root if loading under the VFS.RAW mode, though you can also use full FS path (i.e. C:/.../Spring/foo/bar.txt is visible both as that and as just foo/bar.txt). Note that VFS.RAW is only accessible to unsynced Lua, all synced states are limited to loaded archives.

Paths

Spring’s VFS is lowercase only. Also it is strongly recommended to use linux style path separators, e.g. "foo/bar.txt" and not "foo\bar.txt".

Engine read files

The engine access a few files directly, most of them are lua files which access other files themselves. Here the list of files that must exist in the VFS (some of them don’t have to be in the game/map archive cause there are fallback solutions in springcontent.sdz & maphelper.sdz):

  • ./
  • anims/
  • cursornormal.bmp/png
  • gamedata/
  • defs.lua
  • explosions.lua
  • explosion_alias.lua
  • icontypes.lua
  • messages.lua
  • modrules.lua
  • resources.lua
  • resources_map.lua
  • sidedata.lua
  • sounds.lua
  • luagaia/
  • main.lua
  • draw.lua
  • luarules/
  • main.lua
  • draw.lua
  • luaui/
  • main.lua
  • shaders/
  • ?
  • luaai.lua
  • mapinfo.lua
  • mapoptions.lua
  • modinfo.lua
  • modoptions.lua
  • validmaps.lua

[source]


field RAW


is string
[source] Only select uncompressed files.

field GAME


is string
[source]

field MAP


is string
[source]

field BASE


is string
[source]

field MENU


is string
[source]

field ZIP


is string
[source] Only select compressed files (.sdz, .sd7).

field RAW_FIRST


is string
[source] Try uncompressed files first, then compressed.

field ZIP_FIRST


is string
[source] Try compressed files first, then uncompressed.

field MOD


is string
[source]

field RAW_ONLY


is string
[source]

field ZIP_ONLY


is string
[source]

fn Include (filename, environment, mode) -> module


Loads and runs lua code from a file in the VFS.

[source]

The path is relative to the main Spring directory, e.g.

VFS.Include('LuaUI/includes/filename.lua', nil, vfsmode)

Params

filename: string
environment: table? --(Default: the current function environment) The environment arg sets the global environment (see generic lua refs). In almost all cases, this should be left `nil` to preserve the current env. If the provided, any non-local variables and functions defined in `filename.lua` are then accessable via env. Vise-versa, any variables defined in env prior to passing to `VFS.Include` are available to code in the included file. Code running in `filename.lua` will see the contents of env in place of the normal global environment.
mode: string?

Returns

module: any --The return value of the included file.

fn LoadFile (filename, mode) -> data


Load raw text data from the VFS.

[source]

Returns file contents as a string. Unlike VFS.Include the file will not be executed. This lets you pre-process the code. Use loadstring afterwards.


Params

filename: string
mode: string?

Returns

data: string? --The contents of the file.

fn FileExists (filename, mode) -> exists


Check if file exists in VFS.

[source]

Example usage:

if VFS.FileExists("mapconfig/custom_lava_config.lua", VFS.MAP) then
  # ...
end

Params

filename: string
mode: string?

Returns

exists: boolean --`true` if the file exists, otherwise `false`.

fn DirList (directory, pattern, mode, recursive) -> filenames


List files in a directory.

[source]

Example usage:

local luaFiles = VFS.DirList('units/', '*.lua', nil, true)

Params

directory: string
pattern: string? --(Default: `"*"`)
mode: string?
recursive: boolean? --(Default: `false`)

Returns

filenames: string[]

fn SubDirs (directory, pattern, mode, recursive) -> dirnames


List sub-directories in a directory.

[source]

Example usage:

local files = VFS.SubDirs('sounds/voice/' .. language, '*')
for _, file in ipairs(files) do
    # ...
end

Params

directory: string
pattern: string? --(Default: `"*"`)
mode: string?
recursive: boolean? --(Default: `false`)

Returns

dirnames: string[]

fn GetFileAbsolutePath (filename, mode) -> absolutePath


[source]

Params

filename: string
mode: string?

Returns

absolutePath: string?

fn GetArchiveContainingFile (filename, mode) -> archiveName


[source]

Params

filename: string
mode: string?

Returns

archiveName: string?

fn UseArchive (archiveName, fun) -> Results


Temporarily load an archive from the VFS and run the given function, which can make usage of the files in the archive.

[source]


Params

archiveName: string
fun: unknown

Returns

Results: any … --of the given function

fn CompressFolder (folderPath, archiveType, compressedFilePath, includeFolder, mode)


Compresses the specified folder.

[source]


Params

folderPath: string
archiveType: string? --(Default: `"zip"`)The compression type (can currently be only `"zip"`).
compressedFilePath: string? --(Default: `folderPath .. ".sdz"`)
includeFolder: boolean? --(Default: `false`) Whether the archive should have the specified folder as root.
mode: string?

fn ZlibCompress (uncompressed) -> compressed


[source]

Params

uncompressed: string --Data to compress.

Returns

compressed: string? --Compressed data, or `nil` on error.

fn ZlibDecompress (compressed) -> uncompressed


[source]

Params

compressed: string --Data to decompress.

Returns

uncompressed: string? --Uncompressed data, or `nil` on error.

fn CalculateHash (input, hashType) -> hash


Calculates hash of a given string.

  • MD5 gets base64 encoded.
  • SHA512 gets hex encoded.

[source]


Params

input: string
hashType: HashType --Hash type.

Returns

hash: string?

fn PackU8 (...) ->


Convert unsigned 8-bit integer(s) to binary string.

[source]


Params

...: integer --Numbers to pack.

Returns

: string

fn PackU8 (numbers) ->


Convert unsigned 8-bit integer(s) to binary string.

[source]


Params

numbers: integer[] --Numbers to pack.

Returns

: string

fn PackU16 (...) ->


Convert unsigned 16-bit integer(s) to binary string.

[source]


Params

...: integer --Numbers to pack.

Returns

: string

fn PackU16 (numbers) ->


Convert unsigned 16-bit integer(s) to binary string.

[source]


Params

numbers: integer[] --Numbers to pack.

Returns

: string

fn PackU32 (...) ->


Convert unsigned 32-bit integer(s) to binary string.

[source]


Params

...: integer --Numbers to pack.

Returns

: string

fn PackU32 (numbers) ->


Convert unsigned 32-bit integer(s) to binary string.

[source]


Params

numbers: integer[] --Numbers to pack.

Returns

: string

fn PackS8 (...) ->


Convert signed 8-bit integer(s) to binary string.

[source]


Params

...: integer --Numbers to pack.

Returns

: string

fn PackS8 (numbers) ->


Convert signed 8-bit integer(s) to binary string.

[source]


Params

numbers: integer[] --Numbers to pack.

Returns

: string

fn PackS16 (...) ->


Convert signed 16-bit integer(s) to binary string.

[source]


Params

...: integer --Numbers to pack.

Returns

: string

fn PackS16 (numbers) ->


Convert signed 16-bit integer(s) to binary string.

[source]


Params

numbers: integer[] --Numbers to pack.

Returns

: string

fn PackS32 (...) ->


Convert signed 32-bit integer(s) to binary string.

[source]


Params

...: integer --Numbers to pack.

Returns

: string

fn PackS32 (numbers) ->


Convert signed 32-bit integer(s) to binary string.

[source]


Params

numbers: integer[] --Numbers to pack.

Returns

: string

fn PackS32 (...) ->


Convert signed 32-bit float(s) to binary string.

[source]


Params

...: integer --Numbers to pack.

Returns

: string

fn PackS32 (numbers) ->


Convert signed 32-bit float(s) to binary string.

[source]


Params

numbers: integer[] --Numbers to pack.

Returns

: string

fn UnpackU8 (str, pos) ->


Convert a binary string to an unsigned 8-bit integer.

[source]


Params

str: string --Binary string.
pos: integer? --Byte offset.

Returns

: integer

fn UnpackU16 (str, pos) ->


Convert a binary string to an unsigned 16-bit integer.

[source]


Params

str: string --Binary string.
pos: integer? --Byte offset.

Returns

: integer

fn UnpackU32 (str, pos) ->


Convert a binary string to an unsigned 32-bit integer.

[source]


Params

str: string --Binary string.
pos: integer? --Byte offset.

Returns

: integer

fn UnpackS8 (str, pos) ->


Convert a binary string to a signed 8-bit integer.

[source]


Params

str: string --Binary string.
pos: integer? --Byte offset.

Returns

: integer

fn UnpackS16 (str, pos) ->


Convert a binary string to a signed 16-bit integer.

[source]


Params

str: string --Binary string.
pos: integer? --Byte offset.

Returns

: integer

fn UnpackS32 (str, pos) ->


Convert a binary string to a signed 32-bit integer.

[source]


Params

str: string --Binary string.
pos: integer? --Byte offset.

Returns

: integer

fn UnpackF32 (str, pos) ->


Convert a binary string to a signed 32-bit float.

[source]


Params

str: string --Binary string.
pos: integer? --Byte offset.

Returns

: integer

fn GetMaps () -> mapNames


[source]

Returns

mapNames: string[]

fn GetGames () -> gameNames


[source]

Returns

gameNames: string[]

fn GetAllArchives () -> archiveNames


[source]

Returns

archiveNames: string[]

fn HasArchive () -> hasArchive


[source]

Returns

hasArchive: boolean

fn GetLoadedArchives () -> archiveNames


[source]

Returns

archiveNames: string[]

fn GetArchivePath (archiveName) -> archivePath


[source]

Params

archiveName: string

Returns

archivePath: string?

fn GetArchiveInfo (archiveName) -> archiveInfo


[source]

Params

archiveName: string

Returns

archiveInfo: ArchiveInfo?

fn GetArchiveDependencies (archiveName) -> archiveNames


[source]

Params

archiveName: string

Returns

archiveNames: string[]

fn GetArchiveReplaces (archiveName) -> archiveNames


[source]

Params

archiveName: string

Returns

archiveNames: string[]

fn GetArchiveChecksum (archiveName) -> singleArchiveChecksum, completeArchiveChecksum


[source]

Params

archiveName: string

Returns

singleArchiveChecksum: string
completeArchiveChecksum: string

fn GetNameFromRapidTag (rapidTag) -> archiveName


[source]

Params

rapidTag: string

Returns

archiveName: string

fn GetAvailableAIs (gameArchiveName, mapArichiveName) -> ais


Get a list of all Spring AIs.

The optional gameName and mapName parameters can be used to include game/map specific LuaAIs in the list.

[source]


Params

gameArchiveName: string?
mapArichiveName: string?

Returns

ais: AIInfo[]

Types

class ActiveUniform


[source]

field name


is string

field type


is string
String name of GL_* constant.

field length


is integer
The character length of name.

field size


is integer

field location


is GL

class AIInfo


[source]

field shortName


is string

field version


is string

class ArchiveInfo


[source]

field name


is string

field shortname


is string

field version


is string

field mutator


is string

field game


is string

field shortgame


is string

field description


is string

field mapfile


is string

field modtype


is ModType

class AtmosphereParams


[source]

field fogStart


is number

field fogEnd


is number

field sunColor


is rgba

field skyColor


is rgba

field cloudColor


is rgba

field skyAxisAngle


is xyzw
rotation axis and angle in radians of skybox orientation

alias Attachment


is (“depth”|“stencil”|“color0”|“color1”|“color2”|“color3”|“color4”|“color5”|“color6”|“color7”|“color8”|“color9”|“color10”|“color11”|“color12”|“color13”|“color14”|“color15”)
[source]

alias BuildOrderBlockedStatus


is (0|1|2|3)
[source]

class CallAsTeamOptions


[source]

field ctrl


is integer
Ctrl team ID.

field read


is integer
Read team ID.

field select


is integer
Select team ID.

class Callins


[source]
See: Gadget Widget Menu Intro SyncedCallins UnsyncedCallins

method Initialize ()


Called when the addon is (re)loaded.

[source]


method LoadCode ()


Called when the game is (re)loaded.

[source]


method Shutdown () ->


Called when the addon or the game is shutdown.

[source]


Returns

: nil

method GotChatMsg (msg, playerID)


Called when a player issues a UI command e.g. types /foo or /luarules foo.

[source]


Params

msg: string
playerID: integer

method Load (zipReader)


Called after GamePreload and before GameStart. See Lua_SaveLoad.

[source]


Params

zipReader: table

method GamePreload ()


Called before the 0 gameframe.

Is not called when a saved game is loaded.

[source]


method GameStart ()


Called upon the start of the game.

[source]

Is not called when a saved game is loaded.


method GameOver (winningAllyTeams)


Called when the game ends

[source]


Params

winningAllyTeams: number[] --list of winning allyTeams, if empty the game result was undecided (like when dropping from an host).

method GamePaused (playerID, paused)


Called when the game is paused.

[source]


Params

playerID: integer
paused: boolean

method GameFrame (frame)


Called for every game simulation frame (30 per second).

[source]


Params

frame: number --Starts at frame 1

method GameFramePost (frame)


Called at the end of every game simulation frame

[source]


Params

frame: number --Starts at frame 1

method GameID (gameID)


Called once to deliver the gameID

[source]


Params

gameID: string --encoded in hex.

method TeamDied (teamID)


Called when a team dies (see Spring.KillTeam).

[source]


Params

teamID: integer

method TeamChanged (teamID)


[source]

Params

teamID: integer

method PlayerChanged (playerID)


Called whenever a player’s status changes e.g. becoming a spectator.

[source]


Params

playerID: integer

method PlayerAdded (playerID)


Called whenever a new player joins the game.

[source]


Params

playerID: integer

method PlayerRemoved (playerID, reason)


Called whenever a player is removed from the game.

[source]


Params

playerID: integer
reason: string

method UnitCreated (unitID, unitDefID, unitTeam, builderID)


Called at the moment the unit is created.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer
builderID: integer?

method UnitFinished (unitID, unitDefID, unitTeam)


Called at the moment the unit is completed.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer

method UnitFromFactory (unitID, unitDefID, unitTeam, factID, factDefID, userOrders)


Called when a factory finishes construction of a unit.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer
factID: integer
factDefID: integer
userOrders: boolean

method UnitReverseBuilt (unitID, unitDefID, unitTeam)


Called when a living unit becomes a nanoframe again.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer

method UnitConstructionDecayed (unitID, unitDefID, unitTeam, timeSinceLastBuild, iterationPeriod, part)


Called when a unit being built starts decaying.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer
timeSinceLastBuild: number
iterationPeriod: number
part: number

method UnitDestroyed (unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam, weaponDefID)


Called when a unit is destroyed.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer
attackerID: integer
attackerDefID: integer
attackerTeam: number
weaponDefID: integer

method UnitTaken (unitID, unitDefID, oldTeam, newTeam)


Called when a unit is transferred between teams. This is called before UnitGiven and in that moment unit is still assigned to the oldTeam.

[source]


Params

unitID: integer
unitDefID: integer
oldTeam: number
newTeam: number

method UnitGiven (unitID, unitDefID, newTeam, oldTeam)


Called when a unit is transferred between teams. This is called after UnitTaken and in that moment unit is assigned to the newTeam.

[source]


Params

unitID: integer
unitDefID: integer
newTeam: number
oldTeam: number

method UnitIdle (unitID, unitDefID, unitTeam)


Called when a unit is idle (empty command queue).

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer

method UnitCommand (unitID, unitDefID, unitTeam, cmdID, cmdParams, options, cmdTag)


Called after when a unit accepts a command, after AllowCommand returns true.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer
cmdID: integer
cmdParams: table
options: CommandOptions
cmdTag: number

method UnitCmdDone (unitID, unitDefID, unitTeam, cmdID, cmdParams, options, cmdTag)


Called when a unit completes a command.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer
cmdID: integer
cmdParams: table
options: CommandOptions
cmdTag: number

method UnitDamaged (unitID, unitDefID, unitTeam, damage, paralyzer, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam)


Called when a unit is damaged (after UnitPreDamaged).

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer
damage: number
paralyzer: number
weaponDefID: integer
projectileID: integer
attackerID: integer
attackerDefID: integer
attackerTeam: number

method UnitStunned (unitID, unitDefID, unitTeam, stunned)


Called when a unit changes its stun status.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer
stunned: boolean

method UnitExperience (unitID, unitDefID, unitTeam, experience, oldExperience)


Called when a unit gains experience greater or equal to the minimum limit set by calling Spring.SetExperienceGrade.

Should be called more reliably with small values of experience grade.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer
experience: number
oldExperience: number

method UnitHarvestStorageFull (unitID, unitDefID, unitTeam)


Called when a unit’s harvestStorage is full (according to its unitDef’s entry).

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer

method UnitSeismicPing (x, y, z, strength, allyTeam, unitID, unitDefID)


Called when a unit emits a seismic ping.

[source]

See seismicSignature.


Params

x: number
y: number
z: number
strength: number
allyTeam: integer
unitID: integer
unitDefID: integer

method UnitEnteredRadar (unitID, unitTeam, allyTeam, unitDefID)


Called when a unit enters radar of an allyteam.

Also called when a unit enters LOS without any radar coverage.

[source]


Params

unitID: integer
unitTeam: integer
allyTeam: integer
unitDefID: integer

method UnitEnteredLos (unitID, unitTeam, allyTeam, unitDefID)


Called when a unit enters LOS of an allyteam.

Its called after the unit is in LOS, so you can query that unit.

[source]


Params

unitID: integer
unitTeam: integer
allyTeam: integer --who's LOS the unit entered.
unitDefID: integer

method UnitLeftRadar (unitID, unitTeam, allyTeam, unitDefID)


Called when a unit leaves radar of an allyteam.

Also called when a unit leaves LOS without any radar coverage. For widgets, this is called just after a unit leaves radar coverage, so widgets cannot get the position of units that left their radar.

[source]


Params

unitID: integer
unitTeam: integer
allyTeam: integer
unitDefID: integer

method UnitLeftLos (unitID, unitTeam, allyTeam, unitDefID)


Called when a unit leaves LOS of an allyteam.

For widgets, this one is called just before the unit leaves los, so you can still get the position of a unit that left los.

[source]


Params

unitID: integer
unitTeam: integer
allyTeam: integer
unitDefID: integer

method UnitLoaded (unitID, unitDefID, unitTeam, transportID, transportTeam)


Called when a unit is loaded by a transport.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer
transportID: integer
transportTeam: integer

method UnitUnloaded (unitID, unitDefID, unitTeam, transportID, transportTeam)


Called when a unit is unloaded by a transport.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer
transportID: integer
transportTeam: integer

method UnitEnteredUnderwater (unitID, unitDefID, unitTeam)


[source]

Params

unitID: integer
unitDefID: integer
unitTeam: integer

method UnitEnteredWater (unitID, unitDefID, unitTeam)


[source]

Params

unitID: integer
unitDefID: integer
unitTeam: integer

method UnitLeftAir (unitID, unitDefID, unitTeam)


[source]

Params

unitID: integer
unitDefID: integer
unitTeam: integer

method UnitLeftUnderwater (unitID, unitDefID, unitTeam)


[source]

Params

unitID: integer
unitDefID: integer
unitTeam: integer

method UnitLeftWater (unitID, unitDefID, unitTeam)


[source]

Params

unitID: integer
unitDefID: integer
unitTeam: integer

method UnitEnteredAir (unitID, unitDefID, unitTeam)


[source]

Params

unitID: integer
unitDefID: integer
unitTeam: integer

method UnitCloaked (unitID, unitDefID, unitTeam)


Called when a unit cloaks.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer

method UnitDecloaked (unitID, unitDefID, unitTeam)


Called when a unit decloaks.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer

method UnitUnitCollision (colliderID, collideeID)


Called when two units collide.

Both units must be registered with Script.SetWatchUnit.

[source]


Params

colliderID: integer
collideeID: integer

method UnitFeatureCollision (colliderID, collideeID)


Called when a unit collides with a feature.

[source]

The unit must be registered with Script.SetWatchUnit and the feature registered with Script.SetWatchFeature.


Params

colliderID: integer
collideeID: integer

method UnitMoveFailed (unitID, unitDefID, unitTeam)


[source]

Params

unitID: integer
unitDefID: integer
unitTeam: integer

method UnitArrivedAtGoal (unitID, unitDefID, unitTeam)


[source]

Params

unitID: integer
unitDefID: integer
unitTeam: integer

method RenderUnitDestroyed (unitID, unitDefID, unitTeam)


Called just before a unit is invalid, after it finishes its death animation.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer

method FeatureCreated (featureID, allyTeamID)


Called when a feature is created.

[source]


Params

featureID: integer
allyTeamID: integer

method FeatureDestroyed (featureID, allyTeamID)


Called when a feature is destroyed.

[source]


Params

featureID: integer
allyTeamID: integer

method FeatureDamaged (featureID, featureDefID, featureTeam, damage, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam)


Called when a feature is damaged.

[source]


Params

featureID: integer
featureDefID: integer
featureTeam: number
damage: number
weaponDefID: integer
projectileID: integer
attackerID: integer
attackerDefID: integer
attackerTeam: number

method ProjectileCreated (proID, proOwnerID, weaponDefID)


Called when the projectile is created.

[source]

Note that weaponDefID is missing if the projectile is spawned as part of a burst, but Spring.GetProjectileDefID and Spring.GetProjectileName still work in callin scope using proID.


See: Script.SetWatchProjectile Script.SetWatchWeapon

Params

proID: integer
proOwnerID: integer
weaponDefID: integer

method ProjectileDestroyed (proID, ownerID, proWeaponDefID)


Called when the projectile is destroyed.

[source]


See: Script.SetWatchProjectile Script.SetWatchWeapon

Params

proID: integer
ownerID: integer
proWeaponDefID: integer

method Explosion (weaponDefID, px, py, pz, attackerID, projectileID) -> noGfx


Called when an explosion occurs.

[source]

Only called for weaponDefIDs registered via Script.SetWatchExplosion or Script.SetWatchWeapon.


See: Script.SetWatchExplosion Script.SetWatchWeapon

Params

weaponDefID: integer
px: number
py: number
pz: number
attackerID: integer
projectileID: integer

Returns

noGfx: boolean --if then no graphical effects are drawn by the engine for this explosion.

method StockpileChanged (unitID, unitDefID, unitTeam, weaponNum, oldCount, newCount)


Called when a units stockpile of weapons increases or decreases.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer
weaponNum: integer
oldCount: integer
newCount: integer

method RecvLuaMsg (msg, playerID)


Receives messages from unsynced sent via Spring.SendLuaRulesMsg or Spring.SendLuaUIMsg.

[source]


Params

msg: string
playerID: integer

method Save (zip)


Called when a chat command ‘/save’ or ‘/savegame’ is received.

[source]


Params

zip: table --a userdatum representing the savegame zip file. See Lua_SaveLoad.

method UnsyncedHeightMapUpdate () -> x1, z1, x2, z2


Called when the unsynced copy of the height-map is altered.

[source]


Returns

x1: number
z1: number
x2: number
z2: number

method Update (dt)


Called for every draw frame (including when the game is paused) and at least once per sim frame except when catching up.

[source]


Params

dt: number --the time since the last update.

method ViewResize (viewSizeX, viewSizeY)


Called whenever the window is resized.

[source]


Params

viewSizeX: number
viewSizeY: number

method FontsChanged ()


Called whenever fonts are updated. Signals the game display lists and other caches should be discarded.

Gets called before other Update and Draw callins.

[source]


method SunChanged ()


[source]

method DefaultCommand (type, id)


Used to set the default command when a unit is selected.

[source]


Params

type: (“unit”|“feature”) --The type of the object pointed at.
id: integer --The `unitID` or `featureID`.

method DrawGenesis ()


Use this callin to update textures, shaders, etc.

[source]

Doesn’t render to screen! Also available to LuaMenu.


method DrawWorld ()


Spring draws command queues, ‘map stuff’, and map marks.

[source]


method DrawWorldPreUnit ()


Spring draws units, features, some water types, cloaked units, and the sun.

[source]


method DrawPreDecals ()


Called before decals are drawn

[source]


method DrawWaterPost ()


[source]

method DrawShadowPassTransparent ()


Invoked after semi-transparent shadows pass is about to conclude

[source]

This callin has depth and color buffer of shadowmap bound via FBO as well as the FFP state to do “semi-transparent” shadows pass (traditionally only used to draw shadows of shadow casting semi-transparent particles). Can be used to draw nice colored shadows.


method DrawWorldShadow ()


[source]

method DrawWorldReflection ()


[source]

method DrawWorldRefraction ()


[source]

method DrawGroundPreForward ()


Runs at the start of the forward pass when a custom map shader has been assigned via Spring.SetMapShader (convenient for setting uniforms).

[source]


method DrawGroundPostForward ()


[source]

method DrawGroundPreDeferred ()


Runs at the start of the deferred pass when a custom map shader has been assigned via Spring.SetMapShader (convenient for setting uniforms).

[source]


method DrawGroundDeferred ()


[source]

method DrawGroundPostDeferred ()


This runs at the end of its respective deferred pass.

[source]

Allows proper frame compositing (with ground flashes/decals/foliage/etc, which are drawn between it and DrawWorldPreUnit) via gl.CopyToTexture.


method DrawUnitsPostDeferred ()


Runs at the end of the unit deferred pass.

[source]

Informs Lua code it should make use of the $model_gbuffer_* textures before another pass overwrites them (and to allow proper blending with e.g. cloaked objects which are drawn between these events and DrawWorld via gl.CopyToTexture). N.B. The *PostDeferred events are only sent (and only have a real purpose) if forward drawing is disabled.


method DrawFeaturesPostDeferred ()


Runs at the end of the feature deferred pass to inform Lua code it should make use of the $model_gbuffer_* textures before another pass overwrites them (and to allow proper blending with e.g. cloaked objects which are drawn between these events and DrawWorld via gl.CopyToTexture). N.B. The *PostDeferred events are only sent (and only have a real purpose) if forward drawing is disabled.

[source]


method DrawShadowUnitsLua ()


[source]

method DrawShadowFeaturesLua ()


[source]

method DrawWorldPreParticles (drawAboveWater, drawBelowWater, drawReflection, drawRefraction)


DrawWorldPreParticles is called multiples times per draw frame. Each call has a different permutation of values for drawAboveWater, drawBelowWater, drawReflection, and drawRefraction.

[source]


Params

drawAboveWater: boolean
drawBelowWater: boolean
drawReflection: boolean
drawRefraction: boolean

method DrawScreen (viewSizeX, viewSizeY)


Also available to LuaMenu.

[source]


Params

viewSizeX: number
viewSizeY: number

method DrawScreenEffects (viewSizeX, viewSizeY)


[source]

Params

viewSizeX: number
viewSizeY: number

method DrawScreenPost (viewSizeX, viewSizeY)


Similar to DrawScreenEffects, this can be used to alter the contents of a frame after it has been completely rendered (i.e. World, MiniMap, Menu, UI).

[source]

Note: This callin is invoked after the software rendered cursor (configuration variable HardwareCursor=0) is drawn.


Params

viewSizeX: number
viewSizeY: number

method DrawInMiniMap (sx, sy)


[source]

Params

sx: number --relative to the minimap's position and scale.
sy: number --relative to the minimap's position and scale.

method DrawInMiniMapBackground (sx, sy)


[source]

Params

sx: number --relative to the minimap's position and scale.
sy: number --relative to the minimap's position and scale.

method GameProgress (serverFrameNum)


Called every 60 frames, calculating delta between GameFrame and GameProgress.

Can give an ETA about catching up with simulation for mid-game join players.

[source]


Params

serverFrameNum: integer

method KeyMapChanged ()


Called when the keymap changes

[source]

Can be caused due to a change in language or keyboard


method KeyPress (keyCode, mods, isRepeat, label, utf32char, scanCode, actionList) -> halt


Called repeatedly when a key is pressed down.

[source]

Return true if you don’t want other callins or the engine to also receive this keypress. A list of key codes can be seen at the SDL wiki.


Params

keyCode: number
mods: KeyModifiers
isRepeat: boolean --If you want an action to occur only once check for isRepeat == false.
label: boolean --the name of the key
utf32char: number --(deprecated) always 0
scanCode: number
actionList: table --the list of actions for this keypress

Returns

halt: boolean --whether to halt the chain for consumers of the keypress

method KeyRelease (keyCode, mods, label, utf32char, scanCode, actionList) ->


Called when the key is released.

[source]


Params

keyCode: number
mods: KeyModifiers
label: boolean --the name of the key
utf32char: number --(deprecated) always 0
scanCode: number
actionList: table --the list of actions for this keyrelease

Returns

: boolean

method TextInput (utf8char)


Called whenever a key press results in text input.

[source]


Params

utf8char: string

method TextEditing (utf8, start, length)


[source]

Params

utf8: string
start: number
length: number

method MousePress (x, y, button) -> becomeMouseOwner


Called when a mouse button is pressed.

The button parameter supports up to 7 buttons. Must return true for MouseRelease and other functions to be called.

[source]


Params

x: number
y: number
button: number

Returns

becomeMouseOwner: boolean

method MouseRelease (x, y, button) -> becomeMouseOwner


Called when a mouse button is released.

[source]

Please note that in order to have Spring call Spring.MouseRelease, you need to have a Spring.MousePress call-in in the same addon that returns true.


Params

x: number
y: number
button: number

Returns

becomeMouseOwner: boolean

method MouseMove (x, y, dx, dy, button)


Called when the mouse is moved.

[source]


Params

x: number --final x position
y: number --final y position
dx: number --distance travelled in x
dy: number --distance travelled in y
button: number

method MouseWheel (up, value)


Called when the mouse wheel is moved.

[source]


Params

up: boolean --the direction
value: number --the amount travelled

method IsAbove (x, y) -> isAbove


Called every Update.

[source]

Must return true for Mouse* events and Spring.GetToolTip to be called.


Params

x: number
y: number

Returns

isAbove: boolean

method GetTooltip (x, y) -> tooltip


Called when Spring.IsAbove returns true.

[source]


Params

x: number
y: number

Returns

tooltip: string

method ActiveCommandChanged (cmdId, cmdType)


Called when a command is issued.

[source]


Params

cmdId: integer?
cmdType: integer?

method CameraRotationChanged (rotX, rotY, rotZ)


Called whenever the camera rotation changes

[source]


Params

rotX: number --Camera rotation around the x axis in radians.
rotY: number --Camera rotation around the y axis in radians.
rotZ: number --Camera rotation around the z axis in radians.

method CameraPositionChanged (posX, posY, posZ)


Called whenever the camera position changes

[source]


Params

posX: number --Camera position x in world coordinates
posY: number --Camera position y in world coordinates
posZ: number --Camera position z in world coordinates

method CommandNotify (cmdID, cmdParams, options) -> Returning


Called when a command is issued.

[source]


Params

cmdID: integer
cmdParams: table
options: CommandOptions

Returns

Returning: boolean --true deletes the command and does not send it through the network.

method AddConsoleLine (msg, priority)


Called when text is entered into the console (e.g. Spring.Echo).

[source]


Params

msg: string
priority: integer

method GroupChanged (groupID)


Called when a unit is added to or removed from a control group.

[source]


Params

groupID: integer

method WorldTooltip (type, unitId) -> tooltip


[source]

Params

type: “unit”
unitId: integer

Returns

tooltip: string

method WorldTooltip (type, featureId) -> tooltip


[source]

Params

type: “feature”
featureId: integer

Returns

tooltip: string

method WorldTooltip (type, posX, posY, posZ) -> tooltip


[source]

Params

type: “ground”
posX: number
posY: number
posZ: number

Returns

tooltip: string

method WorldTooltip (type) -> tooltip


[source]

Params

type: “selection”

Returns

tooltip: string

method MapDrawCmd (playerID, type, posX, posY, posZ, label)


[source]

Params

playerID: integer
type: “point”
posX: number
posY: number
posZ: number
label: string

method MapDrawCmd (playerID, type, pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z)


[source]

Params

playerID: integer
type: “line”
pos1X: number
pos1Y: number
pos1Z: number
pos2X: number
pos2Y: number
pos2Z: number

method MapDrawCmd (playerID, type, posX, posY, posZ, radius)


[source]

Params

playerID: integer
type: “erase”
posX: number
posY: number
posZ: number
radius: number

method GameSetup (state, ready, playerStates) -> gameHandled, newReady


Fired when the pregame stage is reached

Pregame is the stage where player readiness is managed before a game starts. Game only starts once all players are ready.

[source]


Params

state: READY_MESSAGE --the current message the engine would display to the player
ready: boolean --whether the player is currently ready or not
playerStates: table<number,READY_STATE> --indexed by playerID

Returns

gameHandled: boolean? --disables the engine ui when true
newReady: boolean? --whether the player is ready (ignored unless `gameHandled = true`)

method RecvSkirmishAIMessage (aiTeam, dataStr)


[source]

Params

aiTeam: integer
dataStr: string

method DownloadQueued (id, name, type)


Called when a Pr-downloader download is queued

[source]


Params

id: integer
name: string
type: string

method DownloadStarted (id)


Called when a Pr-downloader download is started via VFS.DownloadArchive.

[source]


Params

id: integer

method DownloadFinished (id)


Called when a Pr-downloader download finishes successfully.

[source]


Params

id: integer

method DownloadFailed (id, errorID)


Called when a Pr-downloader download fails to complete.

[source]


Params

id: integer
errorID: integer

method DownloadProgress (id, downloaded, total)


Called incrementally during a Pr-downloader download.

[source]


Params

id: integer
downloaded: integer
total: integer

alias CameraMode


is (0|1|2|3|4|5|6)

alias CameraName


is (“ta”|“spring”|“rot”|“ov”|“free”|“fps”|“dummy”)

class CameraState


Parameters for camera state.

Highly dependent on the type of the current camera controller.


field name


is CameraName
The camera name.

field mode


is CameraMode
The camera mode.

field fov


is number?

field px


is number?
Position X of the ground point in screen center.

field py


is number?
Position Y of the ground point in screen center.

field pz


is number?
Position Z of the ground point in screen center.

field dx


is number?
Camera direction vector X.

field dy


is number?
Camera direction vector Y.

field dz


is number?
Camera direction vector Z.

field rx


is number?
Camera rotation angle on X axis. (spring)

field ry


is number?
Camera rotation angle on Y axis. (spring)

field rz


is number?
Camera rotation angle on Z axis. (spring)

field angle


is number?
Camera rotation angle on X axis (aka tilt/pitch). (ta)

field flipped


is number?
-1 for when south is down, 1 for when north is down. (ta)

field dist


is number?
Camera distance from the ground. (spring)

field height


is number?
Camera distance from the ground. (ta)

field oldHeight


is number?
Camera distance from the ground, cannot be changed. (rot)

class CameraVectors


[source]

field forward


is xyz

field up


is xyz

field right


is xyz

field topFrustumPlane


is xyz

field botFrustumPlane


is xyz

field lftFrustumPlane


is xyz

field rgtFrustumPlane


is xyz

enum CMD


Command constants.

Table defining Command related constants.

  • Contains a mix of special constants like command options or move states, and the list of engine command IDs.
  • Also supports integer keys, and those perform reverse mapping of command IDs.

[source]


See: Spring.GiveOrderToUnit Spring.GiveOrderArrayToUnitArray Spring.GetUnitCurrentCommand Callins:AllowCommand Spring.GiveOrderToUnit

field OPT_ALT


is integer
[source]

field OPT_CTRL


is integer
[source]

field OPT_SHIFT


is integer
[source]

field OPT_RIGHT


is integer
[source]

field OPT_INTERNAL


is integer
[source]

field OPT_META


is integer
[source]

field MOVESTATE_NONE


is integer
[source]

field MOVESTATE_HOLDPOS


is integer
[source]

field MOVESTATE_MANEUVER


is integer
[source]

field MOVESTATE_ROAM


is integer
[source]

field FIRESTATE_NONE


is integer
[source]

field FIRESTATE_HOLDFIRE


is integer
[source]

field FIRESTATE_RETURNFIRE


is integer
[source]

field FIRESTATE_FIREATWILL


is integer
[source]

field FIRESTATE_FIREATNEUTRAL


is integer
[source]

field WAITCODE_TIME


is integer
[source]

field WAITCODE_DEATH


is integer
[source]

field WAITCODE_SQUAD


is integer
[source]

field WAITCODE_GATHER


is integer
[source]

field STOP


is integer

Stop the current action and clear the unit’s command queue.

For factories, this will cancel the new unit orders queue. For units, this will cancel the current command and queue.

Accepts no parameters.

It won’t do anything if used with CMD.INSERT, or the shift option.

[source]


field INSERT


is integer
[source]

field REMOVE


is integer

Remove all commands from a unit’s queue matching specific cmdIDs or tags.

Modes of operation

Filter by tag

Removes any command with a tag matching those included in params.

  • params {tag1, tag2 …} an array of tags to look for.

This is the default mode of operation.

Filter by id

Removes any command with a command id matching those included in params.

  • params {id1, id2 …} or {tag1, tag2, …} an array of ids tags to look for.

To use this mode you need to pass the alt option.

Command Options

  • alt Tag/Id switch
  • ctrl Alternative queue selection.
  • For factories alternative queue is the factory command queue, default queue is the rally queue.
  • For other units no effect.

Examples

Delete all attack orders from unit, or factory rally queue if factory:

Spring.GiveOrderToUnit(unitID, CMD.REMOVE, CMD.ATTACK)

Delete all attack and fight orders from unit, or factory rally queue if factory:

Spring.GiveOrderToUnit(unitID, CMD.REMOVE, {CMD.ATTACK, CMD.FIGHT}, CMD.OPT_ALT)

Delete commands with specific tags:

Spring.GiveOrderToUnit(unitID, CMD.REMOVE, {tag1, tag2, tag3})

Delete all commands to build units with UnitDef ids unitDefId1 and unitDefId2 from factory queue:

Spring.GiveOrderToUnit(unitID, CMD.REMOVE, {-unitDefId1, -unitDefId2}, CMD.OPT_ALT + CMD.OPT_CTRL)

[source]


field WAIT


is integer

Makes the unit suspend processing its command queue until wait is removed.

Accepts no parameters.

[source]


field TIMEWAIT


is integer

Makes the unit suspend processing its command queue for a given duration.

  • params {duration} Time to wait in seconds.

[source]


field DEATHWAIT


is integer

Makes the unit suspend processing its commmand queue until the death of a given unit or units in an area.

Modes of operation

Wait for death of specific unit

  • params {unitID} unitID of the unit to wait for.

Wait for death of units in an area

  • params {x1, y1, z1, x2, y2, z2}: Wait for death of units in square {x1, z1, x2, z2}.

[source]


field SQUADWAIT


is integer

Makes selected units, or units coming out of a factory wait until squadSize peers are found to go with them.

If given to non factory units and the squadSize is smaller than the selected number of units the command will have no effect.

Each unit will find squadSize other units and resume wait, those remaining without peers will wait. For example if there are 30 selected units and a squadSize of 12 is sent, 6 units will stay waiting, as 30 - 12*2 = 6.

If given at a waypoint for a factory queue for new units, units coming out of the factory will wait at the waypoint until squadSize units are available, and then they will proceed together.

Can also be given to a group of factories, and units from those factories will gather together.

  • params {squadSize} Squad size.

[source]


field GATHERWAIT


is integer

Makes the unit wait for all other selected units to reach the command.

Useful to make units wait until all other units have reached a waypoint.

Will only be given to movable (unitDef.canMove == true) non-factory units.

Accepts no parameters.

[source]


field MOVE


is integer
[source]

field PATROL


is integer
[source]

field FIGHT


is integer
[source]

field ATTACK


is integer

Attack command. Gives an order to attack some target(s).

The command has different modes of operation, depending on the number of parameters and options used.

Modes of operation

Attack single target

  • params {unitID}: Attack a unit

The command will end once the target is dead or not valid any more.

Area attack

Will create a number of single target actions by finding targets in a circle.

Note: this is different than CMD.AREA_ATTACK, since this initially finds the targets but then doesn’t consider the area any more.

  • params {x,y,z,r} when radius is greater than 0.
  • r: radius
  • x,y,z: map position

Ground attack

  • params {x,y,z,0} or {x,y,z}
  • x,y,z: map position

Command Options

  • alt Also target stunned targets. Without this stunned targets will be skipped.
  • meta Override manualFire, and noAutoTarget weapon behaviours.

Other modifiers

  • modInfo.targetableTransportedUnits: Controls whether transported units are targetable.

Callins

  • UnitCmdDone: Run when the command is finished.

Examples

Attack unit with id targetID.

Spring.GiveOrderToUnit(unitID, CMD.ATTACK, targetID)

Area attack of radius 50 at map position 1000,1000 with height 100:

Spring.GiveOrderToUnit(unitID, CMD.ATTACK, {1000,100,1000,50})

Ground attack at map position 1000,1000 with height 100:

Spring.GiveOrderToUnit(unitID, CMD.ATTACK, {1000,100,1000})

[source]


field AREA_ATTACK


is integer
[source]

field GUARD


is integer
[source]

field GROUPSELECT


is integer
[source]

field GROUPADD


is integer
[source]

field GROUPCLEAR


is integer
[source]

field REPAIR


is integer
[source]

field FIRE_STATE


is integer
[source]

field MOVE_STATE


is integer
[source]

field SETBASE


is integer
[source]

field INTERNAL


is integer
[source]

field SELFD


is integer
[source]

field LOAD_UNITS


is integer
[source]

field LOAD_ONTO


is integer
[source]

field UNLOAD_UNITS


is integer
[source]

field UNLOAD_UNIT


is integer
[source]

field ONOFF


is integer
[source]

field RECLAIM


is integer
[source]

field CLOAK


is integer
[source]

field STOCKPILE


is integer
[source]

field MANUALFIRE


is integer
[source]

field DGUN


is integer
[source]

field RESTORE


is integer
[source]

field REPEAT


is integer
[source]

field TRAJECTORY


is integer
[source]

field RESURRECT


is integer
[source]

field CAPTURE


is integer
[source]

field AUTOREPAIRLEVEL


is integer
[source]

field LOOPBACKATTACK


is integer
[source]

field IDLEMODE


is integer
[source]

enum CMDTYPE


Command type constants

Note, the CMDTYPE[] table is bidirectional. That means: CMDTYPE[CMDTYPE.ICON] := "CMDTYPE_ICON"

[source]


field ICON


is integer

Expect 0 parameters in return.

[source]


field ICON_MODE


is integer

Expect 1 parameter in return (number selected mode).

[source]


field ICON_MAP


is integer

Expect 3 parameters in return (mappos).

[source]


field ICON_AREA


is integer

Expect 4 parameters in return (mappos+radius).

[source]


field ICON_UNIT


is integer

Expect 1 parameters in return (unitid).

[source]


field ICON_UNIT_OR_MAP


is integer

Expect 1 parameters in return (unitid) or 3 parameters in return (mappos).

[source]


field ICON_FRONT


is integer

Expect 3 or 6 parameters in return (middle and right side of front if a front was defined).

[source]


field ICON_UNIT_OR_AREA


is integer

Expect 1 parameter in return (unitid) or 4 parameters in return (mappos+radius).

[source]


field NEXT


is integer

Expect command page used with CMD_INTERNAL.

[source]


field PREV


is integer

Expect command page used with CMD_INTERNAL.

[source]


field ICON_UNIT_FEATURE_OR_AREA


is integer

Expect 1 parameter in return (unitid or Game.maxUnits+featureid) or 4 parameters in return (mappos+radius).

[source]


field ICON_BUILDING


is integer

Expect 3 parameters in return (mappos).

[source]


field CUSTOM


is integer

Expect with CMD_INTERNAL.

[source]


field ICON_UNIT_OR_RECTANGLE


is integer

Expect 1 parameter in return (unitid) or 3 parameters in return (mappos) or 6 parameters in return (startpos+endpos).

[source]


field NUMBER


is integer

Expect 1 parameter in return (number).

[source]


enum COB


COB constants

[source]


field ACTIVATION


is integer
[source]

field STANDINGMOVEORDERS


is integer
[source]

field STANDINGFIREORDERS


is integer
[source]

field HEALTH


is integer
[source]

field INBUILDSTANCE


is integer
[source]

field BUSY


is integer
[source]

field PIECE_XZ


is integer
[source]

field PIECE_Y


is integer
[source]

field UNIT_XZ


is integer
[source]

field UNIT_Y


is integer
[source]

field UNIT_HEIGHT


is integer
[source]

field XZ_ATAN


is integer
[source]

field XZ_HYPOT


is integer
[source]

field ATAN


is integer
[source]

field HYPOT


is integer
[source]

field GROUND_HEIGHT


is integer
[source]

field BUILD_PERCENT_LEFT


is integer
[source]

field YARD_OPEN


is integer
[source]

field BUGGER_OFF


is integer
[source]

field ARMORED


is integer
[source]

field IN_WATER


is integer
[source]

field CURRENT_SPEED


is integer
[source]

field VETERAN_LEVEL


is integer
[source]

field ON_ROAD


is integer
[source]

field MAX_ID


is integer
[source]

field MY_ID


is integer
[source]

field UNIT_TEAM


is integer
[source]

field UNIT_BUILD_PERCENT_LEFT


is integer
[source]

field UNIT_ALLIED


is integer
[source]

field MAX_SPEED


is integer
[source]

field CLOAKED


is integer
[source]

field WANT_CLOAK


is integer
[source]

field GROUND_WATER_HEIGHT


is integer
[source]

field UPRIGHT


is integer
[source]

field POW


is integer
[source]

field PRINT


is integer
[source]

field HEADING


is integer
[source]

field TARGET_ID


is integer
[source]

field LAST_ATTACKER_ID


is integer
[source]

field LOS_RADIUS


is integer
[source]

field AIR_LOS_RADIUS


is integer
[source]

field RADAR_RADIUS


is integer
[source]

field JAMMER_RADIUS


is integer
[source]

field SONAR_RADIUS


is integer
[source]

field SONAR_JAM_RADIUS


is integer
[source]

field SEISMIC_RADIUS


is integer
[source]

field DO_SEISMIC_PING


is integer
[source]

field CURRENT_FUEL


is integer
[source]

field TRANSPORT_ID


is integer
[source]

field SHIELD_POWER


is integer
[source]

field STEALTH


is integer
[source]

field CRASHING


is integer
[source]

field CHANGE_TARGET


is integer
[source]

field CEG_DAMAGE


is integer
[source]

field COB_ID


is integer
[source]

field PLAY_SOUND


is integer
[source]

field KILL_UNIT


is integer
[source]

field SET_WEAPON_UNIT_TARGET


is integer
[source]

field SET_WEAPON_GROUND_TARGET


is integer
[source]

field SONAR_STEALTH


is integer
[source]

field REVERSING


is integer
[source]

field FLANK_B_MODE


is integer
[source]

field FLANK_B_DIR


is integer
[source]

field FLANK_B_MOBILITY_ADD


is integer
[source]

field FLANK_B_MAX_DAMAGE


is integer
[source]

field FLANK_B_MIN_DAMAGE


is integer
[source]

field WEAPON_RELOADSTATE


is integer
[source]

field WEAPON_RELOADTIME


is integer
[source]

field WEAPON_ACCURACY


is integer
[source]

field WEAPON_SPRAY


is integer
[source]

field WEAPON_RANGE


is integer
[source]

field WEAPON_PROJECTILE_SPEED


is integer
[source]

field MIN


is integer
[source]

field MAX


is integer
[source]

field ABS


is integer
[source]

field GAME_FRAME


is integer
[source]

class CollisionVolumeData


Parameters related to a collision volume.

[source]


field type


is (“ellipsoid”|“cylinder”|“box”|“sphere”)
type

field scaleX


is number

field scaleY


is number

field scaleZ


is number

field offsetX


is number

field offsetY


is number

field offsetZ


is number

field boundingRadius


is number

field defaultToSphere


is boolean

field defaultToFootPrint


is boolean

field defaultToPieceTree


is boolean

class Command


[source]

field id


is integer

field params


is number[]?

field options


is CommandOptions?

class CommandDescription


Contains data about a command.

[source]


field id


is (CMD|integer)?

field type


is CMDTYPE?

field name


is string?

field action


is string?

field tooltip


is string?

field texture


is string?

field cursor


is string?

field queueing


is boolean?

field hidden


is boolean?

field disabled


is boolean?

field showUnique


is boolean?

field onlyTexture


is boolean?

field params


is string[]?

alias CommandOptionBit


is (4|8|16|32|64|128)
[source]

alias CommandOptionName


is (“right”|“alt”|“ctrl”|“shift”|“meta”)
[source]

class CommandOptions


Full command options object for reading from a Command.

Note that this has extra fields internal and coded that are not supported when creating a command from Lua.

[source]


field coded


is (CommandOptionBit|integer)
Bitmask of command options.

field alt


is boolean
Alt key pressed.

field ctrl


is boolean
Ctrl key pressed.

field shift


is boolean
Shift key pressed.

field right


is boolean
Right mouse key pressed.

field meta


is boolean
Meta key (space) pressed.

field internal


is boolean

class Configuration


Contains data about a configuration, only name and type are guaranteed

[source]


field name


is string

field type


is string

field description


is string

field defaultValue


is string

field minimumValue


is string

field maximumValue


is string

field safemodeValue


is string

field declarationFile


is string

field declarationLine


is string

field readOnly


is boolean

class ControlPoint


NURBS control point.

[source]


field [1]


is number
x

field [2]


is number
y

field [3]


is number
z

field [4]


is number
weight

class CreateCommand


Used when assigning multiple commands at once.

[source]


field [1]


is (CMD|integer)
Command ID.

field [2]


is CreateCommandParams?
Parameters for the given command.

field [3]


is CreateCommandOptions?
Command options.

field [4]


is integer?
Timeout.

alias CreateCommandOptions


is (CommandOptionName[]|table<CommandOptionName,boolean>|CommandOptionBit|integer)
[source]

alias CreateCommandParams


is (number[]|number)
[source]

class CreateRBOData


[source]

field target


is GL

field format


is GL

field samples


is number?
any number here will result in creation of multisampled RBO

alias DrawFlag


is (0|1|2|4|8|16|32|128)

Drawing Flags

[source]


alias DrawMask


is integer

class ExplosionParams


Parameters for explosion.

Please note the explosion defaults to 1 damage regardless of what it’s defined in the weaponDef. The weapondefID is only used for visuals and for passing into callins like UnitDamaged.

[source]


field weaponDef


is number

field owner


is number

field hitUnit


is number

field hitFeature


is number

field craterAreaOfEffect


is number

field damageAreaOfEffect


is number

field edgeEffectiveness


is number

field explosionSpeed


is number

field gfxMod


is number

field impactOnly


is boolean

field ignoreOwner


is boolean

field damageGround


is boolean

alias Facing


is (0|1|2|3|“s”|“e”|“n”|“w”|“south”|“east”|“north”|“west”)

alias FacingInteger


is (0|1|2|3)

class FBO


User Data FBO

[source]


class FBODescription


[source]

field depth


is string?

field stencil


is string?

field color0


is string?

field color1


is string?

field color2


is string?

field color3


is string?

field color4


is string?

field color5


is string?

field color6


is string?

field color7


is string?

field color8


is string?

field color9


is string?

field color10


is string?

field color11


is string?

field color12


is string?

field color13


is string?

field color14


is string?

field color15


is string?

field drawbuffers


is (integer|GL)[]?
e.g. { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT3_EXT, ..}

field readbuffer


is (integer|GL)?
e.g. GL_COLOR_ATTACHMENT0_EXT

class FeatureSupport


[source]

field NegativeGetUnitCurrentCommand


is boolean
Whether Spring.GetUnitCurrentCommand allows negative indices to look from the end

field hasExitOnlyYardmaps


is boolean
Whether yardmaps accept ’e’ (exit only) and ‘u’ (unbuildable, walkable)

field rmlUiApiVersion


is integer
Version of Recoil’s rmlUI API

field noAutoShowMetal


is boolean
Whether the engine switches to the metal view when selecting a “build metal extractor” command (yes if false)

field maxPiecesPerModel


is integer
How many pieces supported for 3d models?

field gunshipCruiseAltitudeMultiplier


is number
For gunships, the cruiseAltitude from the unit def is multiplied by this much

field noRefundForConstructionDecay


is boolean
Whether there is no refund for construction decay (100% metal back if false)

field noRefundForFactoryCancel


is boolean
Whether there is no refund for factory cancel (100% metal back if false)

field noOffsetForFeatureID


is boolean
Whether featureID from various interfaces (targetID for Reclaim commands, ownerID from SpringGetGroundDecalOwner, etc) needs to be offset by Game.maxUnits

field noHandicapForReclaim


is boolean
Whether handicap is applied to income from reclaim

field groupAddDoesntSelect


is boolean
Whether ‘group add’ also selects the group (does both if false)

alias float2


is xy

alias float3


is xyz

alias float4


is xyzw

class GenericMoveType


[source]

field maxSpeed


is number?

field maxWantedSpeed


is number?

field maneuverLeash


is number?

field waterline


is number?

field useWantedSpeed[0]


is boolean?
Use wanted speed for individual orders.

field useWantedSpeed[1]


is boolean?
Use wanted speed for formation orders.

alias GenericMoveTypeBooleanKey


is (“useWantedSpeed[0]"|“useWantedSpeed[1]”)
[source]

alias GenericMoveTypeNumberKey


is (“maxSpeed”|“maxWantedSpeed”|“maneuverLeash”|“waterline”)
[source]

enum GL


Constants for OpenGL API

For callouts related to OpenGL usage in Recoil, see gl.

[source]


See: gl

field POINTS


is integer
[source]

field LINES


is integer
[source]

field LINE_LOOP


is integer
[source]

field LINE_STRIP


is integer
[source]

field TRIANGLES


is integer
[source]

field TRIANGLE_STRIP


is integer
[source]

field TRIANGLE_FAN


is integer
[source]

field QUADS


is integer
[source]

field QUAD_STRIP


is integer
[source]

field POLYGON


is integer
[source]

field LINE_STRIP_ADJACENCY


is integer
[source]

field LINES_ADJACENCY


is integer
[source]

field TRIANGLE_STRIP_ADJACENCY


is integer
[source]

field TRIANGLES_ADJACENCY


is integer
[source]

field PATCHES


is integer
[source]

field ZERO


is integer
[source]

field ONE


is integer
[source]

field SRC_COLOR


is integer
[source]

field ONE_MINUS_SRC_COLOR


is integer
[source]

field SRC_ALPHA


is integer
[source]

field ONE_MINUS_SRC_ALPHA


is integer
[source]

field DST_ALPHA


is integer
[source]

field ONE_MINUS_DST_ALPHA


is integer
[source]

field DST_COLOR


is integer
[source]

field ONE_MINUS_DST_COLOR


is integer
[source]

field SRC_ALPHA_SATURATE


is integer
[source]

field FUNC_ADD


is integer
[source]

field FUNC_SUBTRACT


is integer
[source]

field FUNC_REVERSE_SUBTRACT


is integer
[source]

field MIN


is integer
[source]

field MAX


is integer
[source]

field NEVER


is integer
[source]

field LESS


is integer
[source]

field EQUAL


is integer
[source]

field LEQUAL


is integer
[source]

field GREATER


is integer
[source]

field NOTEQUAL


is integer
[source]

field GEQUAL


is integer
[source]

field ALWAYS


is integer
[source]

field CLEAR


is integer
[source]

field AND


is integer
[source]

field AND_REVERSE


is integer
[source]

field COPY


is integer
[source]

field AND_INVERTED


is integer
[source]

field NOOP


is integer
[source]

field XOR


is integer
[source]

field OR


is integer
[source]

field NOR


is integer
[source]

field EQUIV


is integer
[source]

field INVERT


is integer
[source]

field OR_REVERSE


is integer
[source]

field COPY_INVERTED


is integer
[source]

field OR_INVERTED


is integer
[source]

field NAND


is integer
[source]

field SET


is integer
[source]

field BACK


is integer
[source]

field FRONT


is integer
[source]

field FRONT_AND_BACK


is integer
[source]

field POINT


is integer
[source]

field LINE


is integer
[source]

field FILL


is integer
[source]

field FLAT


is integer
[source]

field SMOOTH


is integer
[source]

field MODELVIEW


is integer
[source]

field PROJECTION


is integer
[source]

field TEXTURE


is integer
[source]

field NEAREST


is integer
[source]

field LINEAR


is integer
[source]

field NEAREST_MIPMAP_NEAREST


is integer
[source]

field LINEAR_MIPMAP_NEAREST


is integer
[source]

field NEAREST_MIPMAP_LINEAR


is integer
[source]

field LINEAR_MIPMAP_LINEAR


is integer
[source]

field REPEAT


is integer
[source]

field MIRRORED_REPEAT


is integer
[source]

field CLAMP


is integer
[source]

field CLAMP_TO_EDGE


is integer
[source]

field CLAMP_TO_BORDER


is integer
[source]

field TEXTURE_ENV


is integer
[source]

field TEXTURE_ENV_MODE


is integer
[source]

field TEXTURE_ENV_COLOR


is integer
[source]

field MODULATE


is integer
[source]

field DECAL


is integer
[source]

field BLEND


is integer
[source]

field REPLACE


is integer
[source]

field TEXTURE_FILTER_CONTROL


is integer
[source]

field TEXTURE_LOD_BIAS


is integer
[source]

field TEXTURE_GEN_MODE


is integer
[source]

field EYE_PLANE


is integer
[source]

field OBJECT_PLANE


is integer
[source]

field EYE_LINEAR


is integer
[source]

field OBJECT_LINEAR


is integer
[source]

field SPHERE_MAP


is integer
[source]

field NORMAL_MAP


is integer
[source]

field REFLECTION_MAP


is integer
[source]

field S


is integer
[source]

field T


is integer
[source]

field R


is integer
[source]

field Q


is integer
[source]

field CURRENT_BIT


is integer
[source]

field POINT_BIT


is integer
[source]

field LINE_BIT


is integer
[source]

field POLYGON_BIT


is integer
[source]

field POLYGON_STIPPLE_BIT


is integer
[source]

field PIXEL_MODE_BIT


is integer
[source]

field LIGHTING_BIT


is integer
[source]

field FOG_BIT


is integer
[source]

field DEPTH_BUFFER_BIT


is integer
[source]

field ACCUM_BUFFER_BIT


is integer
[source]

field STENCIL_BUFFER_BIT


is integer
[source]

field VIEWPORT_BIT


is integer
[source]

field TRANSFORM_BIT


is integer
[source]

field ENABLE_BIT


is integer
[source]

field COLOR_BUFFER_BIT


is integer
[source]

field HINT_BIT


is integer
[source]

field EVAL_BIT


is integer
[source]

field LIST_BIT


is integer
[source]

field TEXTURE_BIT


is integer
[source]

field SCISSOR_BIT


is integer
[source]

field ALL_ATTRIB_BITS


is integer
[source]

field FOG_HINT


is integer
[source]

field PERSPECTIVE_CORRECTION_HINT


is integer
[source]

field DONT_CARE


is integer
[source]

field FASTEST


is integer
[source]

field NICEST


is integer
[source]

field AMBIENT


is integer
[source]

field DIFFUSE


is integer
[source]

field SPECULAR


is integer
[source]

field POSITION


is integer
[source]

field SPOT_DIRECTION


is integer
[source]

field SPOT_EXPONENT


is integer
[source]

field SPOT_CUTOFF


is integer
[source]

field CONSTANT_ATTENUATION


is integer
[source]

field LINEAR_ATTENUATION


is integer
[source]

field QUADRATIC_ATTENUATION


is integer
[source]

field VERTEX_SHADER


is integer
[source]

field TESS_CONTROL_SHADER


is integer
[source]

field TESS_EVALUATION_SHADER


is integer
[source]

field GEOMETRY_SHADER_EXT


is integer
[source]

field FRAGMENT_SHADER


is integer
[source]

field GEOMETRY_INPUT_TYPE_EXT


is integer
[source]

field GEOMETRY_OUTPUT_TYPE_EXT


is integer
[source]

field GEOMETRY_VERTICES_OUT_EXT


is integer
[source]

field PATCH_VERTICES


is integer
[source]

field PATCH_DEFAULT_OUTER_LEVEL


is integer
[source]

field PATCH_DEFAULT_INNER_LEVEL


is integer
[source]

field BYTE


is integer
[source]

field UNSIGNED_BYTE


is integer
[source]

field SHORT


is integer
[source]

field UNSIGNED_SHORT


is integer
[source]

field INT


is integer
[source]

field UNSIGNED_INT


is integer
[source]

field FLOAT


is integer
[source]

field FLOAT_VEC4


is integer
[source]

field INT_VEC4


is integer
[source]

field UNSIGNED_INT_VEC4


is integer
[source]

field FLOAT_MAT4


is integer
[source]

field ELEMENT_ARRAY_BUFFER


is integer
[source]

field ARRAY_BUFFER


is integer
[source]

field UNIFORM_BUFFER


is integer
[source]

field SHADER_STORAGE_BUFFER


is integer
[source]

field TEXTURE_1D


is integer
[source]

field TEXTURE_2D


is integer
[source]

field TEXTURE_2D_ARRAY


is integer
[source]

field TEXTURE_3D


is integer
[source]

field TEXTURE_CUBE_MAP


is integer
[source]

field TEXTURE_2D_MULTISAMPLE


is integer
[source]

field RGBA32F


is integer
[source]

field RGBA16F


is integer
[source]

field RG32F


is integer
[source]

field RG16F


is integer
[source]

field R11F_G11F_B10F


is integer
[source]

field R32F


is integer
[source]

field R16F


is integer
[source]

field RGBA32UI


is integer
[source]

field RGBA16UI


is integer
[source]

field RGB10_A2UI


is integer
[source]

field RGBA8UI


is integer
[source]

field RG32UI


is integer
[source]

field RG16UI


is integer
[source]

field RG8UI


is integer
[source]

field R32UI


is integer
[source]

field R16UI


is integer
[source]

field R8UI


is integer
[source]

field RGBA32I


is integer
[source]

field RGBA16I


is integer
[source]

field RGBA8I


is integer
[source]

field RG32I


is integer
[source]

field RG16I


is integer
[source]

field RG8I


is integer
[source]

field R32I


is integer
[source]

field R16I


is integer
[source]

field R8I


is integer
[source]

field RGBA16


is integer
[source]

field RGB10_A2


is integer
[source]

field RGBA8


is integer
[source]

field RG16


is integer
[source]

field RG8


is integer
[source]

field R16


is integer
[source]

field R8


is integer
[source]

field RGBA16_SNORM


is integer
[source]

field RGBA8_SNORM


is integer
[source]

field RG16_SNORM


is integer
[source]

field RG8_SNORM


is integer
[source]

field R16_SNORM


is integer
[source]

field R8_SNORM


is integer
[source]

field DEPTH_COMPONENT16


is integer
[source]

field DEPTH_COMPONENT24


is integer
[source]

field DEPTH_COMPONENT32


is integer
[source]

field DEPTH_COMPONENT32F


is integer
[source]

field READ_ONLY


is integer
[source]

field WRITE_ONLY


is integer
[source]

field READ_WRITE


is integer
[source]

field VERTEX_ATTRIB_ARRAY_BARRIER_BIT


is integer
[source]

field ELEMENT_ARRAY_BARRIER_BIT


is integer
[source]

field UNIFORM_BARRIER_BIT


is integer
[source]

field TEXTURE_FETCH_BARRIER_BIT


is integer
[source]

field SHADER_IMAGE_ACCESS_BARRIER_BIT


is integer
[source]

field COMMAND_BARRIER_BIT


is integer
[source]

field PIXEL_BUFFER_BARRIER_BIT


is integer
[source]

field TEXTURE_UPDATE_BARRIER_BIT


is integer
[source]

field BUFFER_UPDATE_BARRIER_BIT


is integer
[source]

field FRAMEBUFFER_BARRIER_BIT


is integer
[source]

field TRANSFORM_FEEDBACK_BARRIER_BIT


is integer
[source]

field ATOMIC_COUNTER_BARRIER_BIT


is integer
[source]

field SHADER_STORAGE_BARRIER_BIT


is integer
[source]

field ALL_BARRIER_BITS


is integer
[source]

field COLOR_ATTACHMENT0


is integer
[source]

field COLOR_ATTACHMENT1


is integer
[source]

field COLOR_ATTACHMENT2


is integer
[source]

field COLOR_ATTACHMENT3


is integer
[source]

field COLOR_ATTACHMENT4


is integer
[source]

field COLOR_ATTACHMENT5


is integer
[source]

field COLOR_ATTACHMENT6


is integer
[source]

field COLOR_ATTACHMENT7


is integer
[source]

field COLOR_ATTACHMENT8


is integer
[source]

field COLOR_ATTACHMENT9


is integer
[source]

field COLOR_ATTACHMENT10


is integer
[source]

field COLOR_ATTACHMENT11


is integer
[source]

field COLOR_ATTACHMENT12


is integer
[source]

field COLOR_ATTACHMENT13


is integer
[source]

field COLOR_ATTACHMENT14


is integer
[source]

field COLOR_ATTACHMENT15


is integer
[source]

field DEPTH_ATTACHMENT


is integer
[source]

field STENCIL_ATTACHMENT


is integer
[source]

field COLOR_ATTACHMENT0_EXT


is integer
[source]

field COLOR_ATTACHMENT1_EXT


is integer
[source]

field COLOR_ATTACHMENT2_EXT


is integer
[source]

field COLOR_ATTACHMENT3_EXT


is integer
[source]

field COLOR_ATTACHMENT4_EXT


is integer
[source]

field COLOR_ATTACHMENT5_EXT


is integer
[source]

field COLOR_ATTACHMENT6_EXT


is integer
[source]

field COLOR_ATTACHMENT7_EXT


is integer
[source]

field COLOR_ATTACHMENT8_EXT


is integer
[source]

field COLOR_ATTACHMENT9_EXT


is integer
[source]

field COLOR_ATTACHMENT10_EXT


is integer
[source]

field COLOR_ATTACHMENT11_EXT


is integer
[source]

field COLOR_ATTACHMENT12_EXT


is integer
[source]

field COLOR_ATTACHMENT13_EXT


is integer
[source]

field COLOR_ATTACHMENT14_EXT


is integer
[source]

field COLOR_ATTACHMENT15_EXT


is integer
[source]

field DEPTH_ATTACHMENT_EXT


is integer
[source]

field STENCIL_ATTACHMENT_EXT


is integer
[source]

field BUFFER


is integer
[source]

field SHADER


is integer
[source]

field PROGRAM


is integer
[source]

field VERTEX_ARRAY


is integer
[source]

field QUERY


is integer
[source]

field PROGRAM_PIPELINE


is integer
[source]

field TRANSFORM_FEEDBACK


is integer
[source]

field RENDERBUFFER


is integer
[source]

field FRAMEBUFFER


is integer
[source]

class GroundMoveType


inherits from GenericMoveType


[source]

field atGoal


is boolean?

field atEndOfPath


is boolean?

field pushResistant


is boolean?

field minScriptChangeHeading


is integer?

field turnRate


is number?

field turnAccel


is number?

field accRate


is number?

field decRate


is number?

field myGravity


is number?

field maxReverseDist


is number?

field minReverseAngle


is number?

field maxReverseSpeed


is number?

field sqSkidSpeedMult


is number?

alias HashType


is (0|1)
[source]

alias Heading


is integer

Integer in range [-32768, 32767] that represents a 2D (xz plane) unit orientation.

                  F(N=2) = H(-32768 / 32767)

                         ^
                         |
                         |
 F(W=3) = H(-16384)  <---o--->  F(E=1) = H(16384)
                         |
                         |
                         v

                  F(S=0) = H(0)

[source]


class HoverAirMoveType


inherits from GenericMoveType


[source]

field collide


is boolean?

field dontLand


is boolean?

field airStrafe


is boolean?

field useSmoothMesh


is boolean?

field bankingAllowed


is boolean?

field wantedHeight


is number?

field accRate


is number?

field decRate


is number?

field turnRate


is number?

field altitudeRate


is number?

field currentBank


is number?

field currentPitch


is number?

field maxDrift


is number?

class Intro


inherits from Callins


[source]
See: Callins

method DrawLoadScreen ()


Draws custom load screens.

[source]


method LoadProgress (message, replaceLastLine)


[source]

Params

message: string
replaceLastLine: boolean

class KeyBinding


Contains data about a keybinding

[source]


field command


is string

field extra


is string

field boundWith


is string

class KeyModifiers


Key Modifier Params

[source]


field right


is boolean
Right mouse key pressed

field alt


is boolean
Alt key pressed

field ctrl


is boolean
Ctrl key pressed

field shift


is boolean
Shift key pressed

class LightParams


Parameters for lighting

[source]


field position


is { px: number, py: number, pz: number }

field direction


is { dx: number, dy: number, dz: number }

field ambientColor


is { blue: number, green: number, red: number }

field diffuseColor


is { blue: number, green: number, red: number }

field specularColor


is { blue: number, green: number, red: number }

field intensityWeight


is { ambientWeight: number, diffuseWeight: number, specularWeight: number }

field ambientDecayRate


is { ambientBlueDecay: number, ambientGreenDecay: number, ambientRedDecay: number }
Per-frame decay of ambientColor (spread over TTL frames)

field diffuseDecayRate


is { diffuseBlueDecay: number, diffuseGreenDecay: number, diffuseRedDecay: number }
Per-frame decay of diffuseColor (spread over TTL frames)

field specularDecayRate


is { specularBlueDecay: number, specularGreenDecay: number, specularRedDecay: number }
Per-frame decay of specularColor (spread over TTL frames)

field decayFunctionType


is { ambientDecayType: number, diffuseDecayType: number, specularDecayType: number }
If value is 0.0 then the *DecayRate values will be interpreted as linear, otherwise exponential.

field radius


is number

field fov


is number

field ttl


is number

field priority


is number

field ignoreLOS


is boolean

enum LOG


[source]
See: Spring.Log

field DEBUG


is integer

field INFO


is integer

field NOTICE


is integer
Engine default.

field DEPRECATED


is integer

field WARNING


is integer

field ERROR


is integer

field FATAL


is integer

alias LogLevel


is (integer|“debug”|“info”|“notice”|“warning”|“deprecated”|“error”|“fatal”)
[source]

class losAccess


Parameters for los access

If one condition is fulfilled all beneath it are too (e.g. if an unit is in LOS it can read params with inradar=true even if the param has inlos=false) All GameRulesParam are public, TeamRulesParams can just be private,allied and/or public You can read RulesParams from any Lua environments! With those losAccess policies you can limit their access.

All GameRulesParam are public, TeamRulesParams can just be private,allied and/or public You can read RulesParams from any Lua environments! With those losAccess policies you can limit their access.

[source]


field private


is boolean?
only readable by the ally (default)

field allied


is boolean?
readable by ally + ingame allied

field inlos


is boolean?
readable if the unit is in LOS

field inradar


is boolean?
readable if the unit is in AirLOS

field public


is boolean?
readable by all

enum LosMask


[source]

field INLOS


is integer
the unit is currently in the los of the allyteam

field INRADAR


is integer
the unit is currently in radar from the allyteam

field PREVLOS


is integer
the unit has previously been in los from the allyteam

field CONTRADAR


is integer
the unit has continuously been in radar since it was last inlos by the allyteam

alias LosTable


is table<(“los”|“radar”|“prevLos”|“contRadar”),boolean>
[source]

class LuaFont


Lua opengl font object.

[source]


See: gl.LoadFont

method Begin (userDefinedBlending)


Begin a block of font commands.

[source]

Fonts can be printed without using Start/End, but when doing several operations it’s more optimal if done inside a block.

Also allows disabling automatic setting of the blend mode. Otherwise the font will always print with BlendFunc(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA).


See: gl.BlendFunc gl.BlendFuncSeparate

Params

userDefinedBlending: boolean? --When `true` doesn't set the gl.BlendFunc automatically. Defaults to `false`.

method SubmitBuffered (noBillboarding, userDefinedBlending)


Draws text printed with the buffered option.

[source]


See: gl.BlendFunc gl.BlendFuncSeparate

Params

noBillboarding: boolean? --When `false` sets 3d billboard mode. Defaults to `true`.
userDefinedBlending: boolean? --When `true` doesn't set the gl.BlendFunc automatically. Defaults to `false`.

class MapRenderingParams


Map rendering params

[source]


field splatTexMults


is rgba

field splatTexScales


is rgba

field voidWater


is boolean

field voidGround


is boolean

field splatDetailNormalDiffuseAlpha


is boolean

class Material


[source]

field shininess


is number

field ambidiff


is (rgb|rgba)

field ambient


is (rgb|rgba)

field diffuse


is (rgb|rgba)

field specular


is (rgb|rgba)

field emission


is (rgb|rgba)

class Matrix4x4


[source]

field [1]


is number
Element at [1,1]

field [2]


is number
Element at [1,2]

field [3]


is number
Element at [1,3]

field [4]


is number
Element at [1,4]

field [5]


is number
Element at [2,1]

field [6]


is number
Element at [2,2]

field [7]


is number
Element at [2,3]

field [8]


is number
Element at [2,4]

field [9]


is number
Element at [3,1]

field [10]


is number
Element at [3,2]

field [11]


is number
Element at [3,3]

field [12]


is number
Element at [3,4]

field [13]


is number
Element at [4,1]

field [14]


is number
Element at [4,2]

field [15]


is number
Element at [4,3]

field [16]


is number
Element at [4,4]

alias MatrixName


is (“view”|“projection”|“viewprojection”|“viewinverse”|“projectioninverse”|“viewprojectioninverse”|“billboard”|“shadow”|“camera”|“camprj”|“caminv”|“camprjinv”)
[source]

class Menu


inherits from Callins


[source]
See: Callins

method ActivateMenu ()


Called whenever LuaMenu is on with no game loaded.

[source]


method ActivateGame ()


Called whenever LuaMenu is on with a game loaded.

[source]


method AllowDraw () -> allowDraw


Enables Draw{Genesis,Screen,ScreenPost} callins if true is returned, otherwise they are called once every 30 seconds. Only active when a game isn’t running.

[source]


Returns

allowDraw: boolean

alias ModType


is (0|1|3|4)
[source]

class MoveCtrl


Accessed via Spring.MoveCtrl.

[source]


fn IsEnabled (unitID) -> isEnabled


[source]

Params

unitID: integer

Returns

isEnabled: boolean?

fn Enable (unitID)


[source]

Params

unitID: integer

fn Disable (unitID)


[source]

Params

unitID: integer

fn SetTag (unitID, tag)


[source]

Params

unitID: integer
tag: integer

fn GetTag (tag)


[source]

Params

tag: integer?

fn SetProgressState (unitID, state)


[source]

Params

unitID: integer
state: (0|1|2|“done”|“active”|“failed”)

fn SetExtrapolate (unitID, extrapolate)


[source]

Params

unitID: integer
extrapolate: boolean

fn SetPhysics (unitID, posX, posY, posZ, velX, velY, velZ, rotX, rotY, rotZ)


[source]

Params

unitID: integer
posX: number --Position X component.
posY: number --Position Y component.
posZ: number --Position Z component.
velX: number --Velocity X component.
velY: number --Velocity Y component.
velZ: number --Velocity Z component.
rotX: number --Rotation X component.
rotY: number --Rotation Y component.
rotZ: number --Rotation Z component.

fn SetPosition (unitID, posX, posY, posZ)


[source]

Params

unitID: integer
posX: number --Position X component.
posY: number --Position Y component.
posZ: number --Position Z component.

fn SetVelocity (unitID, velX, velY, velZ)


[source]

Params

unitID: integer
velX: number --Velocity X component.
velY: number --Velocity Y component.
velZ: number --Velocity Z component.

fn SetRelativeVelocity (unitID, relVelX, relVelY, relVelZ)


[source]

Params

unitID: integer
relVelX: number --Relative velocity X component.
relVelY: number --Relative velocity Y component.
relVelZ: number --Relative velocity Z component.

fn SetRotation (unitID, rotX, rotY, rotZ)


[source]

Params

unitID: integer
rotX: number --Rotation X component.
rotY: number --Rotation Y component.
rotZ: number --Rotation Z component.

fn SetRotationOffset ()


[source]

fn SetRotationVelocity (unitID, rotVelX, rotVelY, rotVelZ)


[source]

Params

unitID: integer
rotVelX: number --Rotation velocity X component.
rotVelY: number --Rotation velocity Y component.
rotVelZ: number --Rotation velocity Z component.

fn SetHeading (unitID, heading)


[source]

Params

unitID: integer
heading: Heading

fn SetTrackSlope (unitID, trackSlope)


[source]

Params

unitID: integer
trackSlope: boolean

fn SetTrackGround (unitID, trackGround)


[source]

Params

unitID: integer
trackGround: boolean

fn SetTrackLimits (unitID, trackLimits)


[source]

Params

unitID: integer
trackLimits: boolean

fn SetGroundOffset (unitID, groundOffset)


[source]

Params

unitID: integer
groundOffset: number

fn SetGravity (unitID, gravityFactor)


[source]

Params

unitID: integer
gravityFactor: number

fn SetDrag (unitID, drag)


[source]

Params

unitID: integer
drag: number

fn SetWindFactor (unitID, windFactor)


[source]

Params

unitID: integer
windFactor: number

fn SetLimits (unitID, minX, minY, minZ, maxX, maxY, maxZ)


[source]

Params

unitID: integer
minX: number --Minimum position X component.
minY: number --Minimum position Y component.
minZ: number --Minimum position Z component.
maxX: number --Maximum position X component.
maxY: number --Maximum position Y component.
maxZ: number --Maximum position Z component.

fn SetNoBlocking (unitID, noBlocking)


[source]

Params

unitID: integer
noBlocking: boolean

fn SetCollideStop (unitID, collideStop)


[source]

Params

unitID: integer
collideStop: boolean

fn SetLimitsStop (unitID, limitsStop)


[source]

Params

unitID: integer
limitsStop: boolean

fn SetGunshipMoveTypeData (unitID, moveType) -> numAssignedValues


[source]

Params

unitID: integer
moveType: HoverAirMoveType

Returns

numAssignedValues: number

fn SetGunshipMoveTypeData (unitID, key, value) -> numAssignedValues


[source]

Params

unitID: integer
key: (GenericMoveTypeBooleanKey|“collide”|“dontLand”|“airStrafe”|“useSmoothMesh”|“bankingAllowed”)
value: boolean

Returns

numAssignedValues: number

fn SetGunshipMoveTypeData (unitID, key, value) -> numAssignedValues


[source]

Params

unitID: integer
key: (GenericMoveTypeNumberKey|“wantedHeight”|“accRate”|“decRate”|“turnRate”|“altitudeRate”|“currentBank”|“currentPitch”…)
value: number

Returns

numAssignedValues: number

fn SetAirMoveTypeData (unitID, moveType) -> numAssignedValues


[source]

Params

unitID: integer
moveType: StrafeAirMoveType

Returns

numAssignedValues: number

fn SetAirMoveTypeData (unitID, key, value) -> numAssignedValues


[source]

Params

unitID: integer
key: (GenericMoveTypeBooleanKey|“collide”|“useSmoothMesh”|“loopbackAttack”)
value: boolean

Returns

numAssignedValues: number

fn SetAirMoveTypeData (unitID, key, value) -> numAssignedValues


[source]

Params

unitID: integer
key: (GenericMoveTypeNumberKey|“wantedHeight”|“turnRadius”|“accRate”|“decRate”|“maxAcc”|“maxDec”|“maxBank”…)
value: number

Returns

numAssignedValues: number

fn SetAirMoveTypeData (unitID, key, value) -> numAssignedValues


[source]

Params

unitID: integer
key: (“maneuverBlockTime”)
value: integer

Returns

numAssignedValues: number

fn SetGroundMoveTypeData (unitID, moveType) -> numAssignedValues


[source]

Params

unitID: integer
moveType: GroundMoveType

Returns

numAssignedValues: number

fn SetGroundMoveTypeData (unitID, key, value) -> numAssignedValues


[source]

Params

unitID: integer
key: (GenericMoveTypeBooleanKey|“atGoal”|“atEndOfPath”|“pushResistant”)
value: boolean

Returns

numAssignedValues: number

fn SetGroundMoveTypeData (unitID, key, value) -> numAssignedValues


[source]

Params

unitID: integer
key: (GenericMoveTypeNumberKey|“turnRate”|“turnAccel”|“accRate”|“decRate”|“myGravity”|“maxReverseDist”|“minReverseAngle”…)
value: number

Returns

numAssignedValues: number

fn SetGroundMoveTypeData (unitID, key, value) -> numAssignedValues


[source]

Params

unitID: integer
key: (“minScriptChangeHeading”)
value: integer

Returns

numAssignedValues: number

fn SetMoveDef (unitID, moveDef) -> success


[source]

Params

unitID: integer
moveDef: (integer|string) --Name or path type of the MoveDef.

Returns

success: boolean --`true` if the `MoveDef` was set, `false` if `unitID` or `moveDef` were invalid, or if the unit does not support a `MoveDef`.

class PieceInfo


[source]

field name


is string

field parent


is string

field children


is string[]
names

field empty


is boolean

field min


is (number,number,number)
(x,y,z)

field max


is (number,number,number)
(x,y,z)

field offset


is (number,number,number)
(x,y,z)

class Plane


[source]

field normalVecX


is number

field normalVecY


is number

field normalVecZ


is number

field d


is number

class PlatformVideoMode


[source]

field display


is integer
[source]

field displayName


is string
[source]

field w


is number
[source]

field h


is number
[source]

field bpp


is integer
[source]

field hz


is number
[source]

class ProjectileParams


[source]

field pos


is xyz

field speed


is xyz

field spread


is xyz

field error


is xyz

field end


is xyz

field owner


is integer

field team


is integer

field ttl


is number

field gravity


is number

field tracking


is number

field maxRange


is number

field startAlpha


is number

field endAlpha


is number

field model


is string

field cegTag


is string

enum ProjectileTargetType


[source]

field feature


is integer
ASCII number for the character f

field projectile


is integer
ASCII number for the character p

field unit


is integer
ASCII number for the character u

class RBO


User Data RBO

[source]


field target


is GL

field format


is GL

field xsize


is integer

field ysize


is integer

field valid


is boolean

field samples


is integer
will return globalRendering->msaaLevel for multisampled RBO or 0 otherwise

enum READY_MESSAGE


[source]

field WAITING


is string

field HOST_WAITING


is string
when waiting and currently the host, key is the first key bound to the action forcestart

field CHOOSE_POS


is string
when current player is not ready and is not a spectator

field STARTING


is string
where n is the number of seconds

enum READY_STATE


[source]

field MISSING


is string
when the player hasn’t joined yet (NETMSG_PLAYERNAME wasn’t received)

field READY


is string

field NOT_READY


is string

class ResourceCost


[source]

field metal


is number

field energy


is number

alias ResourceName


is (“metal”|“energy”|“m”|“e”)

alias ResourceUsage


is table<ResourceName,number>

class rgb


Color triple (RGB)

field [1]


is number
Red value.

field [2]


is number
Green value.

field [3]


is number
Blue value.

class rgba


Color quadruple (RGBA)

field [1]


is number
Red value.

field [2]


is number
Green value.

field [3]


is number
Blue value.

field [4]


is number
Alpha value.

class RmlUi.Context


Holds documents and a data model.

The Context class has no constructor; it must be instantiated through the CreateContext() function. It has the following functions and properties:

[source]


method AddEventListener (event, script, element_context, in_capture_phase)


Adds the inline Lua script, script, as an event listener to the context. element_context is an optional Element; if it is not None, then the script will be executed as if it was bound to that element.

[source]


Params

event: string
script: RmlUi.Element
element_context: boolean
in_capture_phase: boolean

method CreateDocument (tag) ->


Creates a new document with the tag name of tag.

[source]


Params

tag: string

Returns

: RmlUi.Document

method LoadDocument (document_path) ->


Attempts to load a document from the RML file found at document_path. If successful, the document will be returned with a reference count of one.

[source]


Params

document_path: string

Returns

: RmlUi.Document

method GetDocument (name)


[source]

Params

name: string

method Render () ->


Renders the context.

[source]


Returns

: boolean

method UnloadAllDocuments ()


Closes all documents currently loaded with the context.

[source]


method UnloadDocument (document)


Unloads a specific document within the context.

[source]


Params

document: RmlUi.Document

method Update () ->


Updates the context.

[source]


Returns

: boolean

method OpenDataModel (name, model, widget) ->


Create a new data model from a base table model and register to the context. The model table is copied. Note that widget does not actually have to be a widget; it can be any table. This table can be accessed in widgets like <button class="mode-button" onclick="widget:SetCamMode()">Set Dolly Mode</button>. Also note that your data model is inaccessible in onx properties.

[source]


Params

name: string
model: T
widget: table

Returns

: RmlUi.SolLuaDataModel

method RemoveDataModel (name)


Removes a data model from the context.

[source]


Params

name: string

method ProcessMouseMove (position) ->


Processes a mouse move event.

[source]


Params

position: RmlUi.Vector2f

Returns

: boolean

method ProcessMouseButtonDown (button, key_modifier_state) ->


Processes a mouse button down event.

[source]


Params

button: RmlUi.MouseButton
key_modifier_state: integer

Returns

: boolean

method ProcessMouseButtonUp (button, key_modifier_state) ->


Processes a mouse button up event.

[source]


Params

button: RmlUi.MouseButton
key_modifier_state: integer

Returns

: boolean

method ProcessMouseWheel (delta, key_modifier_state) ->


Processes a mouse wheel event.

[source]


Params

delta: (RmlUi.Vector2f|number)
key_modifier_state: integer

Returns

: boolean

method ProcessMouseLeave () ->


Processes a mouse leave event.

[source]


Returns

: boolean

method IsMouseInteracting () ->


Returns true if the mouse is currently interacting with the context, false if not.

[source]


Returns

: boolean

method ProcessKeyDown (key, key_modifier_state) ->


Processes a key down event.

[source]


Params

key: RmlUi.key_identifier
key_modifier_state: integer

Returns

: boolean

method ProcessKeyUp (key, key_modifier_state) ->


Processes a key up event.

[source]


Params

key: RmlUi.key_identifier
key_modifier_state: integer

Returns

: boolean

method ProcessTextInput (text) ->


Processes a text input event.

[source]


Params

text: string

Returns

: boolean

method EnableMouseCursor (enable)


Enables or disables the mouse cursor for the context.

[source]


Params

enable: boolean

method ActivateTheme (theme_name, activate)


Activates a theme for the context.

[source]


Params

theme_name: string
activate: boolean

method IsThemeActive (theme_name) ->


Returns true if the theme is active, false if not.

[source]


Params

theme_name: string

Returns

: boolean

method GetElementAtPoint (point, ignore) ->


Returns the element at the point specified by point.

[source]


Params

point: RmlUi.Vector2f
ignore: RmlUi.Element?

Returns

: RmlUi.Element

method PullDocumentToFront (document)


Pulls the document to the front of the context.

[source]


Params

document: RmlUi.Document

method PushDocumentToBack (document)


Pushes the document to the back of the context.

[source]


Params

document: RmlUi.Document

field dimensions


is RmlUi.Vector2i
[source]

field dp_ratio


is number
[source]

field documents


is RmlUi.Document[]
[source]

field focus_element


is RmlUi.Element
[source]

field hover_element


is RmlUi.Element
[source]

field name


is string
[source]

field root_element


is RmlUi.Element
[source]

enum RmlUi.default_action_phase


[source]

field Auto


is integer
[source]

field Target


is integer
[source]

field TargetAndBubble


is integer
[source]

class RmlUi.Document


inherits from RmlUi.Element


Document derives from Element.

Document has no constructor; it must be instantiated through a Context object instead, either by loading an external RML file or creating an empty document. It has the following functions and properties:

[source]


method PullToFront ()


Pulls the document in front of other documents within its context with a similar z-index.

[source]


method PushToBack ()


Pushes the document behind other documents within its context with a similar z-index.

[source]


method Show (modal, focus)


Shows the document.

[source]


Params

modal: RmlUi.RmlModalFlag? --Defaults to Focus
focus: RmlUi.RmlFocusFlag?

method Hide ()


Hides the document.

[source]


method Close ()


Hides and closes the document, destroying its contents.

[source]


method CreateElement (tag_name) ->


Instances an element with a tag of tag_name.

[source]


Params

tag_name: string

Returns

: RmlUi.ElementPtr

method CreateTextNode (text) ->


Instances a text element containing the string text.

[source]


Params

text: string

Returns

: RmlUi.ElementPtr

method ReloadStyleSheet (load)


Reload the active style sheet.

[source]


Params

load: boolean?

method LoadInlineScript (content, source, source_line)


Load scripts as if it were in the script tag.

[source]


Params

content: string
source: string?
source_line: integer?

method LoadExternalScript (source_path)


Load an external script.

[source]


Params

source_path: string

method UpdateDocument ()


Update the Document.

[source]


method AppendToStyleSheet (content)


Append text to style sheet.

[source]


Params

content: string

field title


is string
[source]

field context


is RmlUi.Context
[source]

field url


is string
[source]

field modal


is boolean
[source] Is it modal?

field widget


is table
[source] A table of data that can be accessed in onevent attributes. It doesn’t have to be a widget.

class RmlUi.Element


Represents an element in the RmlUi document tree. This class cannot be constructed directly; use a Document object to instantiate elements. This is the foundational piece of the DOM.

[source]


method AddEventListener (event, listener, in_capture_phase)


Adds an event listener to the element.

[source]


Params

event: string
listener: (function|string)
in_capture_phase: boolean

method AppendChild (element) ->


Appends element as a child to this element.

[source]


Params

element: RmlUi.ElementPtr

Returns

: RmlUi.ElementPtr

method Blur ()


Removes input focus from this element.

[source]


method Click ()


Fakes a click on this element.

[source]


method DispatchEvent (event, parameters, interruptible) ->


Dispatches an event to this element.

[source]


Params

event: string
parameters: table
interruptible: string

Returns

: boolean

method Focus ()


Gives input focus to this element.

[source]


method GetAttribute (name) ->


Returns the value of the attribute named name. If no such attribute exists, the empty string will be returned.

[source]


Params

name: string

Returns

: any

method GetElementById (id) ->


Returns the descendant element with an id of id.

[source]


Params

id: string

Returns

: RmlUi.Element

method GetElementsByTagName (tag_name) ->


Returns a list of all descendant elements with the tag of tag_name.

[source]


Params

tag_name: string

Returns

: RmlUi.ElementPtr[]

method QuerySelector (query) ->


Unsure what this does, but seems powerful?

[source]


Params

query: string

Returns

: RmlUi.ElementPtr

method QuerySelectorAll (selectors)


Unsure what this does, but seems powerful?

[source]


Params

selectors: string

method HasAttribute (name) ->


Returns True if the element has a value for the attribute named name, False if not.

[source]


Params

name: string

Returns

: boolean

method HasChildNodes () ->


Returns True if the element has at least one child node, false if not.

[source]


Returns

: boolean

method InsertBefore (element, adjacent_element) ->


Inserts the element element as a child of this element, directly before adjacent_element in the list of children.

[source]


Params

element: RmlUi.ElementPtr
adjacent_element: RmlUi.Element

Returns

: RmlUi.Element?

method IsClassSet (name) ->


Returns true if the class name is set on the element, false if not.

[source]


Params

name: string

Returns

: boolean

method RemoveAttribute (name)


Removes the attribute named name from the element.

[source]


Params

name: string

method RemoveChild (element) ->


Removes the child element element from this element.

[source]


Params

element: RmlUi.Element

Returns

: boolean

method ReplaceChild (inserted_element, replaced_element) ->


Replaces the child element replaced_element with inserted_element in this element’s list of children. If replaced_element is not a child of this element, inserted_element will be appended onto the list instead.

[source]


Params

inserted_element: RmlUi.ElementPtr
replaced_element: RmlUi.Element

Returns

: boolean

method ScrollIntoView (align_with_top)


Scrolls this element into view if its ancestors have hidden overflow.

[source]


Params

align_with_top: boolean

method SetAttribute (name, value)


Sets the value of the attribute named name to value.

[source]


Params

name: string
value: string

method SetClass (name, value)


Sets (if value is true) or clears (if value is false) the class name on the element.

[source]


Params

name: string
value: boolean

method GetElementsByClassName (class_name) ->


[source]

Params

class_name: string

Returns

: RmlUi.Element[]

method Clone () ->


[source]

Returns

: RmlUi.ElementPtr

method Closest () ->


[source]

Returns

: RmlUi.Element?

method SetPseudoClass (class_name)


[source]

Params

class_name: string

method IsPseudoClassSet (class_name) ->


[source]

Params

class_name: string

Returns

: boolean

method ArePseudoCLassesSet (class_names) ->


[source]

Params

class_names: string[]

Returns

: boolean

method GetActivePseudoCLasses () ->


[source]

Returns

: string[]

method IsPointWithinElement (point) ->


Is a screen-space point within this element?

[source]


Params

point: RmlUi.Vector2i

Returns

: boolean

method ProcessDefaultAction (event)


[source]

Params

event: RmlUi.Event

method GetValue () -> value


Get the value of this element.

[source]


Returns

value: (number|string|"") --Returns number if it has the tag "input", a string if it has the tag "textarea", else an empty string.

method GetChild (index) ->


[source]

Params

index: integer

Returns

: RmlUi.Element?

field class_name


is string
[source] Name of the class.

field id


is string
[source] ID of this element, in the context of <span id="foo">.

field inner_rml


is string
[source] Gets or sets the inner RML (markup) content of the element.

field scroll_left


is integer
[source] Gets or sets the number of pixels that the content of the element is scrolled from the left.

field scroll_top


is integer
[source] Gets or sets the number of pixels that the content of the element is scrolled from the top.

field attributes


is RmlUi.ElementAttributesProxy
[source] Read-only. Proxy for accessing element attributes.

field child_nodes


is RmlUi.ElementChildNodesProxy
[source] Read-only. Proxy for accessing child nodes of the element.

field client_left


is integer
[source] Read-only. The width of the left border of the element in pixels.

field client_height


is integer
[source] Read-only. The inner height of the element in pixels, including padding but not the horizontal scrollbar height, border, or margin.

field client_top


is integer
[source] Read-only. The width of the top border of the element in pixels.

field client_width


is integer
[source] Read-only. The inner width of the element in pixels, including padding but not the vertical scrollbar width, border, or margin.

field first_child


is RmlUi.Element?
[source] Read-only. The first child element, or nil if there are no children.

field last_child


is RmlUi.Element?
[source] Read-only. The last child element, or nil if there are no children.

field next_sibling


is RmlUi.Element?
[source] Read-only. The next sibling element, or nil if there is none.

field offset_height


is integer
[source] Read-only. The height of the element including vertical padding and borders, in pixels.

field offset_left


is integer
[source] Read-only. The distance from the inner left edge of the offset parent, in pixels.

field offset_parent


is RmlUi.Element
[source] Read-only. The closest positioned ancestor element.

field offset_top


is integer
[source] Read-only. The distance from the inner top edge of the offset parent, in pixels.

field offset_width


is integer
[source] Read-only. The width of the element including horizontal padding and borders, in pixels.

field owner_document


is RmlUi.Document
[source] Read-only. The document that owns this element.

field parent_node


is RmlUi.Element?
[source] Read-only. The parent node of this element, or nil if there is none.

field previous_sibling


is RmlUi.Element?
[source] Read-only. The previous sibling element, or nil if there is none.

field scroll_height


is integer
[source] Read-only. The total height of the element’s content, including content not visible on the screen due to overflow.

field scroll_width


is integer
[source] Read-only. The total width of the element’s content, including content not visible on the screen due to overflow.

field style


is RmlUi.ElementStyleProxy
[source] Read-only. Proxy for accessing and modifying the element’s style properties.

field tag_name


is string
[source] Read-only. The tag name of the element.

field address


is string
[source] Read-only. The address of the element in the document tree.

field absolute_left


is integer
[source] Read-only. The absolute left position of the element relative to the document.

field absolute_top


is integer
[source] Read-only. The absolute top position of the element relative to the document.

field baseline


is integer
[source] Read-only. The baseline position of the element.

field line_height


is integer
[source] Read-only. The computed line height of the element.

field visible


is boolean
[source] Read-only. True if the element is visible, false otherwise.

field z_index


is integer
[source] Read-only. The computed z-index of the element.

alias RmlUi.ElementAttributesProxy


is { [string]: (string|number|boolean) }

Contains all the attributes of an element: The stuff in the opening tag i.e. <span class="my-class">

[source]


alias RmlUi.ElementChildNodesProxy


is RmlUi.Element[]

Contains a list of all child elements.

[source]


class RmlUi.ElementForm


inherits from RmlUi.Element


[source]

method Submit (name, value)


[source]

Params

name: string?
value: string?

class RmlUi.ElementFormControl


inherits from RmlUi.Element


[source]

field disabled


is boolean
[source]

field name


is string
[source]

field value


is string
[source]

field submitted


is boolean
[source]

class RmlUi.ElementFormControlInput


inherits from RmlUi.Element RmlUi.ElementFormControl


[source]

field checked


is boolean
[source]

field maxlength


is integer
[source]

field size


is integer
[source]

field max


is integer
[source]

field min


is integer
[source]

field step


is integer
[source]

class RmlUi.ElementFormControlSelect


inherits from RmlUi.Element RmlUi.ElementFormControl


[source]

method Add (element, before)


[source]

Params

element: RmlUi.Element
before: integer?

method Remove (index)


[source]

Params

index: integer

method RemoveAll ()


[source]

class RmlUi.ElementFormControlTextArea


inherits from RmlUi.Element RmlUi.ElementFormControl


[source]

field cols


is integer
[source]

field maxlength


is integer
[source]

field rows


is integer
[source]

field wordwrap


is boolean
[source]

class RmlUi.ElementProgress


inherits from RmlUi.Element


[source]

field value


is number
[source]

field max


is number
[source]

class RmlUi.ElementPtr


Represents an owned element.

This type is mainly used to modify the DOM tree by passing the object into other elements. For example RmlUi.Element:AppendChild(). A current limitation in the Lua plugin is that Element member properties and functions cannot be used directly on this type.

[source]


alias RmlUi.ElementStyleProxy


is { [string]: string }

Gets the rcss styles associated with an element. As far as I can tell, the values will always be a string.

[source]


class RmlUi.ElementTabSet


inherits from RmlUi.Element


[source]

method SetPanel (index, rml)


Sets the contents of a panel to the RML content rml. If index is out-of-bounds, a new panel will be added at the end.

[source]


Params

index: integer
rml: string

method SetTab (index, rml)


Sets the contents of a tab to the RML content rml. If index is out-of-bounds, a new tab will be added at the end.

[source]


Params

index: integer
rml: string

method RemoveTab (index)


[source]

Params

index: integer

field active_tab


is integer
[source]

field num_tabs


is integer
[source]

class RmlUi.ElementText


inherits from RmlUi.Element


[source]

field text


is string
[source]

class RmlUi.Event


An event that happens to an element.

[source]


field current_element


is RmlUi.Element
[source]

field type


is string
[source]

field target_element


is RmlUi.Element
[source] What element it happened to

field parameters


is RmlUi.EventParametersProxy
[source]

field event_phase


is RmlUi.RmlEventPhase
[source]

field interruptible


is boolean
[source]

field propagating


is boolean
[source]

field immediate_propagating


is boolean
[source]

alias RmlUi.EventID


is (0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|integer)
[source]

class RmlUi.EventListener


Event listener interface

[source]


fn OnAttach (element)


[source]

Params

element: RmlUi.Element

fn OnDetach (element)


[source]

Params

element: RmlUi.Element

fn ProcessEvent (event)


[source]

Params

event: RmlUi.Event

class RmlUi.EventParametersProxy


Keyboard and mouse input data associated with an event.

[source]


field button


is RmlUi.EventParametersProxy.MouseButton

field mouse_x


is integer

field mouse_y


is integer

field scroll_lock_key


is RmlUi.EventParametersProxy.TrueFalse

field meta_key


is RmlUi.EventParametersProxy.TrueFalse

field ctrl_key


is RmlUi.EventParametersProxy.TrueFalse

field shift_key


is RmlUi.EventParametersProxy.TrueFalse

field caps_lock_key


is RmlUi.EventParametersProxy.TrueFalse

field alt_key


is RmlUi.EventParametersProxy.TrueFalse

alias RmlUi.EventParametersProxy.MouseButton


is (0|1|2)
[source]

alias RmlUi.EventParametersProxy.TrueFalse


is (0|1)

RmlUi uses 0 and 1 to represent boolean values here.

[source]


enum RmlUi.font_weight


[source]

field Auto


is integer
[source]

field Normal


is integer
[source]

field Bold


is integer
[source]

enum RmlUi.key_identifier


[source]

field 0


is integer

field 1


is integer

field 2


is integer

field 3


is integer

field 4


is integer

field 5


is integer

field 6


is integer

field 7


is integer

field 8


is integer

field 9


is integer

field UNKNOWN


is integer
[source]

field SPACE


is integer
[source]

field A


is integer
[source]

field B


is integer
[source]

field C


is integer
[source]

field D


is integer
[source]

field E


is integer
[source]

field F


is integer
[source]

field G


is integer
[source]

field H


is integer
[source]

field I


is integer
[source]

field J


is integer
[source]

field K


is integer
[source]

field L


is integer
[source]

field M


is integer
[source]

field N


is integer
[source]

field O


is integer
[source]

field P


is integer
[source]

field Q


is integer
[source]

field R


is integer
[source]

field S


is integer
[source]

field T


is integer
[source]

field U


is integer
[source]

field V


is integer
[source]

field W


is integer
[source]

field X


is integer
[source]

field Y


is integer
[source]

field Z


is integer
[source]

field OEM_1


is integer
[source]

field OEM_PLUS


is integer
[source]

field OEM_COMMA


is integer
[source]

field OEM_MINUS


is integer
[source]

field OEM_PERIOD


is integer
[source]

field OEM_2


is integer
[source]

field OEM_3


is integer
[source]

field OEM_4


is integer
[source]

field OEM_5


is integer
[source]

field OEM_6


is integer
[source]

field OEM_7


is integer
[source]

field OEM_8


is integer
[source]

field OEM_102


is integer
[source]

field NUMPAD0


is integer
[source]

field NUMPAD1


is integer
[source]

field NUMPAD2


is integer
[source]

field NUMPAD3


is integer
[source]

field NUMPAD4


is integer
[source]

field NUMPAD5


is integer
[source]

field NUMPAD6


is integer
[source]

field NUMPAD7


is integer
[source]

field NUMPAD8


is integer
[source]

field NUMPAD9


is integer
[source]

field NUMPADENTER


is integer
[source]

field MULTIPLY


is integer
[source]

field ADD


is integer
[source]

field SEPARATOR


is integer
[source]

field SUBTRACT


is integer
[source]

field DECIMAL


is integer
[source]

field DIVIDE


is integer
[source]

field OEM_NEC_EQUAL


is integer
[source]

field BACK


is integer
[source]

field TAB


is integer
[source]

field CLEAR


is integer
[source]

field RETURN


is integer
[source]

field PAUSE


is integer
[source]

field CAPITAL


is integer
[source]

field KANA


is integer
[source]

field HANGUL


is integer
[source]

field JUNJA


is integer
[source]

field FINAL


is integer
[source]

field HANJA


is integer
[source]

field KANJI


is integer
[source]

field ESCAPE


is integer
[source]

field CONVERT


is integer
[source]

field NONCONVERT


is integer
[source]

field ACCEPT


is integer
[source]

field MODECHANGE


is integer
[source]

field PRIOR


is integer
[source]

field NEXT


is integer
[source]

field END


is integer
[source]

field HOME


is integer
[source]

field LEFT


is integer
[source]

field UP


is integer
[source]

field RIGHT


is integer
[source]

field DOWN


is integer
[source]

field SELECT


is integer
[source]

field PRINT


is integer
[source]

field EXECUTE


is integer
[source]

field SNAPSHOT


is integer
[source]

field INSERT


is integer
[source]

field DELETE


is integer
[source]

field HELP


is integer
[source]

field LWIN


is integer
[source]

field RWIN


is integer
[source]

field APPS


is integer
[source]

field POWER


is integer
[source]

field SLEEP


is integer
[source]

field WAKE


is integer
[source]

field F1


is integer
[source]

field F2


is integer
[source]

field F3


is integer
[source]

field F4


is integer
[source]

field F5


is integer
[source]

field F6


is integer
[source]

field F7


is integer
[source]

field F8


is integer
[source]

field F9


is integer
[source]

field F10


is integer
[source]

field F11


is integer
[source]

field F12


is integer
[source]

field F13


is integer
[source]

field F14


is integer
[source]

field F15


is integer
[source]

field F16


is integer
[source]

field F17


is integer
[source]

field F18


is integer
[source]

field F19


is integer
[source]

field F20


is integer
[source]

field F21


is integer
[source]

field F22


is integer
[source]

field F23


is integer
[source]

field F24


is integer
[source]

field NUMLOCK


is integer
[source]

field SCROLL


is integer
[source]

field OEM_FJ_JISHO


is integer
[source]

field OEM_FJ_MASSHOU


is integer
[source]

field OEM_FJ_TOUROKU


is integer
[source]

field OEM_FJ_LOYA


is integer
[source]

field OEM_FJ_ROYA


is integer
[source]

field LSHIFT


is integer
[source]

field RSHIFT


is integer
[source]

field LCONTROL


is integer
[source]

field RCONTROL


is integer
[source]

field LMENU


is integer
[source]

field RMENU


is integer
[source]

field BROWSER_BACK


is integer
[source]

field BROWSER_FORWARD


is integer
[source]

field BROWSER_REFRESH


is integer
[source]

field BROWSER_STOP


is integer
[source]

field BROWSER_SEARCH


is integer
[source]

field BROWSER_FAVORITES


is integer
[source]

field BROWSER_HOME


is integer
[source]

field VOLUME_MUTE


is integer
[source]

field VOLUME_DOWN


is integer
[source]

field VOLUME_UP


is integer
[source]

field MEDIA_NEXT_TRACK


is integer
[source]

field MEDIA_PREV_TRACK


is integer
[source]

field MEDIA_STOP


is integer
[source]

field MEDIA_PLAY_PAUSE


is integer
[source]

field LAUNCH_MAIL


is integer
[source]

field LAUNCH_MEDIA_SELECT


is integer
[source]

field LAUNCH_APP1


is integer
[source]

field LAUNCH_APP2


is integer
[source]

field OEM_AX


is integer
[source]

field ICO_HELP


is integer
[source]

field ICO_00


is integer
[source]

field PROCESSKEY


is integer
[source]

field ICO_CLEAR


is integer
[source]

field ATTN


is integer
[source]

field CRSEL


is integer
[source]

field EXSEL


is integer
[source]

field EREOF


is integer
[source]

field PLAY


is integer
[source]

field ZOOM


is integer
[source]

field PA1


is integer
[source]

field OEM_CLEAR


is integer
[source]

enum RmlUi.key_modifier


[source]

field CTRL


is integer
[source]

field SHIFT


is integer
[source]

field ALT


is integer
[source]

field META


is integer
[source]

field CAPSLOCK


is integer
[source]

field NUMLOCK


is integer
[source]

field SCROLLLOCK


is integer
[source]

alias RmlUi.MouseButton


is (0|1|2)
[source]

enum RmlUi.RmlEventPhase


[source]

field None


is integer
[source]

field Capture


is integer
[source]

field Target


is integer
[source]

field Bubble


is integer
[source]

enum RmlUi.RmlFocusFlag


[source]

field None


is integer
[source]

field Document


is integer
[source]

field Keep


is integer
[source]

field Auto


is integer
[source]

enum RmlUi.RmlModalFlag


[source]

field None


is integer
[source]

field Modal


is integer
[source]

field Keep


is integer
[source]

alias RmlUi.SelectOptionsProxy


is RmlUi.SelectOptionsProxyNode[]
[source]

alias RmlUi.SelectOptionsProxyNode


is { element: RmlUi.Element, value: string }
[source]

class RmlUi.SolLuaDataModel


Handle for a data model.

It is a wrapper around the model table, marked as type T. You can access fields by using normal indexing, but for the moment, the only keys that work are strings. Any index done this way will automatically trigger a rerender. If you need to index any tables or subtables by anything not a string, you will need to use the underlying table, gotten with __GetTable. This will not trigger a rerender. To trigger a rerender manually, use _SetDirty, passing in the name of the top-level entry in your model table that you edited.

[source]


method __SetDirty (property)


Set a table property dirty to trigger a rerender

[source]


Params

property: string

alias RmlUi.StyleProxy


is { [string]: string }
[source]

class RmlUi.Vector2f


Two-dimensional float vector

[source]


fn new (x, y) ->


[source]

Params

x: number
y: number

Returns

: RmlUi.Vector2f

field x


is number
[source]

field y


is number
[source]

field magnitude


is number
[source]

class RmlUi.Vector2i


Two-dimensional integral vector.

[source]


fn new (x, y) ->


[source]

Params

x: integer
y: integer

Returns

: RmlUi.Vector2i

field x


is integer
[source]

field y


is integer
[source]

field magnitude


is number
[source]

class Roster


Contains data about a player

[source]


field name


is string

field playerID


is integer

field teamID


is integer

field allyTeamID


is integer

field spectator


is boolean

field cpuUsage


is number
in order to find the progress, use: cpuUsage&0x1 if it’s PC or BO, cpuUsage& 0xFE to get path res, (cpuUsage»8)*1000 for the progress

field pingTime


is number
if -1, the player is pathfinding

class RulesParams


inherits from table<string,integer>


[source]

class RulesSyncedCallins


inherits from Callins UnsyncedCallins SyncedCallins


Callins that are sent to the synced lua file: LuaRules/main.lua

class RulesUnsyncedCallins


inherits from Callins UnsyncedCallins


Callins that are sent to the unsynced lua file: LuaRules/draw.lua

class SaveImageOptions


[source]

field alpha


is boolean
(Default: false)

field yflip


is boolean
(Default: true)

field grayscale16bit


is boolean
(Default: false)

field readbuffer


is GL
(Default: current read buffer)

class SetUnitHealthAmounts


[source]

field health


is number?
Set the unit’s health.

field capture


is number?
Set the unit’s capture progress.

field paralyze


is number?
Set the unit’s paralyze damage.

field build


is number?
Set the unit’s build progress.

enum SFX


[source]

field SHATTER


is integer

Piece flag for Spring.UnitScript.Explode.

[source]


field EXPLODE


is integer

Piece flag for Spring.UnitScript.Explode.

[source]


field EXPLODE_ON_HIT


is integer

Piece flag for Spring.UnitScript.Explode.

[source]


field FALL


is integer

Piece flag for Spring.UnitScript.Explode.

[source]


field SMOKE


is integer

Piece flag for Spring.UnitScript.Explode.

[source]


field FIRE


is integer

Piece flag for Spring.UnitScript.Explode.

[source]


field NONE


is integer

Piece flag for Spring.UnitScript.Explode.

[source]


field NO_CEG_TRAIL


is integer

Piece flag for Spring.UnitScript.Explode.

[source]


field NO_HEATCLOUD


is integer

Piece flag for Spring.UnitScript.Explode.

[source]


field RECURSIVE


is integer

Piece flag for Spring.UnitScript.Explode.

[source]


field VTOL


is integer

Piece flag for Spring.UnitScript.EmitSfx.

[source]


field WAKE


is integer

Piece flag for Spring.UnitScript.EmitSfx.

[source]


field REVERSE_WAKE


is integer

Piece flag for Spring.UnitScript.EmitSfx.

[source]


field WHITE_SMOKE


is integer

Piece flag for Spring.UnitScript.EmitSfx.

[source]


field BLACK_SMOKE


is integer

Piece flag for Spring.UnitScript.EmitSfx.

[source]


field BUBBLE


is integer

Piece flag for Spring.UnitScript.EmitSfx.

[source]


field CEG


is integer

Piece flag for Spring.UnitScript.EmitSfx.

[source]


field FIRE_WEAPON


is integer

Piece flag for Spring.UnitScript.EmitSfx.

[source]


field DETONATE_WEAPON


is integer

Piece flag for Spring.UnitScript.EmitSfx.

[source]


field GLOBAL


is integer

Piece flag for Spring.UnitScript.EmitSfx.

[source]


class ShaderParams


[source]

field vertex


is string?
The “Vertex” or vertex-shader is your GLSL-Code as string, its written in a C-Dialect. This shader is busy deforming the geometry of a unit but it can not create new polygons. Use it for waves, wobbling surfaces etc.

field tcs


is string?
The “TCS” or Tesselation Control Shader controls how much tessellation a particular patch gets; it also defines the size of a patch, thus allowing it to augment data. It can also filter vertex data taken from the vertex shader. The main purpose of the TCS is to feed the tessellation levels to the Tessellation primitive generator stage, as well as to feed patch data (as its output values) to the Tessellation Evaluation Shader stage.

field tes


is string?
The “TES” or Tesselation Evaluation Shader takes the abstract patch generated by the tessellation primitive generation stage, as well as the actual vertex data for the entire patch, and generates a particular vertex from it. Each TES invocation generates a single vertex. It can also take per-patch data provided by the Tessellation Control Shader.

field geometry


is string?
The “Geometry” or Geometry-shader can create new vertices and vertice-stripes from points.

field fragment


is string?

The “Fragment” or Fragment-shader (sometimes called pixel-Shader) is post processing the already rendered picture (for example drawing stars on the sky).

Remember textures are not always 2 dimensional pictures. They can contain information about the depth, or the third value marks areas and the strength at which these are processed.


field uniform


is UniformParam?

field uniformInt


is UniformParam?

field uniformFloat


is UniformParam?

field uniformMatrix


is UniformParam?

field geoInputType


is integer?
inType

field geoOutputType


is integer?
outType

field geoOutputVerts


is integer?
maxVerts

field definitions


is string?
string of shader #defines"

class SideSpec


Side spec

[source]


See: Spring.GetSideData

field sideName


is string

Returned when getting arrays of side specifications.

Lowercase side name.


field caseName


is string
Original case side name.

field startUnit


is string

alias SoundChannel


is (“general”|“battle”|“sfx”|“unitreply”|“voice”|“userinterface”|“ui”|0|1|2|3)
[source]

class SoundDeviceSpec


Contains data about a sound device.

[source]


field name


is string

alias StorageName


is (“metalStorage”|“energyStorage”|“ms”|“es”)

class StrafeAirMoveType


inherits from GenericMoveType


[source]

field collide


is boolean?

field useSmoothMesh


is boolean?

field loopbackAttack


is boolean?

field maneuverBlockTime


is integer?

field wantedHeight


is number?

field turnRadius


is number?

field accRate


is number?

field decRate


is number?

field maxAcc


is number?
Synonym for accRate.

field maxDec


is number?
Synonym for decRate.

field maxBank


is number?

field maxPitch


is number?

field maxAileron


is number?

field maxElevator


is number?

field maxRudder


is number?

field attackSafetyDistance


is number?

field myGravity


is number?

class SyncedCallins


[source]

method CommandFallback (unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions, cmdTag) -> whether


Called when the unit reaches an unknown command in its queue (i.e. one not handled by the engine).

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer
cmdID: integer
cmdParams: number[]
cmdOptions: CommandOptions
cmdTag: number

Returns

whether: boolean --to remove the command from the queue

method AllowCommand (unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions, cmdTag, synced, fromLua) -> whether


Called when the command is given, before the unit’s queue is altered.

[source]

The queue remains untouched when a command is blocked, whether it would be queued or replace the queue.


Params

unitID: integer
unitDefID: integer
unitTeam: integer
cmdID: integer
cmdParams: number[]
cmdOptions: CommandOptions
cmdTag: number
synced: boolean
fromLua: boolean

Returns

whether: boolean --it should be let into the queue.

method AllowUnitCreation (unitDefID, builderID, builderTeam, x, y, z, facing) -> allow, dropOrder


Called just before unit is created.

[source]


Params

unitDefID: integer
builderID: integer
builderTeam: integer
x: number
y: number
z: number
facing: FacingInteger

Returns

allow: boolean
dropOrder: boolean

method AllowUnitTransfer (unitID, unitDefID, oldTeam, newTeam, capture) -> whether


Called just before a unit is transferred to a different team.

[source]


Params

unitID: integer
unitDefID: integer
oldTeam: integer
newTeam: integer
capture: boolean

Returns

whether: boolean --or not the transfer is permitted.

method AllowUnitBuildStep (builderID, builderTeam, unitID, unitDefID, part) -> whether


Called just before a unit progresses its build percentage.

[source]


Params

builderID: integer
builderTeam: integer
unitID: integer
unitDefID: integer
part: number

Returns

whether: boolean --or not the build makes progress.

method AllowUnitCaptureStep (builderID, builderTeam, unitID, unitDefID, part) -> whether


[source]

Params

builderID: integer
builderTeam: integer
unitID: integer
unitDefID: integer
part: number

Returns

whether: boolean --or not the capture makes progress.

method AllowUnitTransport (transporterID, transporterUnitDefID, transporterTeam, transporteeID, transporteeUnitDefID, transporteeTeam) -> whether


[source]

Params

transporterID: integer
transporterUnitDefID: integer
transporterTeam: integer
transporteeID: integer
transporteeUnitDefID: integer
transporteeTeam: integer

Returns

whether: boolean --or not the transport is allowed

method AllowUnitTransportLoad (transporterID, transporterUnitDefID, transporterTeam, transporteeID, transporteeUnitDefID, transporteeTeam, x, y, z) -> whether


[source]

Params

transporterID: integer
transporterUnitDefID: integer
transporterTeam: integer
transporteeID: integer
transporteeUnitDefID: integer
transporteeTeam: integer
x: number
y: number
z: number

Returns

whether: boolean --or not the transport load is allowed

method AllowUnitTransportUnload (transporterID, transporterUnitDefID, transporterTeam, transporteeID, transporteeUnitDefID, transporteeTeam, x, y, z) -> whether


[source]

Params

transporterID: integer
transporterUnitDefID: integer
transporterTeam: integer
transporteeID: integer
transporteeUnitDefID: integer
transporteeTeam: integer
x: number
y: number
z: number

Returns

whether: boolean --or not the transport unload is allowed

method AllowUnitCloak (unitID, enemyID) -> whether


[source]

Params

unitID: integer
enemyID: integer?

Returns

whether: boolean --unit is allowed to cloak

method AllowUnitCloak (unitID, objectID, weaponNum) -> whether


[source]

Params

unitID: integer
objectID: integer?
weaponNum: number?

Returns

whether: boolean --unit is allowed to decloak

method AllowUnitKamikaze (unitID, targetID) -> whether


[source]

Params

unitID: integer
targetID: integer

Returns

whether: boolean --unit is allowed to selfd

method AllowFeatureCreation (featureDefID, teamID, x, y, z) -> whether


Called just before feature is created.

[source]


Params

featureDefID: integer
teamID: integer
x: number
y: number
z: number

Returns

whether: boolean --or not the creation is permitted

method AllowFeatureBuildStep (builderID, builderTeam, featureID, featureDefID, part) -> whether


Called just before a feature changes its build percentage.

[source]

Note that this is also called for resurrecting features, and for refilling features with resources before resurrection. On reclaim the part values are negative, and on refill and resurrect they are positive. Part is the percentage the feature be built or reclaimed per frame. Eg. for a 30 workertime builder, that’s a build power of 1 per frame. For a 50 buildtime feature reclaimed by this builder, part will be 100/-50(/1) = -2%, or -0.02 numerically.


Params

builderID: integer
builderTeam: integer
featureID: integer
featureDefID: integer
part: number

Returns

whether: boolean --or not the change is permitted

method AllowResourceLevel (teamID, res, level) -> whether


Called when a team sets the sharing level of a resource.

[source]


Params

teamID: integer
res: string
level: number

Returns

whether: boolean --or not the sharing level is permitted

method AllowResourceTransfer (oldTeamID, newTeamID, res, amount) -> whether


Called just before resources are transferred between players.

[source]


Params

oldTeamID: integer
newTeamID: integer
res: string
amount: number

Returns

whether: boolean --or not the transfer is permitted.

method AllowDirectUnitControl (unitID, unitDefID, unitTeam, playerID) -> allow


Determines if this unit can be controlled directly in FPS view.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer
playerID: integer

Returns

allow: boolean

method AllowBuilderHoldFire (unitID, unitDefID, action) -> actionAllowed


Called when a construction unit wants to “use his nano beams”.

[source]


Params

unitID: integer
unitDefID: integer
action: (-1|CMD)

Returns

actionAllowed: boolean

method AllowStartPosition (playerID, teamID, readyState, clampedX, clampedY, clampedZ, rawX, rawY, rawZ) -> allow


Whether a start position should be allowed

[source]

clamped{X,Y,Z} are the coordinates clamped into start-boxes, raw is where player tried to place their marker.

The readyState can be any one of:

0 - player picked a position, 1 - player clicked ready, 2 - player pressed ready OR the game was force-started (player did not click ready, but is now forcibly readied) or 3 - the player failed to load. The default ‘failed to choose’ start-position is the north-west point of their startbox, or (0,0,0) if they do not have a startbox.


Params

playerID: integer
teamID: integer
readyState: number
clampedX: number
clampedY: number
clampedZ: number
rawX: number
rawY: number
rawZ: number

Returns

allow: boolean

method MoveCtrlNotify (unitID, unitDefID, unitTeam, data) -> whether


Enable both Spring.MoveCtrl.SetCollideStop and Spring.MoveCtrl.SetTrackGround to enable this call-in.

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer
data: number --was supposed to indicate the type of notification but currently never has a value other than 1 ("unit hit the ground").

Returns

whether: boolean --or not the unit should remain script-controlled (false) or return to engine controlled movement (true).

method TerraformComplete (unitID, unitDefID, unitTeam, buildUnitID, buildUnitDefID, buildUnitTeam) -> if


Called when pre-building terrain levelling terraforms are completed (c.f. levelGround)

[source]


Params

unitID: integer
unitDefID: integer
unitTeam: integer
buildUnitID: integer
buildUnitDefID: integer
buildUnitTeam: integer

Returns

if: boolean --true the current build order is terminated

method UnitPreDamaged (unitID, unitDefID, unitTeam, damage, paralyzer, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam) -> newDamage, impulseMult


Called before damage is applied to the unit, allows fine control over how much damage and impulse is applied.

[source]

Called after every damage modification (even HitByWeaponId) but before the damage is applied

expects two numbers returned by lua code: 1st is stored under *newDamage if newDamage != NULL 2nd is stored under *impulseMult if impulseMult != NULL


Params

unitID: integer
unitDefID: integer
unitTeam: integer
damage: number
paralyzer: boolean
weaponDefID: integer? --Synced Only
projectileID: integer? --Synced Only
attackerID: integer? --Synced Only
attackerDefID: integer? --Synced Only
attackerTeam: integer? --Synced Only

Returns

newDamage: number
impulseMult: number

method FeaturePreDamaged (featureID, featureDefID, featureTeam, damage, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam) -> newDamage, impulseMult


Called before damage is applied to the feature.

[source]

Allows fine control over how much damage and impulse is applied.


Params

featureID: integer
featureDefID: integer
featureTeam: integer
damage: number
weaponDefID: integer
projectileID: integer
attackerID: integer
attackerDefID: integer
attackerTeam: integer

Returns

newDamage: number
impulseMult: number

method ShieldPreDamaged (projectileID, projectileOwnerID, shieldWeaponNum, shieldCarrierID, bounceProjectile, beamEmitterWeaponNum, beamEmitterUnitID, startX, startY, startZ, hitX, hitY, hitZ) -> if


Called before any engine shield-vs-projectile logic executes.

[source]

If the weapon is a hitscan type (BeamLaser or LightningCanon) then proID is nil and beamEmitterWeaponNum and beamEmitterUnitID are populated instead.


Params

projectileID: integer
projectileOwnerID: integer
shieldWeaponNum: integer
shieldCarrierID: integer
bounceProjectile: boolean
beamEmitterWeaponNum: integer
beamEmitterUnitID: integer
startX: number
startY: number
startZ: number
hitX: number
hitY: number
hitZ: number

Returns

if: boolean --true the gadget handles the collision event and the engine does not remove the projectile

method AllowWeaponTargetCheck (attackerID, attackerWeaponNum, attackerWeaponDefID) -> allowCheck, ignoreCheck


Determines if this weapon can automatically generate targets itself. See also commandFire weaponDef tag.

[source]

Only called for weaponDefIDs registered via Script.SetWatchAllowTarget or Script.SetWatchWeapon.


See: Script.SetWatchAllowTarget Script.SetWatchWeapon

Params

attackerID: integer
attackerWeaponNum: integer
attackerWeaponDefID: integer

Returns

allowCheck: boolean
ignoreCheck: boolean

method AllowWeaponTarget (attackerID, targetID, attackerWeaponNum, attackerWeaponDefID, defPriority) -> allowed, the


Controls blocking of a specific target from being considered during a weapon’s periodic auto-targeting sweep.

[source]

Only called for weaponDefIDs registered via Script.SetWatchAllowTarget or Script.SetWatchWeapon.


See: Script.SetWatchAllowTarget Script.SetWatchWeapon

Params

attackerID: integer
targetID: integer
attackerWeaponNum: integer
attackerWeaponDefID: integer
defPriority: number

Returns

allowed: boolean
the: number --new priority for this target (if you don't want to change it, return defPriority). Lower priority targets are targeted first.

method AllowWeaponInterceptTarget (interceptorUnitID, interceptorWeaponID, targetProjectileID) -> allowed


Controls blocking of a specific intercept target from being considered during an interceptor weapon’s periodic auto-targeting sweep.

[source]

Only called for weaponDefIDs registered via Script.SetWatchAllowTarget or Script.SetWatchWeapon.


See: Script.SetWatchAllowTarget Script.SetWatchWeapon

Params

interceptorUnitID: integer
interceptorWeaponID: integer
targetProjectileID: integer

Returns

allowed: boolean

fn SendToUnsynced (...)


Invoke UnsyncedCallins:RecvFromSynced callin with the given arguments.

[source]


See: UnsyncedCallins:RecvFromSynced

Params

...: (boolean|number|string|table)? --Arguments. Typically the first argument is the name of a function to call. Argument tables will be recursively copied and stripped of unsupported types and metatables.

alias TargetType


is (0|1|2|3)
[source]

class TeamStats


[source]

field time


is number

field frame


is number

field metalUsed


is number

field metalProduced


is number

field metalExcess


is number

field metalReceived


is number

field metalSent


is number

field energyUsed


is number

field energyProduced


is number

field energyExcess


is number

field energyReceived


is number

field energySent


is number

field damageDealt


is number

field damageReceived


is number

field unitsProduced


is integer

field unitsDied


is integer

field unitsReceived


is integer

field unitsSent


is integer

field unitsCaptured


is integer

field unitsOutCaptured


is integer

class TextColorCode


Indicator bytes representing color code operations during font rendering

field Color


is string
Indicates that the following bytes contain color code information

field ColorAndOutline


is string
Indicates that the following bytes contain color code and outline information

field Reset


is string
Indicates reset of the current color

class Texture


[source]

field target


is GL?

field format


is integer?

field min_filter


is GL?

field mag_filter


is GL?

field wrap_s


is GL?

field wrap_t


is GL?

field wrap_r


is GL?

field compareFunc


is number?

field lodBias


is number?

field aniso


is number?

class TextureInfo


[source]

field xsize


is integer

field ysize


is integer

field zsize


is integer

field id


is integer

field target


is GL

class UI


inherits from Callins


[source]
See: Callins

method ConfigureLayout ()


[source]

alias UniformArrayType


is (1|2|3)
[source]

class UniformParam


inherits from { [string]: (T|T[]) }


A table of uniform name to value.

The Uniforms are the values you send along with the shader-program. To use them in the shader-program declare them like this: uniform float frame;

Specify a Lua array to initialize GLSL arrays.

The engine will automatically fill in an appropriately named uniform for team colour if it is declared;

uniform vec4 teamColor;

[source]


class UnitDefDimensions


[source]

field height


is number

field radius


is number

field midx


is number

field minx


is number

field maxx


is number

field midy


is number

field miny


is number

field maxy


is number

field midz


is number

field minz


is number

field maxz


is number

class UnitState


[source]

field firestate


is number

field movestate


is number

field repeat


is boolean

field cloak


is boolean

field active


is boolean

field trajectory


is boolean

field autoland


is boolean?

field autorepairlevel


is number?

field loopbackattack


is boolean?

class UnsyncedCallins


[source]

method RecvFromSynced (...)


Receives data sent via SendToUnsynced callout.

[source]


Params

...: any

method DrawUnit (unitID, drawMode) -> suppressEngineDraw


For custom rendering of units

[source]


Params

unitID: integer
drawMode: number

Returns

suppressEngineDraw: boolean

method DrawFeature (featureID, drawMode) -> suppressEngineDraw


For custom rendering of features

[source]


Params

featureID: integer
drawMode: number

Returns

suppressEngineDraw: boolean

method DrawShield (featureID, weaponID, drawMode) -> suppressEngineDraw


For custom rendering of shields.

[source]


Params

featureID: integer
weaponID: integer
drawMode: number

Returns

suppressEngineDraw: boolean

method DrawProjectile (projectileID, drawMode) -> suppressEngineDraw


For custom rendering of weapon (& other) projectiles

[source]


Params

projectileID: integer
drawMode: number

Returns

suppressEngineDraw: boolean

method DrawMaterial (uuid, drawMode) -> suppressEngineDraw


[source]

Params

uuid: integer
drawMode: number

Returns

suppressEngineDraw: boolean

class VAO


Vertex Array Object

[source]


See: LuaVAO.GetVAO rts/Lua/LuaVAOImpl.cpp

method Delete () ->


[source]

Returns

: nil

method AttachVertexBuffer (vbo) ->


Attaches a VBO to be used as a vertex buffer

[source]


Params

vbo: VBO

Returns

: nil

method AttachInstanceBuffer (vbo) ->


Attaches a VBO to be used as an instance buffer

[source]


Params

vbo: VBO

Returns

: nil

method AttachIndexBuffer (vbo) ->


Attaches a VBO to be used as an index buffer

[source]


Params

vbo: VBO

Returns

: nil

method DrawArrays (glEnum, vertexCount, vertexFirst, instanceCount, instanceFirst) ->


[source]

Params

glEnum: number --primitivesMode
vertexCount: number?
vertexFirst: number?
instanceCount: number?
instanceFirst: number?

Returns

: nil

method DrawElements (glEnum, drawCount, baseIndex, instanceCount, baseVertex, baseInstance) ->


[source]

Params

glEnum: number --primitivesMode
drawCount: number?
baseIndex: number?
instanceCount: number?
baseVertex: number?
baseInstance: number?

Returns

: nil

method AddUnitsToSubmission (unitIDs) -> submittedCount


[source]

Params

unitIDs: (number|number[])

Returns

submittedCount: number

method AddFeaturesToSubmission (featureIDs) -> submittedCount


[source]

Params

featureIDs: (number|number[])

Returns

submittedCount: number

method AddUnitDefsToSubmission (unitDefIDs) -> submittedCount


[source]

Params

unitDefIDs: (number|number[])

Returns

submittedCount: number

method AddFeatureDefsToSubmission (featureDefIDs) -> submittedCount


[source]

Params

featureDefIDs: (number|number[])

Returns

submittedCount: number

method RemoveFromSubmission (index) ->


[source]

Params

index: number

Returns

: nil

method Submit () ->


[source]

Returns

: nil

class VBO


Vertex Buffer Object

[source]


See: LuaVBO.GetVBO rts/Lua/LuaVBOImpl.cpp

method Delete () ->


[source]

Returns

: nil

method Define (size, attribs) ->


Specify the kind of VBO you will be using.

terrainVertexVBO:Define(numPoints, {{ id = 0, name = "pos", size = 2 }})

It is usually an array of vertex/color/uv data, but can also be an array of instance uniforms.

If you want to specify multiple instances of something to render, you will need to create another VBO, which also specifies the number of instances you wish to render, and the size of the data passed to each instance.

If you want say 5 elements, and each element is defined in the layout:

{id = 0, name = "first", size = 1},{id = 1, name = "second", size = 2}}

Then the total size of your VBO will be 5 * (1 + 2).

They will be laid out consecutively: [1,2],[1,2],[1,2],[1,2],[1,2].

This is important for when you call VBO:Upload, you need to make sure you enter your data into the Lua array correctly.

[source]


See: GL.OpenGL_Data_Types VBO:Upload

Params

size: number --The maximum number of elements this VBO can have.
attribs: (number|VBOAttributeDef[])

Returns

: nil

method GetBufferSize () -> elementsCount, bufferSizeInBytes, size


[source]

Returns

elementsCount: number
bufferSizeInBytes: number
size: number

method Upload (vboData, attributeIndex, elemOffset, luaStartIndex, luaFinishIndex) -> indexData, elemOffset, attrID


Uploads data into the VBO.

[source]


See: VBO:Define

Params

vboData: number[] --Array of values to upload into the VBO.
attributeIndex: integer? --(Default: `-1`) If supplied with non-default value then the data from `vboData` will only be used to upload the data to this particular attribute. The whole `vboData` is expected to contain only attributeIndex data. Otherwise all attributes get updated sequentially across attributes and elements.
elemOffset: integer? --(Default: `0`) The index in destination VBO (on GPU) at which storing begins.
luaStartIndex: integer? --(Default: `1`) The index of `vboData` at which copying begins.
luaFinishIndex: integer? --(Default: `#vboData`) The index of `vboData` at which copying ends.

Returns

indexData: number[]
elemOffset: integer
attrID: (integer|(integer,integer…))

method Download (attributeIndex, elementOffset, elementCount, forceGPURead) ->


[source]

Params

attributeIndex: integer? --(Default: `-1`) when supplied with non-default value: only data from specified attribute will be downloaded - otherwise all attributes are downloaded
elementOffset: integer? --(Default: `0`) download data starting from this element
elementCount: number? --number of elements to download
forceGPURead: boolean? --(Default: `false`) force downloading the data from GPU buffer as opposed to using shadow RAM buffer

Returns

: unknown

method ModelsVBO () -> buffer


Binds engine side vertex or index VBO containing models (units, features) data.

[source]

Also fills in VBO definition data as they’re set for engine models (no need to do VBO:Define()).


Returns

buffer: number? --size in bytes

method InstanceDataFromUnitDefIDs (unitDefIDs, attrID, teamIdOpt, elementOffset) -> instanceData, elementOffset, attrID


Fills in attribute data for each specified unitDefID

[source]

The instance data in that attribute will contain the offset to bind position matrix in global matrices SSBO and offset to uniform buffer structure in global per unit/feature uniform SSBO (unused for Unit/FeatureDefs), as well as some auxiliary data ushc as draw flags and team index.

Data Layout:

SInstanceData:
   , traOffset{ matOffset_ }            // updated during the following draw frames
   , uniOffset{ uniOffset_ }            // updated during the following draw frames
   , info{ teamIndex, drawFlags, 0, 0 } // not updated during the following draw frames
   , aux1 { 0u }

Params

unitDefIDs: (number|number[])
attrID: integer
teamIdOpt: integer?
elementOffset: integer?

Returns

instanceData: (number,number,number,number)
elementOffset: integer
attrID: integer

method InstanceDataFromFeatureDefIDs (featureDefIDs, attrID, teamIdOpt, elementOffset) -> instanceData, elementOffset, attrID


Fills in attribute data for each specified featureDefID

[source]

The instance data in that attribute will contain the offset to bind position matrix in global matrices SSBO and offset to uniform buffer structure in global per unit/feature uniform SSBO (unused for Unit/FeatureDefs), as well as some auxiliary data ushc as draw flags and team index.

Data Layout

SInstanceData:
   , traOffset{ matOffset_ }            // updated during the following draw frames
   , uniOffset{ uniOffset_ }            // updated during the following draw frames
   , info{ teamIndex, drawFlags, 0, 0 } // not updated during the following draw frames
   , aux1 { 0u }

Params

featureDefIDs: (number|number[])
attrID: integer
teamIdOpt: integer?
elementOffset: integer?

Returns

instanceData: (number,number,number,number)
elementOffset: integer
attrID: integer

method InstanceDataFromUnitIDs (unitIDs, attrID, teamIdOpt, elementOffset) -> instanceData, elementOffset, attrID


Fills in attribute data for each specified unitID

[source]

The instance data in that attribute will contain the offset to bind position matrix in global matrices SSBO and offset to uniform buffer structure in global per unit/feature uniform SSBO (unused for Unit/FeatureDefs), as well as some auxiliary data ushc as draw flags and team index.

Data Layout

SInstanceData:
   , traOffset{ matOffset_ }            // updated during the following draw frames
   , uniOffset{ uniOffset_ }            // updated during the following draw frames
   , info{ teamIndex, drawFlags, 0, 0 } // not updated during the following draw frames
   , aux1 { 0u }

Params

unitIDs: (number|number[])
attrID: integer
teamIdOpt: integer?
elementOffset: integer?

Returns

instanceData: (number,number,number,number)
elementOffset: integer
attrID: integer

method InstanceDataFromFeatureIDs (featureIDs, attrID, teamIdOpt, elementOffset) -> instanceData, elementOffset, attrID


Fills in attribute data for each specified featureID

[source]

The instance data in that attribute will contain the offset to bind position matrix in global matrices SSBO and offset to uniform buffer structure in global per unit/feature uniform SSBO (unused for Unit/FeatureDefs), as well as some auxiliary data ushc as draw flags and team index.


Params

featureIDs: (number|number[])
attrID: integer
teamIdOpt: integer?
elementOffset: integer?

Returns

instanceData: (number,number,number,number)
elementOffset: integer
attrID: integer

method MatrixDataFromProjectileIDs (projectileIDs, attrID, teamIdOpt, elementOffset) -> matDataVec, elemOffset, attrID


[source]

Params

projectileIDs: (integer|integer[])
attrID: integer
teamIdOpt: integer?
elementOffset: integer?

Returns

matDataVec: number[] --4x4 matrix
elemOffset: integer
attrID: (integer|(integer,integer…))

method BindBufferRange (index, elementOffset, elementCount, target) -> bindingIndex


Bind a range within a buffer object to an indexed buffer target

[source]

Generally mimics https://registry.khronos.org/OpenGL-Refpages/gl4/html/glBindBufferRange.xhtml except offset and size are specified in number of elements / element indices.


Params

index: integer --should be in the range between `5 < index < GL_MAX_UNIFORM_BUFFER_BINDINGS` value (usually 31)
elementOffset: integer?
elementCount: number?
target: number? --glEnum

Returns

bindingIndex: integer --when successful, -1 otherwise

method UnbindBufferRange (index, elementOffset, elementCount, target) -> bindingIndex


[source]

Params

index: integer
elementOffset: integer?
elementCount: number?
target: number? --glEnum

Returns

bindingIndex: number --when successful, -1 otherwise

method DumpDefinition () ->


Logs the definition of the VBO to the console

[source]


Returns

: nil

method CopyTo (destVBO, copySizeInBytes) -> success


Copy the contents of the VBO to another VBO.

[source]

Destination VBO is expected to have sufficient allocation size, otherwise the copying will gracefully fail.


Params

destVBO: VBO
copySizeInBytes: integer

Returns

success: boolean

method GetID () -> bufferID


Gets the OpenGL Buffer ID

[source]


Returns

bufferID: integer

class VBOAttributeDef


[source]

field id


is integer?

field name


is string?

The location in the vertex shader layout e.g.: layout (location = 0) in vec2 aPos. optional attrib, specifies location in the vertex shader. If not specified the implementation will increment the counter starting from 0. There can be maximum 16 attributes (so id of 15 is max).

(Default: attr# where # is id)

The name for this VBO, only used for debugging.


field size


is integer?

field type


is GL?

Defaults to to 4 for VBO. The number of floats that constitute 1 element in this buffer. e.g. for the previous layout (location = 0) in vec2 aPos, it would be size = 2.

(Default: GL.FLOAT) The datatype of this element.

Accepts the following:

  • GL.BYTE
  • GL.UNSIGNED_BYTE
  • GL.SHORT
  • GL.UNSIGNED_SHORT
  • GL.INT
  • GL.UNSIGNED_INT
  • GL.FLOAT

field normalized


is boolean?

(Defaults: false)

It’s possible to submit normals without normalizing them first, normalized will make sure data is normalized.


class VertexData


[source]

field vert


is xyz?

field v


is xyz?
Short for vert.

field norm


is float3?

field n


is float3?
Short for norm.

field texcoord


is float2?

field t


is float2?
Short for texcoord.

field color


is float4?

field c


is float4?
Short for color.

class WaterParams


Water params

[source]


field absorb


is rgb

field baseColor


is rgb

field minColor


is rgb

field surfaceColor


is rgb

field diffuseColor


is rgb

field specularColor


is rgb

field planeColor


is rgb

field texture


is string
file

field foamTexture


is string
file

field normalTexture


is string
file

field damage


is number

field repeatX


is number

field repeatY


is number

field surfaceAlpha


is number

field ambientFactor


is number

field diffuseFactor


is number

field specularFactor


is number

field specularPower


is number

field fresnelMin


is number

field fresnelMax


is number

field fresnelPower


is number

field reflectionDistortion


is number

field blurBase


is number

field blurExponent


is number

field perlinStartFreq


is number

field perlinLacunarity


is number

field perlinAmplitude


is number

field windSpeed


is number

field waveOffsetFactor


is number

field waveLength


is number

field waveFoamDistortion


is number

field waveFoamIntensity


is number

field causticsResolution


is number

field causticsStrength


is number

field numTiles


is integer

field shoreWaves


is boolean

field forceRendering


is boolean

field hasWaterPlane


is boolean

class WeaponDamages


Parameters for damage

[source]


field paralyzeDamageTime


is integer

field impulseFactor


is number

field impulseBoost


is number

field craterMult


is number

field craterBoost


is number

field dynDamageExp


is number

field dynDamageMin


is number

field dynDamageRange


is number

field dynDamageInverted


is number
Set to true if a non-zero value is passed, false is zero is passed.

field craterAreaOfEffect


is number

field damageAreaOfEffect


is number

field edgeEffectiveness


is number

field explosionSpeed


is number

class WeaponState


Parameter for weapon states

[source]


field reloadState


is integer?

field reloadFrame


is integer?
Alias for reloadState.

field reloadTime


is number?

field reaimTime


is integer?

field accuracy


is number?

field sprayAngle


is number?

field range


is number?
If you change the range of a weapon with dynamic damage make sure you use SetUnitWeaponDamages to change dynDamageRange as well.

field projectileSpeed


is number?

field burst


is integer?

field burstRate


is number?

field projectiles


is integer?

field salvoLeft


is integer?

field nextSalvo


is integer?

field aimReady


is number?
Set to true if a non-zero value is passed, false is zero is passed.

field forceAim


is integer?

field avoidFlags


is integer?

field collisionFlags


is integer?

field ttl


is number?
How many seconds the projectile should live

class xy


Cartesian double (XY)

field [1]


is number
x

field [2]


is number
y

class xyz


Cartesian triple (XYZ)

field [1]


is number
x

field [2]


is number
y

field [3]


is number
z

class xyzw


Cartesian quadruple (XYZW)

field [1]


is number
x

field [2]


is number
y

field [3]


is number
z

field [4]


is number
w

class xz


[source]

field x


is number

field y


is number