Lua API Reference
Globals
table Encoding
EncodingLua Encoding API
[source]
fn DecodeBase64 (text) -> decoded
DecodeBase64 (text) -> decodedDecodes 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 decodeReturns
decoded: string --Decoded textfn EncodeBase64 (text, stripPadding) -> encoded
EncodeBase64 (text, stripPadding) -> encodedEncodes a base64 string
[source]
Params
text: string --Text to encodestripPadding: boolean? --Remove padding (`=` characters) at the end when 'true'. Defaults to `true`.Returns
encoded: string --Encoded textfn IsValidBase64 (text) -> valid
IsValidBase64 (text) -> validValidates a base64 string
[source]
Params
text: string --Text to validateReturns
valid: boolean --Whether the text is valid base64fn DecodeBase64Url (text) -> decoded
DecodeBase64Url (text) -> decodedDecodes 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 decodeReturns
decoded: string --Decoded textfn EncodeBase64Url (text) -> encoded
EncodeBase64Url (text) -> encodedEncodes a base64url string
[source]
Params
text: string --Text to encodeReturns
encoded: string --Encoded textfn IsValidBase64Url (text) -> valid
IsValidBase64Url (text) -> validValidates a base64url string
[source]
Params
text: string --Text to validateReturns
valid: boolean --Whether the text is valid base64urltable Engine
EngineEngine specific information.
[source]
field featureSupport
featureSupportis
FeatureSupportTable containing various engine features as keys; use for cross-version compat
field textColorCodes
textColorCodesis
TextColorCodeTable containing keys that represent the color code operations during font rendering
table Game
GameGame specific information
[source]
field springCategories
springCategoriesis
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
armorTypesis
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
textColorCodesis
TextColorCodeTable containing keys that represent the color code operations during font rendering
table gl
glCallouts for OpenGL API
Only setters and getters for OpenGL usage in Recoil, see GL for constants.
[source]
See: GL
fn AddFallbackFont (filePath) -> success
AddFallbackFont (filePath) -> successAdds 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: booleanfn ClearFallbackFonts () ->
ClearFallbackFonts () ->Clears all fallback fonts.
See the note at ‘AddFallbackFont’ about the ‘FontsChanged’ callin, it also applies when calling this method.
[source]
Returns
: nilfn BlitFBO (x0Src, y0Src, x1Src, y1Src, x0Dst, y0Dst, x1Dst, y1Dst, mask, filter)
BlitFBO (x0Src, y0Src, x1Src, y1Src, x0Dst, y0Dst, x1Dst, y1Dst, mask, filter)needs GLAD_GL_EXT_framebuffer_blit
[source]
Params
x0Src: numbery0Src: numberx1Src: numbery1Src: numberx0Dst: numbery0Dst: numberx1Dst: numbery1Dst: numbermask: 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)
BlitFBO (fboSrc, x0Src, y0Src, x1Src, y1Src, fboDst, x0Dst, y0Dst, x1Dst, y1Dst, mask, filter)needs GLAD_GL_EXT_framebuffer_blit
[source]
Params
fboSrc: FBOx0Src: numbery0Src: numberx1Src: numbery1Src: numberfboDst: FBOx0Dst: numbery0Dst: numberx1Dst: numbery1Dst: numbermask: number? --(Default: GL_COLOR_BUFFER_BIT)filter: number? --(Default: GL_NEAREST)fn ClearAttachmentFBO (target, attachment, clearValue0, clearValue1, clearValue2, clearValue3) -> success
ClearAttachmentFBO (target, attachment, clearValue0, clearValue1, clearValue2, clearValue3) -> successneeds 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: booleanfn GetViewRange () -> nearPlaneDist, farPlaneDist, minViewRange, maxViewRange
GetViewRange () -> nearPlaneDist, farPlaneDist, minViewRange, maxViewRange[source]
Returns
nearPlaneDist: numberfarPlaneDist: numberminViewRange: numbermaxViewRange: numberfn BeginText (userDefinedBlending)
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 Text (text, x, y, size, options) ->
Text (text, x, y, size, options) ->[source]
Params
text: stringx: numbery: numbersize: numberoptions: 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
: nilfn GetTextHeight (text) -> height, descender, lines
GetTextHeight (text) -> height, descender, lines[source]
Params
text: stringReturns
height: numberdescender: numberlines: integerfn Unit (unitID, doRawDraw, useLuaMat, noLuaCall, fullModel)
Unit (unitID, doRawDraw, useLuaMat, noLuaCall, fullModel)Draw the unit, applying transform.
[source]
Params
unitID: integerdoRawDraw: boolean? --(Default: `false`)useLuaMat: integer?noLuaCall: boolean? --(Default: `false`) Skip the `DrawUnit` callin.fullModel: boolean? --(Default: `true`)fn UnitRaw (unitID, doRawDraw, useLuaMat, noLuaCall, fullModel)
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: integerdoRawDraw: boolean? --(Default: `false`)useLuaMat: integer?noLuaCall: boolean? --(Default: `true`) Skip the `DrawUnit` callin.fullModel: boolean? --(Default: `true`)fn UnitTextures (unitID, push)
UnitTextures (unitID, push)[source]
Params
unitID: integerpush: boolean --If `true`, push the render state; if `false`, pop it.fn UnitShape (unitDefID, teamID, rawState, toScreen, opaque)
UnitShape (unitDefID, teamID, rawState, toScreen, opaque)[source]
Params
unitDefID: integerteamID: integerrawState: boolean? --(Default: `true`)toScreen: boolean? --(Default: `false`)opaque: boolean? --(Default: `true`) If `true`, draw opaque; if `false`, draw alpha.fn UnitShapeTextures (unitDefID, push)
UnitShapeTextures (unitDefID, push)[source]
Params
unitDefID: integerpush: boolean --If `true`, push the render state; if `false`, pop it.fn Feature (featureID, doRawDraw, useLuaMat, noLuaCall)
Feature (featureID, doRawDraw, useLuaMat, noLuaCall)Draw the feature, applying transform.
[source]
Params
featureID: integerdoRawDraw: boolean? --(Default: `false`)useLuaMat: integer?noLuaCall: boolean? --(Default: `false`) Skip the `DrawFeature` callin.fn FeatureRaw (featureID, doRawDraw, useLuaMat, noLuaCall)
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: integerdoRawDraw: boolean? --(Default: `false`)useLuaMat: integer?noLuaCall: boolean? --(Default: `true`) Skip the `DrawFeature` callin.fn FeatureTextures (featureID, push)
FeatureTextures (featureID, push)[source]
Params
featureID: integerpush: boolean --If `true`, push the render state; if `false`, pop it.fn FeatureShape (featureDefID, teamID, rawState, toScreen, opaque)
FeatureShape (featureDefID, teamID, rawState, toScreen, opaque)[source]
Params
featureDefID: integerteamID: integerrawState: boolean? --(Default: `true`)toScreen: boolean? --(Default: `false`)opaque: boolean? --(Default: `true`) If `true`, draw opaque; if `false`, draw alpha.fn FeatureShapeTextures (featureDefID, push)
FeatureShapeTextures (featureDefID, push)[source]
Params
featureDefID: integerpush: boolean --If `true`, push the render state; if `false`, pop it.fn DrawListAtUnit (unitID, listIndex, useMidPos, scaleX, scaleY, scaleZ, degrees, rotX, rotY, rotZ)
DrawListAtUnit (unitID, listIndex, useMidPos, scaleX, scaleY, scaleZ, degrees, rotX, rotY, rotZ)[source]
Params
unitID: integerlistIndex: integeruseMidPos: 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, ...)
DrawFuncAtUnit (unitID, useMidPos, fun, ...)[source]
Params
unitID: integeruseMidPos: boolean? --(Default: `true`)fun: unknown...: any --Arguments passed to function.fn DrawGroundCircle (posX, posY, posZ, radius, resolution)
DrawGroundCircle (posX, posY, posZ, radius, resolution)[source]
Params
posX: numberposY: numberposZ: numberradius: numberresolution: integerfn DrawGroundCircle (posX, posY, posZ, radius, resolution, slope, gravity, weaponDefID)
DrawGroundCircle (posX, posY, posZ, radius, resolution, slope, gravity, weaponDefID)[source]
Params
posX: numberposY: numberposZ: numberradius: numberresolution: integerslope: numbergravity: numberweaponDefID: integerfn DrawGroundCircle (x0, z0, x1, z1, useNorm, useTxcd)
DrawGroundCircle (x0, z0, x1, z1, useNorm, useTxcd)[source]
Params
x0: numberz0: numberx1: numberz1: numberuseNorm: nil --No longer used.useTxcd: boolean? --(Default: `false`)fn DrawGroundCircle (x0, z0, x1, z1, useNorm, tu0, tv0, tu1, tv1)
DrawGroundCircle (x0, z0, x1, z1, useNorm, tu0, tv0, tu1, tv1)[source]
Params
x0: numberz0: numberx1: numberz1: numberuseNorm: nil --No longer used.tu0: numbertv0: numbertu1: numbertv1: numberfn MultiTexCoord (texNum, s, t, r, q)
MultiTexCoord (texNum, s, t, r, q)[source]
Params
texNum: integers: numbert: number?r: number?q: number?fn Rect (x1, y1, x2, y2, flipSCoords, flipTCoords)
Rect (x1, y1, x2, y2, flipSCoords, flipTCoords)[source]
Params
x1: numbery1: numberx2: numbery2: numberflipSCoords: boolean?flipTCoords: boolean?fn Rect (x1, y1, x2, y2, s1, t1, s2, t2)
Rect (x1, y1, x2, y2, s1, t1, s2, t2)[source]
Params
x1: numbery1: numberx2: numbery2: numbers1: numbert1: numbers2: numbert2: numberfn DispatchCompute (numGroupX, numGroupY, numGroupZ, barriers)
DispatchCompute (numGroupX, numGroupY, numGroupZ, barriers)[source]
Params
numGroupX: integernumGroupY: integernumGroupZ: integerbarriers: integer? --(Default: `4`)fn Color (r, g, b, a)
Color (r, g, b, a)[source]
Params
r: number --Red.g: number --Green.b: number --Blue.a: number? --(Default: `1.0`) Alpha.fn ColorMask (rgba)
ColorMask (rgba)Enable or disable writing of frame buffer color components.
[source]
Params
rgba: booleanfn ColorMask (red, green, blue, alpha)
ColorMask (red, green, blue, alpha)Enable or disable writing of frame buffer color components.
[source]
Params
red: booleangreen: booleanblue: booleanalpha: booleanfn StencilMask (mask)
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)
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)
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)
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)
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)
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 (ignoredString)
LineStipple (ignoredString)[source]
Params
ignoredString: string --The value of this string is ignored, but it still does something.fn PointSprite (enable, enableCoordReplace, coordOrigin)
PointSprite (enable, enableCoordReplace, coordOrigin)[source]
Params
enable: booleanenableCoordReplace: boolean?coordOrigin: boolean? --`true` for upper left, `false` for lower left, otherwise no change.fn PointParameter (atten0, atten1, atten2, sizeMin, sizeMax, sizeFade)
PointParameter (atten0, atten1, atten2, sizeMin, sizeMax, sizeFade)[source]
Params
atten0: numberatten1: numberatten2: numbersizeMin: number?sizeMax: number?sizeFade: number?fn RenderToTexture (texName, fun, ...)
RenderToTexture (texName, fun, ...)[source]
Params
texName: stringfun: unknown...: any --Arguments to the function.fn ActiveTexture (texNum, func, ...)
ActiveTexture (texNum, func, ...)[source]
Params
texNum: integerfunc: function...: any --Arguments to the function.fn BindImageTexture (unit, texID, level, layer, access, format)
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: integertexID: 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
CreateTextureAtlas (xsize, ysize, allocType) -> texName[source]
Params
xsize: integerysize: integerallocType: integer?Returns
texName: stringfn GetAtlasTexture (texName, subAtlasTexName) -> x1, x2, y1, y2
GetAtlasTexture (texName, subAtlasTexName) -> x1, x2, y1, y2[source]
Params
texName: stringsubAtlasTexName: stringReturns
x1: numberx2: numbery1: numbery2: numberfn GetEngineAtlasTextures (atlasName) -> atlasTextures
GetEngineAtlasTextures (atlasName) -> atlasTextures[source]
Params
atlasName: ("$explosions"|"$groundfx")Returns
atlasTextures: table<string,float4> --Table of x1,x2,y1,y2 coordinates by texture name.fn Ortho (left, right, bottom, top, near, far)
Ortho (left, right, bottom, top, near, far)[source]
Params
left: numberright: numberbottom: numbertop: numbernear: numberfar: numberfn Frustum (left, right, bottom, top, near, far)
Frustum (left, right, bottom, top, near, far)[source]
Params
left: numberright: numberbottom: numbertop: numbernear: numberfar: numberfn ClipPlane (plane, equation0, equation1, equation2, equation3)
ClipPlane (plane, equation0, equation1, equation2, equation3)[source]
Params
plane: integerequation0: numberequation1: numberequation2: numberequation3: numberfn LoadMatrix () -> m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44
LoadMatrix () -> m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44[source]
Returns
m11: numberm12: numberm13: numberm14: numberm21: numberm22: numberm23: numberm24: numberm31: numberm32: numberm33: numberm34: numberm41: numberm42: numberm43: numberm44: numberfn MultMatrix (m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44)
MultMatrix (m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44)[source]
Params
m11: numberm12: numberm13: numberm14: numberm21: numberm22: numberm23: numberm24: numberm31: numberm32: numberm33: numberm34: numberm41: numberm42: numberm43: numberm44: numberfn GetMatrixData (index) -> The
GetMatrixData (index) -> The[source]
Params
index: integer --Matrix index in range `[1, 16]`.Returns
The: number --value.fn GetMatrixData (name) -> The
GetMatrixData (name) -> The[source]
Params
name: MatrixName --The matrix name.Returns
The: Matrix4x4 --matrix.fn GetFixedState (param, toStr) -> enabled, values
GetFixedState (param, toStr) -> enabled, values[source]
Params
param: stringtoStr: boolean? --(Default: `false`)Returns
enabled: booleanvalues: any …fn SaveImage (x, y, width, height, filename, options) -> success
SaveImage (x, y, width, height, filename, options) -> success[source]
Params
x: integery: integerwidth: integerheight: integerfilename: stringoptions: SaveImageOptions?Returns
success: boolean?fn GetGlobalTexCoords () -> xstart, ystart, xend, yend
GetGlobalTexCoords () -> xstart, ystart, xend, yend[source]
Returns
xstart: numberystart: numberxend: numberyend: numberfn GetAtmosphere () -> lightDirX, lightDirY, lightDirZ
GetAtmosphere () -> lightDirX, lightDirY, lightDirZ[source]
Returns
lightDirX: numberlightDirY: numberlightDirZ: numberfn GetAtmosphere (param) ->
GetAtmosphere (param) ->[source]
Params
param: (“fogStart”|“fogEnd”|“pos”|“fogColor”|“skyColor”|“sunColor”…)Returns
: any …fn GetSun () -> lightDirX, lightDirY, lightDirZ
GetSun () -> lightDirX, lightDirY, lightDirZ[source]
Returns
lightDirX: numberlightDirY: numberlightDirZ: numberfn GetSun (param, mode) -> data1, data2, data3
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 ObjectLabel (objectTypeIdentifier, objectID, label)
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) ->
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 limitsourceIsThirdParty: boolean --Set the source tag, true for GL_DEBUG_SOURCE_THIRD_PARTY, false for GL_DEBUG_SOURCE_APPLICATION. default falseReturns
: nilfn PopDebugGroup () ->
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
: nilfn GetShaderLog () -> infoLog
GetShaderLog () -> infoLogReturns 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: stringfn CreateShader (shaderParams) -> shaderID
CreateShader (shaderParams) -> shaderIDCreate a shader.
[source]
Params
shaderParams: ShaderParamsReturns
shaderID: integerfn UseShader (shaderID) -> linked
UseShader (shaderID) -> linkedBinds a shader program identified by shaderID. Pass 0 to disable the shader. Returns whether the shader was successfully bound.
[source]
Params
shaderID: integerReturns
linked: booleanfn ActiveShader (shaderID, func, ...)
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: integerfunc: function...: any --Argumentsfn GetActiveUniforms (shaderID) -> activeUniforms
GetActiveUniforms (shaderID) -> activeUniformsQuery the active (actually used) uniforms of a shader and identify their names, types (float, int, uint) and sizes (float, vec4, …).
[source]
Params
shaderID: integerReturns
activeUniforms: ActiveUniform[]fn UniformInt (locationID, int1, int2, int3, int4)
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) --uniformNameint1: integerint2: integer?int3: integer?int4: integer?fn UniformArray (locationID, type, uniforms)
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) --uniformNametype: UniformArrayTypeuniforms: number[] --Array up to 1024 elementsfn UniformMatrix (locationID, matrix)
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) --uniformNamematrix: MatrixName --Name of common matrix.fn UniformMatrix (locationID, matrix)
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) --uniformNamematrix: number[] --A 2x2, 3x3 or 4x4 matrix.fn GetEngineUniformBufferDef (index) -> glslDefinition
GetEngineUniformBufferDef (index) -> glslDefinition[source]
Return the GLSL compliant definition of UniformMatricesBuffer(idx=0) or UniformParamsBuffer(idx=1) structure.
Params
index: numberReturns
glslDefinition: stringfn GetEngineModelUniformDataDef (index) -> glslDefinition
GetEngineModelUniformDataDef (index) -> glslDefinition[source]
Return the GLSL compliant definition of ModelUniformData structure (per Unit/Feature buffer available on GPU)
Params
index: numberReturns
glslDefinition: stringfn GetEngineModelUniformDataSize (index) -> sizeInElements, sizeInBytesOnCPU
GetEngineModelUniformDataSize (index) -> sizeInElements, sizeInBytesOnCPU[source]
Return the current size values of ModelUniformData structure (per Unit/Feature buffer available on GPU)
Params
index: numberReturns
sizeInElements: numbersizeInBytesOnCPU: numberfn SetGeometryShaderParameter (shaderID, key, value) ->
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: integerkey: numbervalue: numberReturns
: nilfn SetTesselationShaderParameter (param, value) ->
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: integervalue: integerReturns
: nilfn CreateRBO (xsize, ysize, data) ->
CreateRBO (xsize, ysize, data) ->[source]
Params
xsize: integerysize: integerdata: CreateRBODataReturns
: RBOfn GetVBO (bufferType, freqUpdated) -> VBO
GetVBO (bufferType, freqUpdated) -> VBOExample:
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 RmlUi
RmlUiGlobal functions for Recoil’s RmlUi implementation.
[source]
fn CreateContext (name) -> nil
CreateContext (name) -> nilCreate a new context.
[source]
Params
name: stringReturns
nil: RmlUi.Context? --if failed.fn LoadFontFace (file_path, fallback, weight) -> success
LoadFontFace (file_path, fallback, weight) -> successLoad a font face.
[source]
Params
file_path: stringfallback: boolean?weight: RmlUi.font_weight?Returns
success: booleanfn GetContext (name) -> nil
GetContext (name) -> nilGet a context by name.
[source]
Params
name: stringReturns
nil: RmlUi.Context? --if failed.fn RegiserEventType (event_type, interruptible, bubbles, default_phase) ->
RegiserEventType (event_type, interruptible, bubbles, default_phase) ->Register a new event type.
[source]
Params
event_type: stringinterruptible: boolean?bubbles: boolean?default_phase: RmlUi.default_action_phase?Returns
: RmlUi.EventIDfn AddTranslationString (key, translation) -> success
AddTranslationString (key, translation) -> successAdd a translation string.
[source]
Params
key: stringtranslation: stringReturns
success: booleanfn SetMouseCursorAlias (rml_name, recoil_name)
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 scriptrecoil_name: string --name used in recoilfn SetDebugContext (context)
SetDebugContext (context)Set which context the debug inspector is meant to inspect.
[source]
Params
context: (string|RmlUi.Context)table Script
Scriptfn IsEngineMinVersion (minMajorVer, minMinorVer, minCommits) -> satisfiesMin
IsEngineMinVersion (minMajorVer, minMinorVer, minCommits) -> satisfiesMin[source]
Params
minMajorVer: integerminMinorVer: 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
GetWatchUnit (unitDefID) -> watchedQuery whether any callins are registered for a unitDefID.
[source]
See: Script.SetWatchUnit
Params
unitDefID: integerReturns
watched: boolean --Watch status.fn GetWatchFeature (featureDefID) -> watched
GetWatchFeature (featureDefID) -> watchedQuery whether any callins are registered for a featureDefID.
[source]
See: Script.SetWatchFeature
Params
featureDefID: integerReturns
watched: boolean --`true` if callins are registered, otherwise `false`.fn GetWatchWeapon (weaponDefID) -> watched
GetWatchWeapon (weaponDefID) -> watchedQuery 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: integerReturns
watched: boolean --True if watch is enabled for any weaponDefID callins.fn GetWatchExplosion (weaponDefID) -> watched
GetWatchExplosion (weaponDefID) -> watchedQuery whether explosion callins are registered for a weaponDefID.
[source]
See: Script.SetWatchExplosion
Params
weaponDefID: integerReturns
watched: boolean --`true` if callins are registered, otherwise `false`.fn GetWatchProjectile (weaponDefID) -> watched
GetWatchProjectile (weaponDefID) -> watchedQuery whether projectile callins are registered for a weaponDefID.
[source]
See: Script.SetWatchProjectile
Params
weaponDefID: integerReturns
watched: boolean --`true` if callins are registered, otherwise `false`.fn GetWatchAllowTarget (weaponDefID) -> watched
GetWatchAllowTarget (weaponDefID) -> watchedQuery whether weapon targeting callins are registered for a weaponDefID.
[source]
See: Script.SetWatchAllowTarget
Params
weaponDefID: integerReturns
watched: boolean --`true` if callins are registered, otherwise `false`.fn SetWatchWeapon (weaponDefID, watch)
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: integerwatch: boolean --Whether to register or deregister.fn SetWatchProjectile (weaponDefID, watch)
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)
SetWatchAllowTarget (weaponDefID, watch)Register or deregister weaponDefID for weapon targeting callins.
[source]
See: Script.GetWatchAllowTarget SyncedCallins:AllowWeaponTargetCheck SyncedCallins:AllowWeaponTarget SyncedCallins:AllowWeaponInterceptTarget
Params
weaponDefID: integerwatch: boolean --Whether to register or deregister.table Spring
Springfn GetMenuName () -> name
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
GetProfilerTimeRecord (profilerName, frameData) -> total, current, max_dt, time_pct, peak_pct, frameData[source]
Params
profilerName: stringframeData: boolean? --(Default: `false`)Returns
total: number --in mscurrent: number --in msmax_dt: numbertime_pct: numberpeak_pct: numberframeData: table<number,number>? --Table where key is the frame index and value is duration.fn GetLuaMemUsage () -> luaHandleAllocedMem, luaHandleNumAllocs, luaGlobalAllocedMem, luaGlobalNumAllocs, luaUnsyncedGlobalAllocedMem, luaUnsyncedGlobalNumAllocs, luaSyncedGlobalAllocedMem, luaSyncedGlobalNumAllocs
GetLuaMemUsage () -> luaHandleAllocedMem, luaHandleNumAllocs, luaGlobalAllocedMem, luaGlobalNumAllocs, luaUnsyncedGlobalAllocedMem, luaUnsyncedGlobalNumAllocs, luaSyncedGlobalAllocedMem, luaSyncedGlobalNumAllocs[source]
Returns
luaHandleAllocedMem: number --in kilobytesluaHandleNumAllocs: number --divided by 1000luaGlobalAllocedMem: number --in kilobytesluaGlobalNumAllocs: number --divided by 1000luaUnsyncedGlobalAllocedMem: number --in kilobytesluaUnsyncedGlobalNumAllocs: number --divided by 1000luaSyncedGlobalAllocedMem: number --in kilobytesluaSyncedGlobalNumAllocs: number --divided by 1000fn GetVidMemUsage () -> usedMem, availableMem
GetVidMemUsage () -> usedMem, availableMem[source]
Returns
usedMem: number --in MBavailableMem: number --in MBfn GetFrameTimer (lastFrameTime) ->
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 startReturns
: integerfn DiffTimers (endTimer, startTimer, returnMs, fromMicroSecs) -> timeAmount
DiffTimers (endTimer, startTimer, returnMs, fromMicroSecs) -> timeAmount[source]
Params
endTimer: integerstartTimer: integerreturnMs: boolean? --(Default: `false`) whether to return `timeAmount` in milliseconds as opposed to secondsfromMicroSecs: boolean? --(Default: `false`) whether timers are in microseconds instead of millisecondsReturns
timeAmount: numberfn GetNumDisplays () -> numDisplays
GetNumDisplays () -> numDisplays[source]
Returns
numDisplays: number --as returned by `SDL_GetNumVideoDisplays`fn GetViewGeometry () -> viewSizeX, viewSizeY, viewPosX, viewPosY
GetViewGeometry () -> viewSizeX, viewSizeY, viewPosX, viewPosYGet main view geometry (map and game rendering)
[source]
Returns
viewSizeX: number --in pxviewSizeY: number --in pxviewPosX: number --offset from leftmost screen left border in pxviewPosY: number --offset from bottommost screen bottom border in pxfn GetDualViewGeometry () -> dualViewSizeX, dualViewSizeY, dualViewPosX, dualViewPosY
GetDualViewGeometry () -> dualViewSizeX, dualViewSizeY, dualViewPosX, dualViewPosYGet dual view geometry (minimap when enabled)
[source]
Returns
dualViewSizeX: number --in pxdualViewSizeY: number --in pxdualViewPosX: number --offset from leftmost screen left border in pxdualViewPosY: number --offset from bottommost screen bottom border in pxfn GetWindowGeometry () -> winSizeX, winSizeY, winPosX, winPosY, windowBorderTop, windowBorderLeft, windowBorderBottom, windowBorderRight
GetWindowGeometry () -> winSizeX, winSizeY, winPosX, winPosY, windowBorderTop, windowBorderLeft, windowBorderBottom, windowBorderRightGet main window geometry
[source]
Returns
winSizeX: number --in pxwinSizeY: number --in pxwinPosX: number --in pxwinPosY: number --in pxwindowBorderTop: number --in pxwindowBorderLeft: number --in pxwindowBorderBottom: number --in pxwindowBorderRight: number --in pxfn GetWindowDisplayMode () -> width, height, bits, refresh
GetWindowDisplayMode () -> width, height, bits, refreshGet main window display mode
[source]
Returns
width: number --in pxheight: number --in pxbits: number --per pixelrefresh: number --rate in Hzfn GetScreenGeometry (displayIndex, queryUsable) -> screenSizeX, screenSizeY, screenPosX, screenPosY, windowBorderTop, windowBorderLeft, windowBorderBottom, windowBorderRight, screenUsableSizeX, screenUsableSizeY, screenUsablePosX, screenUsablePosY
GetScreenGeometry (displayIndex, queryUsable) -> screenSizeX, screenSizeY, screenPosX, screenPosY, windowBorderTop, windowBorderLeft, windowBorderBottom, windowBorderRight, screenUsableSizeX, screenUsableSizeY, screenUsablePosX, screenUsablePosYGet screen geometry
[source]
Params
displayIndex: number? --(Default: `-1`)queryUsable: boolean? --(Default: `false`)Returns
screenSizeX: number --in pxscreenSizeY: number --in pxscreenPosX: number --in pxscreenPosY: number --in pxwindowBorderTop: number --in pxwindowBorderLeft: number --in pxwindowBorderBottom: number --in pxwindowBorderRight: number --in pxscreenUsableSizeX: number? --in pxscreenUsableSizeY: number? --in pxscreenUsablePosX: number? --in pxscreenUsablePosY: number? --in pxfn GetMiniMapGeometry () -> minimapPosX, minimapPosY, minimapSizeX, minimapSizeY, minimized, maximized
GetMiniMapGeometry () -> minimapPosX, minimapPosY, minimapSizeX, minimapSizeY, minimized, maximizedGet minimap geometry
[source]
Returns
minimapPosX: number --in pxminimapPosY: number --in pxminimapSizeX: number --in pxminimapSizeY: number --in pxminimized: booleanmaximized: booleanfn GetMiniMapDualScreen () -> position
GetMiniMapDualScreen () -> position[source]
Returns
position: (“left”|“right”|false) --`"left"` or `"right"` when dual screen is enabled, otherwise `false`.fn GetSelectionBox () -> left, top, right, bottom
GetSelectionBox () -> left, top, right, bottomGet 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 GetFrameTimeOffset () -> offset
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 framefn IsUnitAllied (unitID) -> isAllied
IsUnitAllied (unitID) -> isAllied[source]
Params
unitID: integerReturns
isAllied: boolean? --nil with unitID cannot be parsedfn IsUnitSelected (unitID) -> isSelected
IsUnitSelected (unitID) -> isSelected[source]
Params
unitID: integerReturns
isSelected: boolean? --nil when unitID cannot be parsedfn GetUnitLuaDraw (unitID) -> draw
GetUnitLuaDraw (unitID) -> draw[source]
Params
unitID: integerReturns
draw: boolean? --nil when unitID cannot be parsedfn GetUnitNoDraw (unitID) -> nil
GetUnitNoDraw (unitID) -> nil[source]
Params
unitID: integerReturns
nil: boolean? --when unitID cannot be parsedfn GetUnitEngineDrawMask (unitID) -> nil
GetUnitEngineDrawMask (unitID) -> nil[source]
Params
unitID: integerReturns
nil: boolean? --when unitID cannot be parsedfn GetUnitAlwaysUpdateMatrix (unitID) -> nil
GetUnitAlwaysUpdateMatrix (unitID) -> nil[source]
Params
unitID: integerReturns
nil: boolean? --when unitID cannot be parsedfn GetUnitDrawFlag (unitID) -> nil
GetUnitDrawFlag (unitID) -> nil[source]
Params
unitID: integerReturns
nil: number? --when unitID cannot be parsedfn GetUnitNoMinimap (unitID) -> nil
GetUnitNoMinimap (unitID) -> nil[source]
Params
unitID: integerReturns
nil: boolean? --when unitID cannot be parsedfn GetUnitNoGroup (unitID) -> noGroup
GetUnitNoGroup (unitID) -> noGroupCheck if a unit is not allowed to be added to a group by a player.
[source]
Params
unitID: integerReturns
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
GetUnitNoSelect (unitID) -> noSelect[source]
Params
unitID: integerReturns
noSelect: boolean? --`nil` when `unitID` cannot be parsed.fn GetUnitSelectionVolumeData (unitID) -> scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, volumeType, useContHitTest, getPrimaryAxis, ignoreHits
GetUnitSelectionVolumeData (unitID) -> scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, volumeType, useContHitTest, getPrimaryAxis, ignoreHits[source]
Params
unitID: integerReturns
scaleX: number? --nil when unitID cannot be parsedscaleY: numberscaleZ: numberoffsetX: numberoffsetY: numberoffsetZ: numbervolumeType: numberuseContHitTest: numbergetPrimaryAxis: numberignoreHits: booleanfn GetFeatureLuaDraw (featureID) -> nil
GetFeatureLuaDraw (featureID) -> nil[source]
Params
featureID: integerReturns
nil: boolean? --when featureID cannot be parsedfn GetFeatureNoDraw (featureID) -> nil
GetFeatureNoDraw (featureID) -> nil[source]
Params
featureID: integerReturns
nil: boolean? --when featureID cannot be parsedfn GetFeatureEngineDrawMask (featureID) -> nil
GetFeatureEngineDrawMask (featureID) -> nil[source]
Params
featureID: integerReturns
nil: boolean? --when featureID cannot be parsedfn GetFeatureAlwaysUpdateMatrix (featureID) -> nil
GetFeatureAlwaysUpdateMatrix (featureID) -> nil[source]
Params
featureID: integerReturns
nil: boolean? --when featureID cannot be parsedfn GetFeatureDrawFlag (featureID) -> nil
GetFeatureDrawFlag (featureID) -> nil[source]
Params
featureID: integerReturns
nil: number? --when featureID cannot be parsedfn GetFeatureSelectionVolumeData (featureID) -> scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, volumeType, useContHitTest, getPrimaryAxis, ignoreHits
GetFeatureSelectionVolumeData (featureID) -> scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, volumeType, useContHitTest, getPrimaryAxis, ignoreHits[source]
Params
featureID: integerReturns
scaleX: number? --nil when unitID cannot be parsedscaleY: numberscaleZ: numberoffsetX: numberoffsetY: numberoffsetZ: numbervolumeType: numberuseContHitTest: numbergetPrimaryAxis: numberignoreHits: booleanfn GetUnitTransformMatrix (unitID) -> m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44
GetUnitTransformMatrix (unitID) -> m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44[source]
Params
unitID: integerReturns
m11: number? --nil when unitID cannot be parsedm12: numberm13: numberm14: numberm21: numberm22: numberm23: numberm24: numberm31: numberm32: numberm33: numberm34: numberm41: numberm42: numberm43: numberm44: numberfn GetFeatureTransformMatrix (featureID) -> m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44
GetFeatureTransformMatrix (featureID) -> m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44[source]
Params
featureID: integerReturns
m11: number? --nil when featureID cannot be parsedm12: numberm13: numberm14: numberm21: numberm22: numberm23: numberm24: numberm31: numberm32: numberm33: numberm34: numberm41: numberm42: numberm43: numberm44: numberfn IsUnitInView (unitID) -> inView
IsUnitInView (unitID) -> inView[source]
Params
unitID: integerReturns
inView: boolean? --nil when unitID cannot be parsedfn IsUnitVisible (unitID, radius, checkIcon) -> isVisible
IsUnitVisible (unitID, radius, checkIcon) -> isVisible[source]
Params
unitID: integerradius: number? --unitRadius when not specifiedcheckIcon: booleanReturns
isVisible: boolean? --nil when unitID cannot be parsedfn IsUnitIcon (unitID) -> isUnitIcon
IsUnitIcon (unitID) -> isUnitIcon[source]
Params
unitID: integerReturns
isUnitIcon: boolean? --nil when unitID cannot be parsedfn IsAABBInView (minX, minY, minZ, maxX, maxY, maxZ) -> inView
IsAABBInView (minX, minY, minZ, maxX, maxY, maxZ) -> inView[source]
Params
minX: numberminY: numberminZ: numbermaxX: numbermaxY: numbermaxZ: numberReturns
inView: booleanfn IsSphereInView (posX, posY, posZ, radius) -> inView
IsSphereInView (posX, posY, posZ, radius) -> inView[source]
Params
posX: numberposY: numberposZ: numberradius: number? --(Default: `0`)Returns
inView: booleanfn GetUnitViewPosition (unitID, midPos) -> x, y, z
GetUnitViewPosition (unitID, midPos) -> x, y, z[source]
Params
unitID: integermidPos: boolean? --(Default: `false`)Returns
x: number? --nil when unitID cannot be parsedy: numberz: numberfn GetVisibleUnits (teamID, radius, icons) -> unitIDs
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
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
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 GetRenderUnitsDrawFlagChanged (sendMask) -> ids
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 GetRenderFeaturesDrawFlagChanged (sendMask) -> ids
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 GetUnitsInScreenRectangle (left, top, right, bottom, allegiance) -> unitIDs
GetUnitsInScreenRectangle (left, top, right, bottom, allegiance) -> unitIDsGet units inside a rectangle area on the map
[source]
Params
left: numbertop: numberright: numberbottom: numberallegiance: number? --(Default: `-1`) teamID when > 0, when < 0 one of AllUnits = -1, MyUnits = -2, AllyUnits = -3, EnemyUnits = -4Returns
unitIDs: number[]?fn GetFeaturesInScreenRectangle (left, top, right, bottom) -> featureIDs
GetFeaturesInScreenRectangle (left, top, right, bottom) -> featureIDsGet features inside a rectangle area on the map
[source]
Params
left: numbertop: numberright: numberbottom: numberReturns
featureIDs: number[]?fn GetSpectatingState () -> spectating, spectatingFullView, spectatingFullSelect
GetSpectatingState () -> spectating, spectatingFullView, spectatingFullSelect[source]
Returns
spectating: booleanspectatingFullView: booleanspectatingFullSelect: booleanfn GetSelectedUnitsSorted () -> where, the
GetSelectedUnitsSorted () -> where, theGet selected units aggregated by unitDefID
[source]
Returns
where: table<number,number[]> --keys are unitDefIDs and values are unitIDsthe: integer --number of unitDefIDsfn GetSelectedUnitsCounts () -> unitsCounts, the
GetSelectedUnitsCounts () -> unitsCounts, theGet an aggregate count of selected units per unitDefID
[source]
Returns
unitsCounts: table<number,number> --where keys are unitDefIDs and values are countsthe: integer --number of unitDefIDsfn GetSelectedUnitsCount () -> selectedUnitsCount
GetSelectedUnitsCount () -> selectedUnitsCountReturns the amount of selected units
[source]
Returns
selectedUnitsCount: numberfn GetBoxSelectionByEngine () -> isHandledByEngine
GetBoxSelectionByEngine () -> isHandledByEngineGet 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 HaveAdvShading () -> useAdvShading, groundUseAdvShading
HaveAdvShading () -> useAdvShading, groundUseAdvShading[source]
Returns
useAdvShading: booleangroundUseAdvShading: booleanfn GetWaterMode () -> waterRendererID, waterRendererName
GetWaterMode () -> waterRendererID, waterRendererName[source]
See: rts/Rendering/Env/IWater.h
Returns
waterRendererID: integerwaterRendererName: stringfn GetMapSquareTexture (texSquareX, texSquareY, lodMin, luaTexName, lodMax) -> success
GetMapSquareTexture (texSquareX, texSquareY, lodMin, luaTexName, lodMax) -> success[source]
Params
texSquareX: numbertexSquareY: numberlodMin: numberluaTexName: stringlodMax: number? --(Default: lodMin)Returns
success: boolean?fn GetNanoProjectileParams () -> rotVal, rotVel, rotAcc, rotValRng, rotVelRng, rotAccRng
GetNanoProjectileParams () -> rotVal, rotVel, rotAcc, rotValRng, rotVelRng, rotAccRng[source]
Returns
rotVal: number --in degreesrotVel: number --in degreesrotAcc: number --in degreesrotValRng: number --in degreesrotVelRng: number --in degreesrotAccRng: number --in degreesfn GetCameraNames () -> indexByName
GetCameraNames () -> indexByNameGet available cameras.
[source]
Returns
indexByName: table<string,integer> --Table where where keys are names and values are indices.fn GetCameraState (useTable) -> name, depends
GetCameraState (useTable) -> name, depends[source]
Params
useTable: falseReturns
name: CameraNamedepends: any … --on the current controller mode.fn GetCameraState (useTable) -> cameraState
GetCameraState (useTable) -> cameraState[source]
Params
useTable: true? --(Default: `true`) Return a table instead of multiple values.Returns
cameraState: CameraStatefn GetCameraRotation () -> rotX, rotY, rotZ
GetCameraRotation () -> rotX, rotY, rotZGet 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 WorldToScreenCoords (x, y, z) -> viewPortX, viewPortY, viewPortZ
WorldToScreenCoords (x, y, z) -> viewPortX, viewPortY, viewPortZ[source]
Params
x: numbery: numberz: numberReturns
viewPortX: numberviewPortY: numberviewPortZ: numberfn TraceScreenRay (screenX, screenY, onlyCoords, useMinimap, includeSky, ignoreWater, heightOffset) -> description, unitID, featureID, coords
TraceScreenRay (screenX, screenY, onlyCoords, useMinimap, includeSky, ignoreWater, heightOffset) -> description, unitID, featureID, coordsGet 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 positionincludeSky: boolean? --(Default: `false`)ignoreWater: boolean? --(Default: `false`)heightOffset: number? --(Default: `0`)Returns
description: string? --of traced positionunitID: (number|string|xyz)? --or feature, position triple when onlyCoords=truefeatureID: (number|string)? --or groundcoords: xyz?fn GetPixelDir (x, y) -> dirX, dirY, dirZ
GetPixelDir (x, y) -> dirX, dirY, dirZ[source]
Params
x: numbery: numberReturns
dirX: numberdirY: numberdirZ: numberfn GetTeamColor (teamID) -> r, g, b, a
GetTeamColor (teamID) -> r, g, b, a[source]
Params
teamID: integerReturns
r: number? --factor from 0 to 1g: number? --factor from 0 to 1b: number? --factor from 0 to 1a: number? --factor from 0 to 1fn GetTeamOrigColor (teamID) -> r, g, b, a
GetTeamOrigColor (teamID) -> r, g, b, a[source]
Params
teamID: integerReturns
r: number? --factor from 0 to 1g: number? --factor from 0 to 1b: number? --factor from 0 to 1a: number? --factor from 0 to 1fn GetGameSpeed () -> wantedSpeedFactor, speedFactor, paused
GetGameSpeed () -> wantedSpeedFactor, speedFactor, paused[source]
Returns
wantedSpeedFactor: numberspeedFactor: numberpaused: booleanfn GetGameState (maxLatency) -> doneLoading, isSavedGame, isClientPaused, isSimLagging
GetGameState (maxLatency) -> doneLoading, isSavedGame, isClientPaused, isSimLagging[source]
Params
maxLatency: number? --(Default: `500`) used for `isSimLagging` return parameterReturns
doneLoading: booleanisSavedGame: booleanisClientPaused: booleanisSimLagging: booleanfn GetActiveCommand () -> cmdIndex, cmdID, cmdType, cmdName
GetActiveCommand () -> cmdIndex, cmdID, cmdType, cmdName[source]
Returns
cmdIndex: number?cmdID: integer?cmdType: number?cmdName: string?fn GetDefaultCommand () -> cmdIndex, cmdID, cmdType, cmdName
GetDefaultCommand () -> cmdIndex, cmdID, cmdType, cmdName[source]
Returns
cmdIndex: integer?cmdID: integer?cmdType: integer?cmdName: string?fn GetMouseState () -> x, y, lmbPressed, mmbPressed, rmbPressed, offscreen, mmbScroll
GetMouseState () -> x, y, lmbPressed, mmbPressed, rmbPressed, offscreen, mmbScroll[source]
Returns
x: numbery: numberlmbPressed: number --left mouse button pressedmmbPressed: number --middle mouse button pressedrmbPressed: number --right mouse button pressedoffscreen: booleanmmbScroll: booleanfn GetMouseStartPosition (button) -> x, y, camPosX, camPosY, camPosZ, dirX, dirY, dirZ
GetMouseStartPosition (button) -> x, y, camPosX, camPosY, camPosZ, dirX, dirY, dirZ[source]
Params
button: numberReturns
x: numbery: numbercamPosX: numbercamPosY: numbercamPosZ: numberdirX: numberdirY: numberdirZ: numberfn GetMouseButtonsPressed (button1, ...) -> Pressed
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 GetConsoleBuffer (maxLines) -> buffer
GetConsoleBuffer (maxLines) -> buffer[source]
Params
maxLines: numberReturns
buffer: { priority: integer, text: string }[]fn GetKeyFromScanSymbol (scanSymbol) -> keyName
GetKeyFromScanSymbol (scanSymbol) -> keyName[source]
Params
scanSymbol: stringReturns
keyName: stringfn GetModKeyState () -> alt, ctrl, meta, shift
GetModKeyState () -> alt, ctrl, meta, shift[source]
Returns
alt: booleanctrl: booleanmeta: booleanshift: booleanfn GetPressedKeys () -> where
GetPressedKeys () -> where[source]
Returns
where: table<(number|string),true> --keys are keyCodes or key namesfn GetPressedScans () -> where
GetPressedScans () -> where[source]
Returns
where: table<(number|string),true> --keys are scanCodes or scan namesfn GetKeySymbol (keyCode) -> keyCodeName, keyCodeDefaultName
GetKeySymbol (keyCode) -> keyCodeName, keyCodeDefaultName[source]
Params
keyCode: numberReturns
keyCodeName: stringkeyCodeDefaultName: string --name when there are not aliasesfn GetScanSymbol (scanCode) -> scanCodeName, scanCodeDefaultName
GetScanSymbol (scanCode) -> scanCodeName, scanCodeDefaultName[source]
Params
scanCode: numberReturns
scanCodeName: stringscanCodeDefaultName: string --name when there are not aliasesfn GetKeyBindings (keySet1, keySet2) ->
GetKeyBindings (keySet1, keySet2) ->[source]
Params
keySet1: string? --filters keybindings bound to this keysetkeySet2: string? --OR bound to this keysetReturns
: KeyBinding[]fn GetActionHotKeys (actionName) -> hotkeys
GetActionHotKeys (actionName) -> hotkeys[source]
Params
actionName: stringReturns
hotkeys: string[]?fn GetGroupList () -> where
GetGroupList () -> where[source]
Returns
where: table<number,number>? --keys are groupIDs and values are countsfn GetGroupUnitsSorted (groupID) -> where
GetGroupUnitsSorted (groupID) -> where[source]
Params
groupID: integerReturns
where: table<number,number[]>? --keys are unitDefIDs and values are unitIDsfn GetGroupUnitsCounts (groupID) -> where
GetGroupUnitsCounts (groupID) -> where[source]
Params
groupID: integerReturns
where: table<number,number>? --keys are unitDefIDs and values are countsfn GetPlayerTraffic (playerID, packetID) -> traffic
GetPlayerTraffic (playerID, packetID) -> traffic[source]
Params
playerID: integerpacketID: integer?Returns
traffic: numberfn GetPlayerStatistics (playerID) -> mousePixels, mouseClicks, keyPresses, numCommands, unitCommands
GetPlayerStatistics (playerID) -> mousePixels, mouseClicks, keyPresses, numCommands, unitCommands[source]
Params
playerID: integerReturns
mousePixels: number? --nil when invalid playerIDmouseClicks: numberkeyPresses: numbernumCommands: numberunitCommands: numberfn GetConfigInt (name, default) -> configInt
GetConfigInt (name, default) -> configInt[source]
Params
name: stringdefault: number? --(Default: `0`)Returns
configInt: number?fn GetConfigFloat (name, default) -> configFloat
GetConfigFloat (name, default) -> configFloat[source]
Params
name: stringdefault: number? --(Default: `0`)Returns
configFloat: number?fn GetConfigString (name, default) -> configString
GetConfigString (name, default) -> configString[source]
Params
name: stringdefault: string? --(Default: `""`)Returns
configString: number?fn GetLogSections () -> sections
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 GetGroundDecalMiddlePos (decalID) -> posX, posZ
GetGroundDecalMiddlePos (decalID) -> posX, posZ[source]
Params
decalID: integerReturns
posX: number?posZ: numberfn GetGroundDecalQuadPos (decalID) -> posTL.x, posTL.z, posTR.x, posTR.z, posBR.x, posBR.z, posBL.x, posBL.z
GetGroundDecalQuadPos (decalID) -> posTL.x, posTL.z, posTR.x, posTR.z, posBR.x, posBR.z, posBL.x, posBL.z[source]
Params
decalID: integerReturns
posTL.x: number?posTL.z: numberposTR.x: numberposTR.z: numberposBR.x: numberposBR.z: numberposBL.x: numberposBL.z: numberfn GetGroundDecalSizeAndHeight (decalID) -> sizeX, sizeY, projCubeHeight
GetGroundDecalSizeAndHeight (decalID) -> sizeX, sizeY, projCubeHeight[source]
Params
decalID: integerReturns
sizeX: number?sizeY: numberprojCubeHeight: numberfn GetGroundDecalRotation (decalID) -> rotation
GetGroundDecalRotation (decalID) -> rotation[source]
Params
decalID: integerReturns
rotation: number? --Rotation in radians.fn GetGroundDecalTexture (decalID, isMainTex) -> texture
GetGroundDecalTexture (decalID, isMainTex) -> texture[source]
Params
decalID: integerisMainTex: boolean? --(Default: `true`) If `false`, return the normal/glow map.Returns
texture: string?fn GetGroundDecalTextures (isMainTex, addFilenames) -> textureNames
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 tableReturns
textureNames: string[] --All textures on the atlas and available for use in `SetGroundDecalTexture`.fn SetGroundDecalTextureParams (decalID) -> texWrapDistance, texTraveledDistance
SetGroundDecalTextureParams (decalID) -> texWrapDistance, texTraveledDistance[source]
Params
decalID: integerReturns
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
GetGroundDecalAlpha (decalID) -> alpha, alphaFalloff[source]
Params
decalID: integerReturns
alpha: number? --Between 0 and 1alphaFalloff: number --Between 0 and 1, per secondfn GetGroundDecalNormal (decalID) -> normal.x, normal.y, normal.z
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: integerReturns
normal.x: number?normal.y: numbernormal.z: numberfn GetGroundDecalTint (decalID) -> tintR, tintG, tintB, tintA
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: integerReturns
tintR: number?tintG: numbertintB: numbertintA: numberfn GetGroundDecalMisc (decalID) -> dotElimExp, refHeight, minHeight, maxHeight, forceHeightMode
GetGroundDecalMisc (decalID) -> dotElimExp, refHeight, minHeight, maxHeight, forceHeightMode[source]
Returns less important parameters of a ground decal
Params
decalID: integerReturns
dotElimExp: number?refHeight: numberminHeight: numbermaxHeight: numberforceHeightMode: numberfn GetGroundDecalCreationFrame (decalID) -> creationFrameMin, creationFrameMax
GetGroundDecalCreationFrame (decalID) -> creationFrameMin, creationFrameMax[source]
Min can be not equal to max for “gradient” style decals, e.g. unit tracks
Params
decalID: integerReturns
creationFrameMin: number?creationFrameMax: numberfn GetGroundDecalOwner (decalID) -> value
GetGroundDecalOwner (decalID) -> value[source]
Params
decalID: integerReturns
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
GetGroundDecalType (decalID) -> type[source]
Params
decalID: integerReturns
type: (“explosion”|“plate”|“lua”|“track”|“unknown”)?fn GetSyncedGCInfo (collectGC) -> GC
GetSyncedGCInfo (collectGC) -> GC[source]
Params
collectGC: boolean? --(Default: `false`) collect before returning metricReturns
GC: number? --values are expressed in Kbytes: #bytes/2^10fn SendCommands (command, ...) ->
SendCommands (command, ...) ->[source]
Params
command: string...: string --additional commandsReturns
: nilfn SendPublicChat (message) ->
SendPublicChat (message) ->Sends a chat message to everyone (players and spectators).
[source]
Params
message: stringReturns
: nilfn SendAllyChat (message) ->
SendAllyChat (message) ->Sends a chat message to the sender’s ally team (if a spectator, to other spectators).
[source]
Params
message: stringReturns
: nilfn SendSpectatorChat (message) ->
SendSpectatorChat (message) ->Sends a chat message to spectators. Works even if you’re a player.
[source]
Params
message: stringReturns
: nilfn SendPrivateChat (message, playerID) ->
SendPrivateChat (message, playerID) ->Sends a private chat message to a specific player ID.
[source]
Params
message: stringplayerID: integerReturns
: nilfn SendMessageToSpectators (message) ->
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
: nilfn SendMessageToPlayer (playerID, message) ->
SendMessageToPlayer (playerID, message) ->[source]
Params
playerID: integermessage: stringReturns
: nilfn SendMessageToAllyTeam (allyID, message) ->
SendMessageToAllyTeam (allyID, message) ->[source]
Params
allyID: integermessage: stringReturns
: nilfn LoadSoundDef (soundfile) -> success
LoadSoundDef (soundfile) -> successLoads a SoundDefs file, the format is the same as in gamedata/sounds.lua.
[source]
Params
soundfile: stringReturns
success: booleanfn PlaySoundFile (soundfile, volume, posx, posy, posz, speedx, speedy, speedz, channel) -> playSound
PlaySoundFile (soundfile, volume, posx, posy, posz, speedx, speedy, speedz, channel) -> playSound[source]
Params
soundfile: stringvolume: number? --(Default: 1.0)posx: number?posy: number?posz: number?speedx: number?speedy: number?speedz: number?channel: SoundChannel? --(Default: `0|"general"`)Returns
playSound: booleanfn PlaySoundStream (oggfile, volume, enqueue) -> success
PlaySoundStream (oggfile, volume, enqueue) -> successAllows to play an Ogg Vorbis (.OGG) and mp3 compressed sound file.
[source]
Multiple sound streams may be played at once.
Params
oggfile: stringvolume: number? --(Default: 1.0)enqueue: boolean?Returns
success: booleanfn SetSoundStreamVolume (volume) ->
SetSoundStreamVolume (volume) ->Set volume for SoundStream
[source]
Params
volume: numberReturns
: nilfn AddWorldIcon (cmdID, posX, posY, posZ) ->
AddWorldIcon (cmdID, posX, posY, posZ) ->[source]
Params
cmdID: integerposX: numberposY: numberposZ: numberReturns
: nilfn AddWorldText (text, posX, posY, posZ) ->
AddWorldText (text, posX, posY, posZ) ->[source]
Params
text: stringposX: numberposY: numberposZ: numberReturns
: nilfn AddWorldUnit (unitDefID, posX, posY, posZ, teamID, facing) ->
AddWorldUnit (unitDefID, posX, posY, posZ, teamID, facing) ->[source]
Params
unitDefID: integerposX: numberposY: numberposZ: numberteamID: integerfacing: FacingIntegerReturns
: nilfn DrawUnitCommands (unitIDs, tableOrArray)
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) ->
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
: nilfn SetCameraTarget (x, y, z, transTime) ->
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: numbery: numberz: numbertransTime: number?Returns
: nilfn SetCameraOffset (posX, posY, posZ, tiltX, tiltY, tiltZ) ->
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
: nilfn SetCameraState (cameraState, transitionTime, transitionTimeFactor, transitionTimeExponent) -> set
SetCameraState (cameraState, transitionTime, transitionTimeFactor, transitionTimeExponent) -> setSet 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 nanosecondstransitionTimeFactor: number?transitionTimeExponent: number?Returns
set: boolean --`true` when applied without errors, otherwise `false`.fn RunDollyCamera (runtime) ->
RunDollyCamera (runtime) ->Runs Dolly Camera
[source]
Params
runtime: number --Runtime in milliseconds.Returns
: nilfn PauseDollyCamera (fraction) ->
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 percentReturns
: nilfn SetDollyCameraPosition (x, y, z) ->
SetDollyCameraPosition (x, y, z) ->Sets Dolly Camera Position
[source]
Params
x: numbery: numberz: numberReturns
: nilfn SetDollyCameraCurve (degree, cpoints, knots) ->
SetDollyCameraCurve (degree, cpoints, knots) ->Sets Dolly Camera movement Curve
[source]
Params
degree: numbercpoints: ControlPoint[] --NURBS control point positions.knots: tableReturns
: nilfn SetDollyCameraMode (mode) ->
SetDollyCameraMode (mode) ->Sets Dolly Camera movement mode
[source]
Params
mode: (1|2) --`1` static position, `2` nurbs curveReturns
: nilfn SetDollyCameraRelativeMode (relativeMode) ->
SetDollyCameraRelativeMode (relativeMode) ->Sets Dolly Camera movement curve to world relative or look target relative
[source]
Params
relativeMode: number --`1` world, `2` look targetReturns
: nilfn SetDollyCameraLookCurve (degree, cpoints, knots) ->
SetDollyCameraLookCurve (degree, cpoints, knots) ->Sets Dolly Camera Look Curve
[source]
Params
degree: numbercpoints: ControlPoint[] --NURBS control point positions.knots: tableReturns
: nilfn SetDollyCameraLookPosition (x, y, z) ->
SetDollyCameraLookPosition (x, y, z) ->Sets Dolly Camera Look Position
[source]
Params
x: numbery: numberz: numberReturns
: nilfn SetDollyCameraLookUnit (unitID) ->
SetDollyCameraLookUnit (unitID) ->Sets target unit for Dolly Camera to look towards
[source]
Params
unitID: integer --The unit to look at.Returns
: nilfn SelectUnit (unitID, append) ->
SelectUnit (unitID, append) ->Selects a single unit
[source]
Params
unitID: integer?append: boolean? --(Default: `false`) Append to current selection.Returns
: nilfn DeselectUnitArray (unitIDs) ->
DeselectUnitArray (unitIDs) ->Deselects multiple units.
[source]
Params
unitIDs: integer[] --Table with unit IDs as values.Returns
: nilfn DeselectUnitMap (unitMap) ->
DeselectUnitMap (unitMap) ->Deselects multiple units.
[source]
Params
unitMap: table<integer,any> --Table with unit IDs as keys.Returns
: nilfn SelectUnitArray (unitIDs, append) ->
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 selectionReturns
: nilfn SelectUnitMap (unitMap, append) ->
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 selectionReturns
: nilfn AddMapLight (lightParams) -> lightHandle
AddMapLight (lightParams) -> lightHandle[source]
requires MaxDynamicMapLights > 0
Params
lightParams: LightParamsReturns
lightHandle: integerfn AddModelLight (lightParams) -> lightHandle
AddModelLight (lightParams) -> lightHandle[source]
requires MaxDynamicMapLights > 0
Params
lightParams: LightParamsReturns
lightHandle: numberfn UpdateMapLight (lightHandle, lightParams) -> success
UpdateMapLight (lightHandle, lightParams) -> success[source]
Params
lightHandle: numberlightParams: LightParamsReturns
success: booleanfn UpdateModelLight (lightHandle, lightParams) -> success
UpdateModelLight (lightHandle, lightParams) -> success[source]
Params
lightHandle: numberlightParams: LightParamsReturns
success: booleanfn SetMapLightTrackingState (lightHandle, unitOrProjectileID, enableTracking, unitOrProjectile) -> success
SetMapLightTrackingState (lightHandle, unitOrProjectileID, enableTracking, unitOrProjectile) -> successSet a map-illuminating light to start/stop tracking the position of a moving object (unit or projectile)
[source]
Params
lightHandle: numberunitOrProjectileID: integerenableTracking: booleanunitOrProjectile: booleanReturns
success: booleanfn SetModelLightTrackingState (lightHandle, unitOrProjectileID, enableTracking, unitOrProjectile) -> success
SetModelLightTrackingState (lightHandle, unitOrProjectileID, enableTracking, unitOrProjectile) -> successSet a model-illuminating light to start/stop tracking the position of a moving object (unit or projectile)
[source]
Params
lightHandle: numberunitOrProjectileID: integerenableTracking: booleanunitOrProjectile: booleanReturns
success: booleanfn SetMapShader (standardShaderID, deferredShaderID) ->
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: integerdeferredShaderID: integerReturns
: nilfn SetMapSquareTexture (texSqrX, texSqrY, luaTexName) -> success
SetMapSquareTexture (texSqrX, texSqrY, luaTexName) -> success[source]
Params
texSqrX: numbertexSqrY: numberluaTexName: stringReturns
success: booleanfn SetMapShadingTexture (texType, texName) -> success
SetMapShadingTexture (texType, texName) -> success[source]
Params
texType: stringtexName: stringReturns
success: booleanfn SetUnitEngineDrawMask (unitID, drawMask) ->
SetUnitEngineDrawMask (unitID, drawMask) ->[source]
Params
unitID: integerdrawMask: numberReturns
: nilfn SetUnitAlwaysUpdateMatrix (unitID, alwaysUpdateMatrix) ->
SetUnitAlwaysUpdateMatrix (unitID, alwaysUpdateMatrix) ->[source]
Params
unitID: integeralwaysUpdateMatrix: booleanReturns
: nilfn SetUnitNoMinimap (unitID, unitNoMinimap) ->
SetUnitNoMinimap (unitID, unitNoMinimap) ->[source]
Params
unitID: integerunitNoMinimap: booleanReturns
: nilfn SetUnitNoGroup (unitID, unitNoGroup)
SetUnitNoGroup (unitID, unitNoGroup)[source]
Params
unitID: integerunitNoGroup: boolean --Whether unit can be added to selection groupsfn SetUnitNoSelect (unitID, unitNoSelect) ->
SetUnitNoSelect (unitID, unitNoSelect) ->[source]
Params
unitID: integerunitNoSelect: boolean --whether unit can be selected or notReturns
: nilfn SetUnitLeaveTracks (unitID, unitLeaveTracks) ->
SetUnitLeaveTracks (unitID, unitLeaveTracks) ->[source]
Params
unitID: integerunitLeaveTracks: boolean --whether unit leaves tracks on movementReturns
: nilfn SetUnitSelectionVolumeData (unitID, featureID, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, vType, tType, Axis) ->
SetUnitSelectionVolumeData (unitID, featureID, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, vType, tType, Axis) ->[source]
Params
unitID: integerfeatureID: integerscaleX: numberscaleY: numberscaleZ: numberoffsetX: numberoffsetY: numberoffsetZ: numbervType: numbertType: numberAxis: numberReturns
: nilfn SetFeatureNoDraw (featureID, noDraw) ->
SetFeatureNoDraw (featureID, noDraw) ->[source]
Params
featureID: integernoDraw: booleanReturns
: nilfn SetFeatureEngineDrawMask (featureID, engineDrawMask) ->
SetFeatureEngineDrawMask (featureID, engineDrawMask) ->[source]
Params
featureID: integerengineDrawMask: numberReturns
: nilfn SetFeatureAlwaysUpdateMatrix (featureID, alwaysUpdateMat) ->
SetFeatureAlwaysUpdateMatrix (featureID, alwaysUpdateMat) ->[source]
Params
featureID: integeralwaysUpdateMat: numberReturns
: nilfn SetFeatureFade (featureID, allow) ->
SetFeatureFade (featureID, allow) ->Control whether a feature will fade or not when zoomed out.
[source]
Params
featureID: integerallow: booleanReturns
: nilfn SetFeatureSelectionVolumeData (featureID, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, vType, tType, Axis) ->
SetFeatureSelectionVolumeData (featureID, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, vType, tType, Axis) ->[source]
Params
featureID: integerscaleX: numberscaleY: numberscaleZ: numberoffsetX: numberoffsetY: numberoffsetZ: numbervType: numbertType: numberAxis: numberReturns
: nilfn AddUnitIcon (iconName, texFile, size, dist, radAdjust) -> added
AddUnitIcon (iconName, texFile, size, dist, radAdjust) -> added[source]
Params
iconName: stringtexFile: stringsize: number?dist: number?radAdjust: number?Returns
added: booleanfn UnitIconSetDraw (unitID, drawIcon) ->
UnitIconSetDraw (unitID, drawIcon) ->[source]
Use Spring.SetUnitIconDraw instead.
Params
unitID: integerdrawIcon: booleanReturns
: nilfn SetUnitDefIcon (unitDefID, iconName) ->
SetUnitDefIcon (unitDefID, iconName) ->[source]
Params
unitDefID: integericonName: stringReturns
: nilfn SetUnitDefImage (unitDefID, image) ->
SetUnitDefImage (unitDefID, image) ->[source]
Params
unitDefID: integerimage: string --luaTexture|texFileReturns
: nilfn ExtractModArchiveFile (modfile) -> extracted
ExtractModArchiveFile (modfile) -> extracted[source]
Params
modfile: stringReturns
extracted: booleanfn SetActiveCommand (action, actionExtra) -> commandSet
SetActiveCommand (action, actionExtra) -> commandSet[source]
Params
action: stringactionExtra: string?Returns
commandSet: boolean?fn SetActiveCommand (cmdIndex, button, leftClick, rightClick, alt, ctrl, meta, shift) -> commandSet
SetActiveCommand (cmdIndex, button, leftClick, rightClick, alt, ctrl, meta, shift) -> commandSet[source]
Params
cmdIndex: numberbutton: number? --(Default: `1`)leftClick: boolean?rightClick: boolean?alt: boolean?ctrl: boolean?meta: boolean?shift: boolean?Returns
commandSet: boolean?fn SetDrawSelectionInfo (enable) ->
SetDrawSelectionInfo (enable) ->Disables the “Selected Units x” box in the GUI.
[source]
Params
enable: booleanReturns
: nilfn SetTeamColor (teamID, r, g, b) ->
SetTeamColor (teamID, r, g, b) ->[source]
Params
teamID: integerr: numberg: numberb: numberReturns
: nilfn AssignMouseCursor (cmdName, iconFileName, overwrite, hotSpotTopLeft) -> assigned
AssignMouseCursor (cmdName, iconFileName, overwrite, hotSpotTopLeft) -> assignedChanges/creates the cursor of a single CursorCmd.
[source]
Params
cmdName: stringiconFileName: string --not the full filename, instead it is like this:
Wanted filename: Anims/cursorattack_0.bmp
=> iconFileName: cursorattackoverwrite: boolean? --(Default: `true`)hotSpotTopLeft: boolean? --(Default: `false`)Returns
assigned: boolean?fn ReplaceMouseCursor (oldFileName, newFileName, hotSpotTopLeft) -> assigned
ReplaceMouseCursor (oldFileName, newFileName, hotSpotTopLeft) -> assignedMass replace all occurrences of the cursor in all CursorCmds.
[source]
Params
oldFileName: stringnewFileName: stringhotSpotTopLeft: boolean? --(Default: `false`)Returns
assigned: boolean?fn SetCustomCommandDrawData (cmdID, cmdReference, color, showArea) ->
SetCustomCommandDrawData (cmdID, cmdReference, color, showArea) ->Register your custom cmd so it gets visible in the unit’s cmd queue
[source]
Params
cmdID: integercmdReference: (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
: nilfn SetMouseCursor (cursorName, cursorScale) ->
SetMouseCursor (cursorName, cursorScale) ->[source]
Params
cursorName: stringcursorScale: number? --(Default: `1.0`)Returns
: nilfn SetNanoProjectileParams (rotVal, rotVel, rotAcc, rotValRng, rotVelRng, rotAccRng) ->
SetNanoProjectileParams (rotVal, rotVel, rotAcc, rotValRng, rotVelRng, rotAccRng) ->[source]
Params
rotVal: number? --(Default: `0`) in degreesrotVel: number? --(Default: `0`) in degreesrotAcc: number? --(Default: `0`) in degreesrotValRng: number? --(Default: `0`) in degreesrotVelRng: number? --(Default: `0`) in degreesrotAccRng: number? --(Default: `0`) in degreesReturns
: nilfn SetConfigInt (name, value, useOverlay) ->
SetConfigInt (name, value, useOverlay) ->[source]
Params
name: stringvalue: integeruseOverlay: boolean? --(Default: `false`) If `true`, the value will only be set in memory, and not be restored for the next game.Returns
: nilfn SetConfigFloat (name, value, useOverlay) ->
SetConfigFloat (name, value, useOverlay) ->[source]
Params
name: stringvalue: numberuseOverlay: boolean? --(Default: `false`) If `true`, the value will only be set in memory, and not be restored for the next game.Returns
: nilfn SetConfigString (name, value, useOverlay) ->
SetConfigString (name, value, useOverlay) ->[source]
Params
name: stringvalue: stringuseOverlay: boolean? --(Default: `false`) If `true`, the value will only be set in memory, and not be restored for the next game.Returns
: nilfn SetUnitGroup (unitID, groupID) ->
SetUnitGroup (unitID, groupID) ->[source]
Params
unitID: integergroupID: integer --the group number to be assigned, or -1 for deassignmentReturns
: nilfn GiveOrder (cmdID, params, options, timeout) ->
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
: booleanfn GiveOrderToUnit (unitID, cmdID, params, options, timeout) ->
GiveOrderToUnit (unitID, cmdID, params, options, timeout) ->Give order to specific unit.
[source]
Params
unitID: integercmdID: (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
: booleanfn GiveOrderToUnitMap (unitMap, cmdID, params, options, timeout) -> orderGiven
GiveOrderToUnitMap (unitMap, cmdID, params, options, timeout) -> orderGivenGive 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: booleanfn GiveOrderToUnitArray (unitIDs, cmdID, params, options, timeout) -> ordersGiven
GiveOrderToUnitArray (unitIDs, cmdID, params, options, timeout) -> ordersGivenGive 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
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
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
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 SendLuaUIMsg (message, mode) ->
SendLuaUIMsg (message, mode) ->[source]
Params
message: stringmode: string --"s"/"specs" | "a"/"allies"Returns
: nilfn SetShareLevel (resource, shareLevel) ->
SetShareLevel (resource, shareLevel) ->[source]
Params
resource: string --metal | energyshareLevel: numberReturns
: nilfn ShareResources (teamID, resource, amount) ->
ShareResources (teamID, resource, amount) ->[source]
Params
teamID: integerresource: string --metal | energyamount: numberReturns
: nilfn MarkerAddPoint (x, y, z, text, localOnly) ->
MarkerAddPoint (x, y, z, text, localOnly) ->[source]
Params
x: numbery: numberz: numbertext: string? --(Default: `""`)localOnly: boolean?Returns
: nilfn MarkerAddLine (x1, y1, z1, x2, y2, z2, localOnly, playerId) ->
MarkerAddLine (x1, y1, z1, x2, y2, z2, localOnly, playerId) ->[source]
Params
x1: numbery1: numberz1: numberx2: numbery2: numberz2: numberlocalOnly: boolean? --(Default: `false`)playerId: number?Returns
: nilfn MarkerErasePosition (x, y, z, unused, localOnly, playerId, alwaysErase) ->
MarkerErasePosition (x, y, z, unused, localOnly, playerId, alwaysErase) ->[source]
Issue an erase command for markers on the map.
Params
x: numbery: numberz: numberunused: nil --This argument is ignored.localOnly: boolean? --(Default: `false`) do not issue a network message, erase only for the current playerplayerId: number? --when not specified it uses the issuer playerIdalwaysErase: boolean? --(Default: `false`) erase any marker when `localOnly` and current player is spectating. Allows spectators to erase players markers locallyReturns
: nilfn SetSunDirection (dirX, dirY, dirZ, intensity) ->
SetSunDirection (dirX, dirY, dirZ, intensity) ->[source]
Params
dirX: numberdirY: numberdirZ: numberintensity: number? --(Default: `1.0`)Returns
: nilfn SetMapRenderingParams (params) ->
SetMapRenderingParams (params) ->Allows to change map rendering params at runtime.
[source]
Params
params: MapRenderingParamsReturns
: nilfn ForceTesselationUpdate (normal, shadow) -> updated
ForceTesselationUpdate (normal, shadow) -> updated[source]
Params
normal: boolean? --(Default: `true`)shadow: boolean? --(Default: `false`)Returns
updated: booleanfn SendSkirmishAIMessage (aiTeam, message) -> ai_processed
SendSkirmishAIMessage (aiTeam, message) -> ai_processed[source]
Params
aiTeam: numbermessage: stringReturns
ai_processed: boolean?fn SetLogSectionFilterLevel (sectionName, logLevel) ->
SetLogSectionFilterLevel (sectionName, logLevel) ->[source]
Params
sectionName: stringlogLevel: (string|number)?Returns
: nilfn GarbageCollectCtrl (itersPerBatch, numStepsPerIter, minStepsPerIter, maxStepsPerIter, minLoopRunTime, maxLoopRunTime, baseRunTimeMult, baseMemLoadMult) ->
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
: nilfn SetDrawGroundDeferred (drawGroundDeferred, drawGroundForward) ->
SetDrawGroundDeferred (drawGroundDeferred, drawGroundForward) ->[source]
Params
drawGroundDeferred: booleandrawGroundForward: boolean? --allows disabling of the forward passReturns
: nilfn SetDrawModelsDeferred (drawUnitsDeferred, drawFeaturesDeferred, drawUnitsForward, drawFeaturesForward) ->
SetDrawModelsDeferred (drawUnitsDeferred, drawFeaturesDeferred, drawUnitsForward, drawFeaturesForward) ->[source]
Params
drawUnitsDeferred: booleandrawFeaturesDeferred: booleandrawUnitsForward: boolean? --allows disabling of the respective forward passesdrawFeaturesForward: boolean? --allows disabling of the respective forward passesReturns
: nilfn SetVideoCapturingMode (allowCaptureMode) ->
SetVideoCapturingMode (allowCaptureMode) ->This doesn’t actually record the game in any way, it just regulates the framerate and interpolations.
[source]
Params
allowCaptureMode: booleanReturns
: nilfn SetWaterParams (waterParams) ->
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: WaterParamsReturns
: nilfn PreloadUnitDefModel (unitDefID) ->
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: integerReturns
: nilfn DestroyGroundDecal (decalID) -> delSuccess
DestroyGroundDecal (decalID) -> delSuccess[source]
Params
decalID: integerReturns
delSuccess: booleanfn SetGroundDecalPosAndDims (decalID, midPosX, midPosZ, sizeX, sizeZ, projCubeHeight) -> decalSet
SetGroundDecalPosAndDims (decalID, midPosX, midPosZ, sizeX, sizeZ, projCubeHeight) -> decalSet[source]
Params
decalID: integermidPosX: number? --(Default: currMidPosX)midPosZ: number? --(Default: currMidPosZ)sizeX: number? --(Default: currSizeX)sizeZ: number? --(Default: currSizeZ)projCubeHeight: number? --(Default: calculateProjCubeHeight)Returns
decalSet: booleanfn SetGroundDecalQuadPosAndHeight (decalID, posTL, posTR, posBR, posBL, projCubeHeight) -> decalSet
SetGroundDecalQuadPosAndHeight (decalID, posTL, posTR, posBR, posBL, projCubeHeight) -> decalSet[source]
Use for non-rectangular decals
Params
decalID: integerposTL: xz? --(Default: currPosTL)posTR: xz? --(Default: currPosTR)posBR: xz? --(Default: currPosBR)posBL: xz? --(Default: currPosBL)projCubeHeight: number? --(Default: calculateProjCubeHeight)Returns
decalSet: booleanfn SetGroundDecalRotation (decalID, rot) -> decalSet
SetGroundDecalRotation (decalID, rot) -> decalSet[source]
Params
decalID: integerrot: number? --(Default: random) in radiansReturns
decalSet: booleanfn SetGroundDecalTexture (decalID, textureName, isMainTex) -> decalSet
SetGroundDecalTexture (decalID, textureName, isMainTex) -> decalSet[source]
Params
decalID: integertextureName: 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 mapReturns
decalSet: boolean?fn SetGroundDecalTextureParams (decalID, texWrapDistance, texTraveledDistance) -> decalSet
SetGroundDecalTextureParams (decalID, texWrapDistance, texTraveledDistance) -> decalSet[source]
Params
decalID: integertexWrapDistance: number? --(Default: currTexWrapDistance) if non-zero sets the mode to repeat the texture along the left-right direction of the decal every texWrapFactor elmostexTraveledDistance: 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
SetGroundDecalAlpha (decalID, alpha, alphaFalloff) -> decalSet[source]
Params
decalID: integeralpha: number? --(Default: currAlpha) Between 0 and 1alphaFalloff: number? --(Default: currAlphaFalloff) Between 0 and 1, per secondReturns
decalSet: booleanfn SetGroundDecalNormal (decalID, normalX, normalY, normalZ) -> decalSet
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: integernormalX: number? --(Default: `0`)normalY: number? --(Default: `0`)normalZ: number? --(Default: `0`)Returns
decalSet: booleanfn SetGroundDecalTint (decalID, tintColR, tintColG, tintColB, tintColA) -> decalSet
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: integertintColR: number? --(Default: curTintColR)tintColG: number? --(Default: curTintColG)tintColB: number? --(Default: curTintColB)tintColA: number? --(Default: curTintColA)Returns
decalSet: booleanfn SetGroundDecalMisc (decalID, dotElimExp, refHeight, minHeight, maxHeight, forceHeightMode) -> decalSet
SetGroundDecalMisc (decalID, dotElimExp, refHeight, minHeight, maxHeight, forceHeightMode) -> decalSet[source]
Sets varios secondary parameters of a decal
Params
decalID: integerdotElimExp: number? --(Default: curValue) pow(max(dot(decalProjVector, SurfaceNormal), 0.0), dotElimExp), used to reduce decal artifacts on surfaces non-collinear with the projection vectorrefHeight: 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 positionReturns
decalSet: booleanfn SetGroundDecalCreationFrame (decalID, creationFrameMin, creationFrameMax) -> decalSet
SetGroundDecalCreationFrame (decalID, creationFrameMin, creationFrameMax) -> decalSet[source]
Use separate min and max for “gradient” style decals such as tank tracks
Params
decalID: integercreationFrameMin: number? --(Default: currCreationFrameMin)creationFrameMax: number? --(Default: currCreationFrameMax)Returns
decalSet: booleanfn SDLSetTextInputRect (x, y, width, height) ->
SDLSetTextInputRect (x, y, width, height) ->[source]
Params
x: numbery: numberwidth: numberheight: numberReturns
: nilfn SetWindowGeometry (displayIndex, winRelPosX, winRelPosY, winSizeX, winSizeY, fullScreen, borderless) ->
SetWindowGeometry (displayIndex, winRelPosX, winRelPosY, winSizeX, winSizeY, fullScreen, borderless) ->[source]
Params
displayIndex: numberwinRelPosX: numberwinRelPosY: numberwinSizeX: numberwinSizeY: numberfullScreen: booleanborderless: booleanReturns
: nilfn Reload (startScript) ->
Reload (startScript) ->[source]
Params
startScript: string --the CONTENT of the script.txt spring should use to start.Returns
: nilfn Restart (commandline_args, startScript) ->
Restart (commandline_args, startScript) ->[source]
If this call returns, something went wrong
Params
commandline_args: string --commandline arguments passed to spring executable.startScript: stringReturns
: nilfn Start (commandline_args, startScript) ->
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
: nilfn SetWMIcon (iconFileName) ->
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: stringReturns
: nilfn SetWMCaption (title, titleShort) ->
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
: nilfn ClearWatchDogTimer (threadName) ->
ClearWatchDogTimer (threadName) ->[source]
Params
threadName: string? --(Default: main)Returns
: nilfn Yield () -> when
Yield () -> whenRelinquish 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
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
GetMetalAmount (x, z) -> amountReturns 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: numberfn SetMetalAmount (x, z, metalAmount) ->
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
: nilfn GetMetalExtraction (x, z) -> extraction
GetMetalExtraction (x, z) -> extraction[source]
Params
x: integer --X coordinate in worldspace / `Game.metalMapSquareSize`.z: integer --Z coordinate in worldspace / `Game.metalMapSquareSize`.Returns
extraction: numberfn SetAlly (firstAllyTeamID, secondAllyTeamID, ally) ->
SetAlly (firstAllyTeamID, secondAllyTeamID, ally) ->Changes the value of the (one-sided) alliance between: firstAllyTeamID -> secondAllyTeamID.
[source]
Params
firstAllyTeamID: integersecondAllyTeamID: integerally: booleanReturns
: nilfn SetAllyTeamStartBox (allyTeamID, xMin, zMin, xMax, zMax) ->
SetAllyTeamStartBox (allyTeamID, xMin, zMin, xMax, zMax) ->Changes the start box position of an allyTeam.
[source]
Params
allyTeamID: integerxMin: 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
: nilfn AssignPlayerToTeam (playerID, teamID) ->
AssignPlayerToTeam (playerID, teamID) ->Assigns a player to a team.
[source]
Params
playerID: integerteamID: integerReturns
: nilfn SetGlobalLos (allyTeamID, globallos) ->
SetGlobalLos (allyTeamID, globallos) ->Changes access to global line of sight for a team and its allies.
[source]
Params
allyTeamID: integergloballos: booleanReturns
: nilfn KillTeam (teamID) ->
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: integerReturns
: nilfn GameOver (winningAllyTeamIDs) -> Number
GameOver (winningAllyTeamIDs) -> NumberDeclare 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 SetWind (minStrength, maxStrength) ->
SetWind (minStrength, maxStrength) ->Set wind strength
[source]
Params
minStrength: numbermaxStrength: numberReturns
: nilfn AddTeamResource (teamID, type, amount) ->
AddTeamResource (teamID, type, amount) ->Adds metal or energy resources to the specified team.
[source]
Params
teamID: integertype: ResourceNameamount: numberReturns
: nilfn UseTeamResource (teamID, type, amount) -> hadEnough
UseTeamResource (teamID, type, amount) -> hadEnoughConsumes metal or energy resources of the specified team.
[source]
Params
teamID: integertype: ResourceName --Resource type.amount: number --Amount of resource to use.Returns
hadEnough: booleanfn UseTeamResource (teamID, amount) -> hadEnough
UseTeamResource (teamID, amount) -> hadEnoughConsumes metal and/or energy resources of the specified team.
[source]
Params
teamID: integeramount: ResourceUsageReturns
hadEnough: booleanfn SetTeamResource (teamID, resource, amount) ->
SetTeamResource (teamID, resource, amount) ->[source]
Params
teamID: integerresource: (ResourceName|StorageName)amount: numberReturns
: nilfn SetTeamShareLevel (teamID, type, amount) ->
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: integertype: ResourceNameamount: numberReturns
: nilfn ShareTeamResource (teamID_src, teamID_recv, type, amount) ->
ShareTeamResource (teamID_src, teamID_recv, type, amount) ->Transfers resources between two teams.
[source]
Params
teamID_src: integerteamID_recv: integertype: ResourceNameamount: numberReturns
: nilfn CallCOBScript (unitID, funcName, retArgs, ...) ->
CallCOBScript (unitID, funcName, retArgs, ...) ->[source]
Params
unitID: integerfuncName: (integer|string)? --Function ID or name.retArgs: integer --Number of values to return....: any --ArgumentsReturns
: number …fn GetCOBScriptID (unitID, funcName) -> funcID
GetCOBScriptID (unitID, funcName) -> funcID[source]
Params
unitID: integerfuncName: stringReturns
funcID: integer?fn CreateUnit (unitDef, posX, posY, posZ, facing, teamID, build, flattenGround, unitID, builderID) -> unitID
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: numberposY: numberposZ: numberfacing: FacingteamID: integerbuild: 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) ->
DestroyUnit (unitID, selfd, reclaimed, attackerID, cleanupImmediately) ->[source]
See: Spring.CreateUnit
Params
unitID: integerselfd: 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
: nilfn TransferUnit (unitID, newTeamID, given) ->
TransferUnit (unitID, newTeamID, given) ->[source]
Params
unitID: integernewTeamID: integergiven: boolean? --(Default: `true`) if false, the unit is captured.Returns
: nilfn SetUnitCosts (unitID, where) ->
SetUnitCosts (unitID, where) ->[source]
Params
unitID: integerwhere: table<number,number> --keys and values are, respectively and in this order: buildTime=amount, metalCost=amount, energyCost=amountReturns
: nilfn SetUnitResourcing (unitID, res, amount) ->
SetUnitResourcing (unitID, res, amount) ->[source]
Params
unitID: integerres: stringamount: numberReturns
: nilfn SetUnitResourcing (unitID, res) ->
SetUnitResourcing (unitID, res) ->[source]
Params
unitID: integerres: table<string,number> --keys are: "[u|c][u|m][m|e]" unconditional | conditional, use | make, metal | energy. Values are amountsReturns
: nilfn SetUnitStorage (unitID, res)
SetUnitStorage (unitID, res)[source]
Params
unitID: integerres: ResourceUsage --keys are: "[m|e]" metal | energy. Values are amountsfn SetUnitHealth (unitID, health) ->
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: integerhealth: (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
: nilfn SetUnitMaxHealth (unitID, maxHealth) ->
SetUnitMaxHealth (unitID, maxHealth) ->[source]
Params
unitID: integermaxHealth: numberReturns
: nilfn SetUnitStockpile (unitID, stockpile, buildPercent) ->
SetUnitStockpile (unitID, stockpile, buildPercent) ->[source]
Params
unitID: integerstockpile: number?buildPercent: number?Returns
: nilfn SetUnitUseWeapons (unitID, forceUseWeapons, allowUseWeapons) ->
SetUnitUseWeapons (unitID, forceUseWeapons, allowUseWeapons) ->[source]
Params
unitID: integerforceUseWeapons: number?allowUseWeapons: number?Returns
: nilfn SetUnitWeaponState (unitID, weaponNum, states) ->
SetUnitWeaponState (unitID, weaponNum, states) ->[source]
Params
unitID: integerweaponNum: numberstates: WeaponStateReturns
: nilfn SetUnitWeaponState (unitID, weaponNum, key, value) ->
SetUnitWeaponState (unitID, weaponNum, key, value) ->[source]
Params
unitID: integerweaponNum: numberkey: stringvalue: numberReturns
: nilfn SetUnitWeaponDamages (unitID, weaponNum, damages) ->
SetUnitWeaponDamages (unitID, weaponNum, damages) ->[source]
Params
unitID: integerweaponNum: (number|“selfDestruct”|“explode”)damages: WeaponDamagesReturns
: nilfn SetUnitWeaponDamages (unitID, weaponNum, key, value) ->
SetUnitWeaponDamages (unitID, weaponNum, key, value) ->[source]
Params
unitID: integerweaponNum: (number|“selfDestruct”|“explode”)key: stringvalue: numberReturns
: nilfn SetUnitExperience (unitID, experience) ->
SetUnitExperience (unitID, experience) ->[source]
See: Spring.AddUnitExperience Spring.GetUnitExperience
Params
unitID: integerexperience: numberReturns
: nilfn AddUnitExperience (unitID, deltaExperience) ->
AddUnitExperience (unitID, deltaExperience) ->[source]
See: Spring.SetUnitExperience Spring.GetUnitExperience
Params
unitID: integerdeltaExperience: number --Can be negative to subtract, but the unit will never have negative total afterwardsReturns
: nilfn SetUnitArmored (unitID, armored, armorMultiple) ->
SetUnitArmored (unitID, armored, armorMultiple) ->[source]
Params
unitID: integerarmored: boolean?armorMultiple: number?Returns
: nilfn SetUnitLosMask (unitID, allyTeam, losTypes)
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: integerallyTeam: numberlosTypes: (LosTable|LosMask|integer) --A bitmask of `LosMask` bits or a
table. True bits disable engine updates to visibility.fn SetUnitLosState (unitID, allyTeam, losTypes)
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: integerallyTeam: numberlosTypes: (LosTable|LosMask|integer) --A bitmask of `LosMask` bits or a
tablefn SetUnitCloak (unitID, cloak, cloakArg) ->
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: integercloak: (boolean|number)cloakArg: (boolean|number)Returns
: nilfn SetUnitSonarStealth (unitID, sonarStealth) ->
SetUnitSonarStealth (unitID, sonarStealth) ->[source]
Params
unitID: integersonarStealth: booleanReturns
: nilfn SetUnitSeismicSignature (unitID, seismicSignature) ->
SetUnitSeismicSignature (unitID, seismicSignature) ->[source]
Params
unitID: integerseismicSignature: numberReturns
: nilfn SetUnitLeavesGhost (leavesGhost, leaveDeadGhost)
SetUnitLeavesGhost (leavesGhost, leaveDeadGhost)Set whether unit leaves static radar ghosts.
[source]
Params
leavesGhost: booleanleaveDeadGhost: boolean? --(Default: `false`) leave a dead ghost behind if disabling and the unit had a live static ghost.fn SetUnitAlwaysVisible (unitID, alwaysVisible) ->
SetUnitAlwaysVisible (unitID, alwaysVisible) ->[source]
Params
unitID: integeralwaysVisible: booleanReturns
: nilfn SetUnitUseAirLos (unitID, useAirLos) ->
SetUnitUseAirLos (unitID, useAirLos) ->[source]
Params
unitID: integeruseAirLos: booleanReturns
: nilfn SetUnitMetalExtraction (unitID, depth, range) ->
SetUnitMetalExtraction (unitID, depth, range) ->[source]
Params
unitID: integerdepth: number --corresponds to metal extraction raterange: number? --similar to "extractsMetal" in unitDefs.Returns
: nilfn SetUnitHarvestStorage (unitID, metal) ->
SetUnitHarvestStorage (unitID, metal) ->See also harvestStorage UnitDef tag.
[source]
Params
unitID: integermetal: numberReturns
: nilfn SetUnitBuildParams (unitID, paramName, value) ->
SetUnitBuildParams (unitID, paramName, value) ->[source]
Params
unitID: integerparamName: string --one of `buildRange`|`buildDistance`|`buildRange3D`value: (number|boolean) --boolean when `paramName` is `buildRange3D`, otherwise number.Returns
: nilfn SetUnitBuildSpeed (builderID, buildSpeed, repairSpeed, reclaimSpeed, captureSpeed, terraformSpeed) ->
SetUnitBuildSpeed (builderID, buildSpeed, repairSpeed, reclaimSpeed, captureSpeed, terraformSpeed) ->[source]
Params
builderID: integerbuildSpeed: numberrepairSpeed: number?reclaimSpeed: number?captureSpeed: number?terraformSpeed: number?Returns
: nilfn SetUnitNanoPieces (builderID, pieces) ->
SetUnitNanoPieces (builderID, pieces) ->[source]
This saves a lot of engine calls, by replacing: function script.QueryNanoPiece() return currentpiece end Use it!
Params
builderID: integerpieces: tableReturns
: nilfn SetUnitBlocking (unitID, isBlocking, isSolidObjectCollidable, isProjectileCollidable, isRaySegmentCollidable, crushable, blockEnemyPushing, blockHeightChanges) -> isBlocking
SetUnitBlocking (unitID, isBlocking, isSolidObjectCollidable, isProjectileCollidable, isRaySegmentCollidable, crushable, blockEnemyPushing, blockHeightChanges) -> isBlocking[source]
Params
unitID: integerisBlocking: 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: booleanfn SetUnitCrashing (unitID, crashing) -> success
SetUnitCrashing (unitID, crashing) -> success[source]
Params
unitID: integercrashing: booleanReturns
success: booleanfn SetUnitShieldState (unitID, weaponID, enabled, power) ->
SetUnitShieldState (unitID, weaponID, enabled, power) ->[source]
Params
unitID: integerweaponID: integer? --(Default: `-1`)enabled: boolean?power: number?Returns
: nilfn SetUnitShieldRechargeDelay (unitID, weaponID, rechargeTime) ->
SetUnitShieldRechargeDelay (unitID, weaponID, rechargeTime) ->[source]
Params
unitID: integerweaponID: integer? --(optional if the unit only has one shield)rechargeTime: number? --(in seconds; emulates a regular hit if nil)Returns
: nilfn SetUnitFlanking (unitID, type, arg1, y, z) ->
SetUnitFlanking (unitID, type, arg1, y, z) ->[source]
Params
unitID: integertype: string --"dir"|"minDamage"|"maxDamage"|"moveFactor"|"mode"arg1: number --x|minDamage|maxDamage|moveFactor|modey: number? --only when type is "dir"z: number? --only when type is "dir"Returns
: nilfn GetUnitPhysicalState (unitID) -> Unit
GetUnitPhysicalState (unitID) -> Unit[source]
Params
unitID: integerReturns
Unit: number --'s PhysicalState bitmaskfn SetUnitNeutral (unitID, neutral) -> setNeutral
SetUnitNeutral (unitID, neutral) -> setNeutral[source]
Params
unitID: integerneutral: booleanReturns
setNeutral: boolean?fn SetUnitTarget (unitID, enemyUnitID, dgun, userTarget, weaponNum) -> success
SetUnitTarget (unitID, enemyUnitID, dgun, userTarget, weaponNum) -> successDefines a unit’s target.
[source]
Params
unitID: integerenemyUnitID: integer? --when nil drops the units current target.dgun: boolean? --(Default: `false`)userTarget: boolean? --(Default: `false`)weaponNum: number? --(Default: `-1`)Returns
success: booleanfn SetUnitTarget (unitID, x, y, z, dgun, userTarget, weaponNum) -> success
SetUnitTarget (unitID, x, y, z, dgun, userTarget, weaponNum) -> success[source]
Params
unitID: integerx: number? --when nil or not passed it will drop target and ignore other parametersy: number?z: number?dgun: boolean? --(Default: `false`)userTarget: boolean? --(Default: `false`)weaponNum: number? --(Default: `-1`)Returns
success: booleanfn SetUnitMidAndAimPos (unitID, mpX, mpY, mpZ, apX, apY, apZ, relative) -> success
SetUnitMidAndAimPos (unitID, mpX, mpY, mpZ, apX, apY, apZ, relative) -> success[source]
Params
unitID: integermpX: number --new middle positionX of unitmpY: number --new middle positionY of unitmpZ: number --new middle positionZ of unitapX: number --new positionX that enemies aim at on this unitapY: number --new positionY that enemies aim at on this unitapZ: number --new positionZ that enemies aim at on this unitrelative: boolean? --(Default: `false`) are the new coordinates relative to world (false) or unit (true) coordinates? Also, note that apy is inverted!Returns
success: booleanfn SetUnitRadiusAndHeight (unitID, radius, height) -> success
SetUnitRadiusAndHeight (unitID, radius, height) -> success[source]
Params
unitID: integerradius: numberheight: numberReturns
success: booleanfn SetUnitBuildeeRadius (unitID, build) ->
SetUnitBuildeeRadius (unitID, build) ->[source]
Sets the unit’s radius for when targeted by build, repair, reclaim-type commands.
Params
unitID: integerbuild: number --radius for when targeted by build, repair, reclaim-type commands.Returns
: nilfn SetUnitPieceParent (unitID, AlteredPiece, ParentPiece) ->
SetUnitPieceParent (unitID, AlteredPiece, ParentPiece) ->Changes the pieces hierarchy of a unit by attaching a piece to a new parent.
[source]
Params
unitID: integerAlteredPiece: numberParentPiece: numberReturns
: nilfn SetUnitPieceMatrix (unitID, pieceNum, matrix) ->
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: integerpieceNum: numbermatrix: number[] --an array of 16 floatsReturns
: nilfn SetUnitCollisionVolumeData (unitID, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, vType, tType, Axis) -> enum
SetUnitCollisionVolumeData (unitID, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, vType, tType, Axis) -> enum[source]
Params
unitID: integerscaleX: numberscaleY: numberscaleZ: numberoffsetX: numberoffsetY: numberoffsetZ: numbervType: numbertType: numberAxis: numberReturns
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) ->
SetUnitPieceCollisionVolumeData (unitID, pieceIndex, enable, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, volumeType, primaryAxis) ->[source]
Params
unitID: integerpieceIndex: numberenable: booleanscaleX: numberscaleY: numberscaleZ: numberoffsetX: numberoffsetY: numberoffsetZ: numbervolumeType: number?primaryAxis: number?Returns
: nilfn SetUnitPieceVisible (unitID, pieceIndex, visible) ->
SetUnitPieceVisible (unitID, pieceIndex, visible) ->[source]
Params
unitID: integerpieceIndex: numbervisible: booleanReturns
: nilfn SetUnitSensorRadius (unitID, type, radius) -> New
SetUnitSensorRadius (unitID, type, radius) -> New[source]
Params
unitID: integertype: (“los”|“airLos”|“radar”|“sonar”|“seismic”|“radarJammer”…)radius: numberReturns
New: number? --radius, or `nil` if unit is invalid.fn SetUnitPosErrorParams (unitID, posErrorVectorX, posErrorVectorY, posErrorVectorZ, posErrorDeltaX, posErrorDeltaY, posErrorDeltaZ, nextPosErrorUpdate) ->
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: integerposErrorVectorX: numberposErrorVectorY: numberposErrorVectorZ: numberposErrorDeltaX: numberposErrorDeltaY: numberposErrorDeltaZ: numbernextPosErrorUpdate: number?Returns
: nilfn SetUnitMoveGoal (unitID, goalX, goalY, goalZ, goalRadius, moveSpeed, moveRaw) ->
SetUnitMoveGoal (unitID, goalX, goalY, goalZ, goalRadius, moveSpeed, moveRaw) ->Used by default commands to get in build-, attackrange etc.
[source]
Params
unitID: integergoalX: numbergoalY: numbergoalZ: numbergoalRadius: number?moveSpeed: number?moveRaw: boolean?Returns
: nilfn SetUnitLandGoal (unitID, goalX, goalY, goalZ, goalRadius) ->
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: integergoalX: numbergoalY: numbergoalZ: numbergoalRadius: number?Returns
: nilfn SetUnitPhysics (unitID, posX, posY, posZ, velX, velY, velZ, rotX, rotY, rotZ, dragX, dragY, dragZ) ->
SetUnitPhysics (unitID, posX, posY, posZ, velX, velY, velZ, rotX, rotY, rotZ, dragX, dragY, dragZ) ->[source]
Params
unitID: integerposX: numberposY: numberposZ: numbervelX: numbervelY: numbervelZ: numberrotX: numberrotY: numberrotZ: numberdragX: numberdragY: numberdragZ: numberReturns
: nilfn SetUnitPosition (unitID, x, z, floating) ->
SetUnitPosition (unitID, x, z, floating) ->Set unit position (2D)
[source]
Sets a unit’s position in 2D, at terrain height.
Params
unitID: integerx: numberz: numberfloating: boolean? --(Default: `false`) If true, over water the position is on surface. If false, on seafloor.Returns
: nilfn SetUnitPosition (unitID, x, y, z) ->
SetUnitPosition (unitID, x, y, z) ->Set unit position (3D)
[source]
Sets a unit’s position in 3D, at an arbitrary height.
Params
unitID: integerx: numbery: numberz: numberReturns
: nilfn SetUnitRotation (unitID, pitch, yaw, roll) ->
SetUnitRotation (unitID, pitch, yaw, roll) ->[source]
Note: PYR order
Params
unitID: integerpitch: number --Rotation in X axisyaw: number --Rotation in Y axisroll: number --Rotation in Z axisReturns
: nilfn SetUnitDirection (unitID, frontx, fronty, frontz) ->
SetUnitDirection (unitID, frontx, fronty, frontz) ->[source]
Set unit front direction vector. The vector is normalized in the engine.
Params
unitID: integerfrontx: numberfronty: numberfrontz: numberReturns
: nilfn SetUnitDirection (unitID, frontx, fronty, frontz, rightx, righty, rightz) ->
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: integerfrontx: numberfronty: numberfrontz: numberrightx: numberrighty: numberrightz: numberReturns
: nilfn SetUnitHeadingAndUpDir (unitID, heading, upx, upy, upz) ->
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: integerheading: Headingupx: numberupy: numberupz: numberReturns
: nilfn SetUnitVelocity (unitID, velX, velY, velZ)
SetUnitVelocity (unitID, velX, velY, velZ)Set the velocity of a Unit
[source]
See: Spring.SetUnitMoveCtrl for disabling/enabling this control
Params
unitID: integervelX: number --in elmos/framevelY: number --in elmos/framevelZ: number --in elmos/framefn BuggerOff (x, y, z, radius, teamID, spherical, forced, excludeUnitID, excludeUnitDefIDs) ->
BuggerOff (x, y, z, radius, teamID, spherical, forced, excludeUnitID, excludeUnitDefIDs) ->[source]
Params
x: numbery: numberz: number? --uses ground height when unspecifiedradius: numberteamID: integerspherical: boolean? --(Default: `true`)forced: boolean? --(Default: `true`)excludeUnitID: integer?excludeUnitDefIDs: number[]?Returns
: nilfn AddFeatureDamage (featureID, damage, paralyze, attackerID, weaponID, impulseX, impulseY, impulseZ)
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: integerdamage: numberparalyze: 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) ->
AddUnitDamage (unitID, damage, paralyze, attackerID, weaponID, impulseX, impulseY, impulseZ) ->[source]
Params
unitID: integerdamage: numberparalyze: 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
: nilfn AddUnitImpulse (unitID, x, y, z, decayRate) ->
AddUnitImpulse (unitID, x, y, z, decayRate) ->[source]
Params
unitID: integerx: numbery: numberz: numberdecayRate: number?Returns
: nilfn AddUnitSeismicPing (unitID, pindSize) ->
AddUnitSeismicPing (unitID, pindSize) ->[source]
Params
unitID: integerpindSize: numberReturns
: nilfn AddUnitResource (unitID, resource, amount) ->
AddUnitResource (unitID, resource, amount) ->[source]
Params
unitID: integerresource: string --"m" | "e"amount: numberReturns
: nilfn UseUnitResource (unitID, resource, amount) -> okay
UseUnitResource (unitID, resource, amount) -> okay[source]
Params
unitID: integerresource: ResourceNameamount: numberReturns
okay: boolean?fn UseUnitResource (unitID, resources) -> okay
UseUnitResource (unitID, resources) -> okay[source]
Params
unitID: integerresources: ResourceUsageReturns
okay: boolean?fn TransferFeature (featureID, teamID) ->
TransferFeature (featureID, teamID) ->Feature Control
[source]
Params
featureID: integerteamID: integerReturns
: nilfn SetFeatureAlwaysVisible (featureID, enable) ->
SetFeatureAlwaysVisible (featureID, enable) ->[source]
Params
featureID: integerenable: booleanReturns
: nilfn SetFeatureUseAirLos (featureID, useAirLos) ->
SetFeatureUseAirLos (featureID, useAirLos) ->[source]
Params
featureID: integeruseAirLos: booleanReturns
: nilfn SetFeatureHealth (featureID, health, checkDestruction) ->
SetFeatureHealth (featureID, health, checkDestruction) ->[source]
Params
featureID: integerhealth: numbercheckDestruction: boolean? --(Default: `false`) Whether to destroy feature if feature goes below 0 health.Returns
: nilfn SetFeatureMaxHealth (featureID, maxHealth) ->
SetFeatureMaxHealth (featureID, maxHealth) ->[source]
Params
featureID: integermaxHealth: number --minimum 0.1Returns
: nilfn SetFeatureReclaim (featureID, reclaimLeft) ->
SetFeatureReclaim (featureID, reclaimLeft) ->[source]
Params
featureID: integerreclaimLeft: numberReturns
: nilfn SetFeatureResources (featureID, metal, energy, reclaimTime, reclaimLeft, featureDefMetal, featureDefEnergy) ->
SetFeatureResources (featureID, metal, energy, reclaimTime, reclaimLeft, featureDefMetal, featureDefEnergy) ->[source]
Params
featureID: integermetal: numberenergy: numberreclaimTime: number?reclaimLeft: number?featureDefMetal: number?featureDefEnergy: number?Returns
: nilfn SetFeatureResurrect (featureID, unitDef, facing, progress) ->
SetFeatureResurrect (featureID, unitDef, facing, progress) ->[source]
Params
featureID: integerunitDef: (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
: nilfn SetFeatureMoveCtrl (featureID, enabled, initialVelocityX, initialVelocityY, initialVelocityZ, accelerationX, accelerationY, accelerationZ)
SetFeatureMoveCtrl (featureID, enabled, initialVelocityX, initialVelocityY, initialVelocityZ, accelerationX, accelerationY, accelerationZ)Enable feature movement control.
[source]
Params
featureID: integerenabled: 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)
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: integerenabled: 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) ->
SetFeaturePhysics (featureID, posX, posY, posZ, velX, velY, velZ, rotX, rotY, rotZ, dragX, dragY, dragZ) ->[source]
Params
featureID: integerposX: numberposY: numberposZ: numbervelX: numbervelY: numbervelZ: numberrotX: numberrotY: numberrotZ: numberdragX: numberdragY: numberdragZ: numberReturns
: nilfn SetFeaturePosition (featureID, x, y, z, snapToGround) ->
SetFeaturePosition (featureID, x, y, z, snapToGround) ->[source]
Params
featureID: integerx: numbery: numberz: numbersnapToGround: boolean?Returns
: nilfn SetFeatureRotation (featureID, pitch, yaw, roll) ->
SetFeatureRotation (featureID, pitch, yaw, roll) ->[source]
Note: PYR order
Params
featureID: integerpitch: number --Rotation in X axisyaw: number --Rotation in Y axisroll: number --Rotation in Z axisReturns
: nilfn SetFeatureDirection (featureID, frontx, fronty, frontz) ->
SetFeatureDirection (featureID, frontx, fronty, frontz) ->[source]
Set feature front direction vector. The vector is normalized in the engine.
Params
featureID: integerfrontx: numberfronty: numberfrontz: numberReturns
: nilfn SetFeatureDirection (featureID, frontx, fronty, frontz, rightx, righty, rightz) ->
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: integerfrontx: numberfronty: numberfrontz: numberrightx: numberrighty: numberrightz: numberReturns
: nilfn SetFeatureHeadingAndUpDir (featureID, heading, upx, upy, upz) ->
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: integerheading: Headingupx: numberupy: numberupz: numberReturns
: nilfn SetFeatureVelocity (featureID, velX, velY, velZ)
SetFeatureVelocity (featureID, velX, velY, velZ)Set the velocity of a Feature
[source]
See: Spring.SetFeatureMoveCtrl for disabling/enabling this control
Params
featureID: integervelX: number --in elmos/framevelY: number --in elmos/framevelZ: number --in elmos/framefn SetFeatureBlocking (featureID, isBlocking, isSolidObjectCollidable, isProjectileCollidable, isRaySegmentCollidable, crushable, blockEnemyPushing, blockHeightChanges) -> isBlocking
SetFeatureBlocking (featureID, isBlocking, isSolidObjectCollidable, isProjectileCollidable, isRaySegmentCollidable, crushable, blockEnemyPushing, blockHeightChanges) -> isBlocking[source]
Params
featureID: integerisBlocking: 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: booleanfn SetFeatureNoSelect (featureID, noSelect) ->
SetFeatureNoSelect (featureID, noSelect) ->[source]
Params
featureID: integernoSelect: booleanReturns
: nilfn SetFeatureMidAndAimPos (featureID, mpX, mpY, mpZ, apX, apY, apZ, relative) -> success
SetFeatureMidAndAimPos (featureID, mpX, mpY, mpZ, apX, apY, apZ, relative) -> success[source]
Check Spring.SetUnitMidAndAimPos for further explanation of the arguments.
Params
featureID: integermpX: numbermpY: numbermpZ: numberapX: numberapY: numberapZ: numberrelative: boolean?Returns
success: booleanfn SetFeatureRadiusAndHeight (featureID, radius, height) -> success
SetFeatureRadiusAndHeight (featureID, radius, height) -> success[source]
Params
featureID: integerradius: numberheight: numberReturns
success: booleanfn SetFeatureCollisionVolumeData (featureID, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, vType, tType, Axis) ->
SetFeatureCollisionVolumeData (featureID, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, vType, tType, Axis) ->[source]
Check Spring.SetUnitCollisionVolumeData for further explanation of the arguments.
Params
featureID: integerscaleX: numberscaleY: numberscaleZ: numberoffsetX: numberoffsetY: numberoffsetZ: numbervType: numbertType: numberAxis: numberReturns
: nilfn SetFeaturePieceCollisionVolumeData (featureID, pieceIndex, enable, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, Axis, volumeType, primaryAxis) ->
SetFeaturePieceCollisionVolumeData (featureID, pieceIndex, enable, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, Axis, volumeType, primaryAxis) ->[source]
Params
featureID: integerpieceIndex: numberenable: booleanscaleX: numberscaleY: numberscaleZ: numberoffsetX: numberoffsetY: numberoffsetZ: numberAxis: numbervolumeType: numberprimaryAxis: number?Returns
: nilfn SetFeaturePieceVisible (featureID, pieceIndex, visible) ->
SetFeaturePieceVisible (featureID, pieceIndex, visible) ->[source]
Params
featureID: integerpieceIndex: numbervisible: booleanReturns
: nilfn SetFeatureFireTime (featureID, fireTime)
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: integerfireTime: number --in secondsfn SetFeatureSmokeTime (featureID, smokeTime)
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: integersmokeTime: number --in secondsfn CreateUnitWreck (unitID, wreckLevel, doSmoke) -> featureID
CreateUnitWreck (unitID, wreckLevel, doSmoke) -> featureIDCreate a wreck from a unit
[source]
Params
unitID: integerwreckLevel: 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
CreateFeatureWreck (featureID, wreckLevel, doSmoke) -> featureIDCreate a wreck from a feature
[source]
Params
featureID: integerwreckLevel: 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) ->
SetProjectileAlwaysVisible (projectileID, alwaysVisible) ->[source]
Params
projectileID: integeralwaysVisible: booleanReturns
: nilfn SetProjectileUseAirLos (projectileID, useAirLos) ->
SetProjectileUseAirLos (projectileID, useAirLos) ->[source]
Params
projectileID: integeruseAirLos: booleanReturns
: nilfn SetProjectileMoveControl (projectileID, enable)
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: integerenable: booleanfn SetProjectilePosition (projectileID, posX, posY, posZ)
SetProjectilePosition (projectileID, posX, posY, posZ)Set the position of a projectile
[source]
Params
projectileID: integerposX: number? --(Default: `0`)posY: number? --(Default: `0`)posZ: number? --(Default: `0`)fn SetProjectileVelocity (projectileID, velX, velY, velZ)
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: integervelX: number --in elmos/framevelY: number --in elmos/framevelZ: number --in elmos/framefn SetProjectileTarget (projectileID, targetID, targetType) -> validTarget
SetProjectileTarget (projectileID, targetID, targetType) -> validTargetSet projectile target (object)
[source]
Params
projectileID: integertargetID: numbertargetType: ProjectileTargetTypeReturns
validTarget: boolean?fn SetProjectileTarget (projectileID, posX, posY, posZ) -> validTarget
SetProjectileTarget (projectileID, posX, posY, posZ) -> validTargetSet projectile target (position)
[source]
Params
projectileID: integerposX: numberposY: numberposZ: numberReturns
validTarget: boolean?fn SetProjectileTimeToLive (projectileID, ttl)
SetProjectileTimeToLive (projectileID, ttl)Set Time To Live for a projectile
[source]
Params
projectileID: integerttl: number --Remaining time to live in framesfn SetProjectileDamages (unitID, weaponNum, key, value)
SetProjectileDamages (unitID, weaponNum, key, value)[source]
Params
unitID: integerweaponNum: integerkey: stringvalue: numberfn SetProjectileIgnoreTrackingError (projectileID, ignore)
SetProjectileIgnoreTrackingError (projectileID, ignore)[source]
Params
projectileID: integerignore: booleanfn SetProjectileGravity (projectileID, grav) ->
SetProjectileGravity (projectileID, grav) ->[source]
Params
projectileID: integergrav: number? --(Default: `0`)Returns
: nilfn SetPieceProjectileParams (projectileID, explosionFlags, spinAngle, spinSpeed, spinVectorX, spinVectorY, spinVectorZ)
SetPieceProjectileParams (projectileID, explosionFlags, spinAngle, spinSpeed, spinVectorX, spinVectorY, spinVectorZ)Set piece projectile params
Non passed or nil args don’t set params.
[source]
Params
projectileID: integerexplosionFlags: number?spinAngle: number?spinSpeed: number?spinVectorX: number?spinVectorY: number?spinVectorZ: number?fn SetProjectileCEG (projectileID, ceg_name) ->
SetProjectileCEG (projectileID, ceg_name) ->[source]
Params
projectileID: integerceg_name: stringReturns
: nilfn GiveOrderToUnit (unitID, cmdID, params, options, timeout) -> unitOrdered
GiveOrderToUnit (unitID, cmdID, params, options, timeout) -> unitOrdered[source]
Params
unitID: integercmdID: (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: booleanfn GiveOrderToUnitMap (unitMap, cmdID, params, options, timeout) -> unitsOrdered
GiveOrderToUnitMap (unitMap, cmdID, params, options, timeout) -> unitsOrderedGive 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
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
GiveOrderArrayToUnit (unitID, commands) -> ordersGiven[source]
Params
unitID: integercommands: CreateCommand[]Returns
ordersGiven: booleanfn GiveOrderArrayToUnitMap (unitMap, commands) -> unitsOrdered
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
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)
LevelHeightMap (x, z, height)Set the height of a point in the world.
[source]
Params
x: numberz: numberheight: numberfn LevelHeightMap (x1, z1, x2, z2, height) ->
LevelHeightMap (x1, z1, x2, z2, height) ->Set the height of a rectangle area in the world.
[source]
Params
x1: numberz1: numberx2: numberz2: numberheight: number?Returns
: nilfn AdjustHeightMap (x, z, height)
AdjustHeightMap (x, z, height)Add height to a point in the world.
[source]
Params
x: numberz: numberheight: numberfn AdjustHeightMap (x1, z1, x2, z2, height) ->
AdjustHeightMap (x1, z1, x2, z2, height) ->Add height to a rectangle in the world.
[source]
Params
x1: numberz1: numberx2: numberz2: numberheight: number?Returns
: nilfn RevertHeightMap (x, z, height)
RevertHeightMap (x, z, height)Restore map height at a point in the world.
[source]
Params
x: numberz: numberheight: numberfn RevertHeightMap (x1, z1, x2, z2, height) ->
RevertHeightMap (x1, z1, x2, z2, height) ->Restore map height of a rectangle area in the world.
[source]
Params
x1: numberz1: numberx2: numberz2: numberheight: number?Returns
: nilfn AddHeightMap (x, z, height) -> newHeight
AddHeightMap (x, z, height) -> newHeightCan only be called in Spring.SetHeightMapFunc
[source]
Params
x: numberz: numberheight: numberReturns
newHeight: integer?fn SetHeightMap (x, z, height, terraform) -> absHeightDiff
SetHeightMap (x, z, height, terraform) -> absHeightDiff[source]
Can only be called in Spring.SetHeightMapFunc.
Params
x: numberz: numberheight: numberterraform: 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
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: functionarg: number...: numberReturns
absTotalHeightMapAmountChanged: integer?fn LevelOriginalHeightMap (x, z, height)
LevelOriginalHeightMap (x, z, height)Set the height of a point in the original map height cache.
[source]
Params
x: numberz: numberheight: numberfn LevelOriginalHeightMap (x1, z1, x2, z2, height)
LevelOriginalHeightMap (x1, z1, x2, z2, height)Set the height of a rectangle area in the original map height cache.
[source]
Params
x1: numberz1: numberx2: numberz2: numberheight: numberfn AdjustOriginalHeightMap (x, z, height)
AdjustOriginalHeightMap (x, z, height)Add height to a point in the original map height cache.
[source]
Params
x: numberz: numberheight: numberfn AdjustOriginalHeightMap (x1, z1, x2, z2, height)
AdjustOriginalHeightMap (x1, z1, x2, z2, height)Add height to a rectangle area in the original map height cache.
[source]
Params
x1: numberz1: numberx2: numberz2: numberheight: numberfn RevertOriginalHeightMap (x, z, height)
RevertOriginalHeightMap (x, z, height)Restore original map height at a point in the world.
[source]
Params
x: numberz: numberheight: numberfn RevertOriginalHeightMap (x1, z1, x2, z2, height) ->
RevertOriginalHeightMap (x1, z1, x2, z2, height) ->Restore original map height over a rectangle in the world.
[source]
Params
x1: numberz1: numberx2: numberz2: numberheight: number?Returns
: nilfn AddOriginalHeightMap (x, y, height) ->
AddOriginalHeightMap (x, y, height) ->[source]
Can only be called in Spring.SetOriginalHeightMapFunc
Params
x: numbery: numberheight: numberReturns
: nilfn SetOriginalHeightMap (x, y, height, factor) ->
SetOriginalHeightMap (x, y, height, factor) ->[source]
Can only be called in Spring.SetOriginalHeightMapFunc
Params
x: numbery: numberheight: numberfactor: number?Returns
: nilfn SetOriginalHeightMapFunc (heightMapFunc) ->
SetOriginalHeightMapFunc (heightMapFunc) ->[source]
Cannot recurse on itself
Params
heightMapFunc: functionReturns
: nilfn RebuildSmoothMesh () ->
RebuildSmoothMesh () ->[source]
Heightmap changes normally take up to 25s to propagate to the smooth mesh. Use to force a mapwide update immediately.
Returns
: nilfn LevelSmoothMesh (x1, z1, x2, z2, height)
LevelSmoothMesh (x1, z1, x2, z2, height)[source]
Params
x1: numberz1: numberx2: numberz2: numberheight: numberfn AdjustSmoothMesh (x1, z1, x2, z2, height)
AdjustSmoothMesh (x1, z1, x2, z2, height)[source]
Params
x1: numberz1: numberx2: numberz2: numberheight: numberfn RevertSmoothMesh (x1, z1, x2, z2, origFactor)
RevertSmoothMesh (x1, z1, x2, z2, origFactor)[source]
Params
x1: numberz1: numberx2: numberz2: numberorigFactor: numberfn AddSmoothMesh (x, z, height) -> height
AddSmoothMesh (x, z, height) -> heightCan only be called in Spring.SetSmoothMeshFunc.
[source]
Params
x: numberz: numberheight: numberReturns
height: number? --The new height, or `nil` if coordinates are invalid.fn SetSmoothMesh (x, z, height, terraform) -> The
SetSmoothMesh (x, z, height, terraform) -> TheCan only be called in Spring.SetSmoothMeshFunc.
[source]
Params
x: numberz: numberheight: numberterraform: number? --(Default: `1`)Returns
The: number? --absolute height difference, or `nil` if coordinates are invalid.fn SetSmoothMeshFunc (luaFunction, arg, ...) -> absTotalHeightMapAmountChanged
SetSmoothMeshFunc (luaFunction, arg, ...) -> absTotalHeightMapAmountChanged[source]
Params
luaFunction: functionarg: any...: anyReturns
absTotalHeightMapAmountChanged: number?fn SetMapSquareTerrainType (x, z, newType) -> oldType
SetMapSquareTerrainType (x, z, newType) -> oldType[source]
Params
x: numberz: numbernewType: numberReturns
oldType: integer?fn SetTerrainTypeData (typeIndex, speedTanks, speedKBOts, speedHovers, speedShips) ->
SetTerrainTypeData (typeIndex, speedTanks, speedKBOts, speedHovers, speedShips) ->[source]
Params
typeIndex: numberspeedTanks: number? --(Default: nil)speedKBOts: number? --(Default: nil)speedHovers: number? --(Default: nil)speedShips: number? --(Default: nil)Returns
: boolean? --truefn SetSquareBuildingMask (x, z, mask) -> See
SetSquareBuildingMask (x, z, mask) -> See[source]
Params
x: numberz: numbermask: numberReturns
See: nil --also buildingMask unitdef tag.fn UnitWeaponHoldFire (unitID, weaponID) ->
UnitWeaponHoldFire (unitID, weaponID) ->[source]
Params
unitID: integerweaponID: integerReturns
: nilfn ForceUnitCollisionUpdate (unitID) ->
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: integerReturns
: nilfn UnitAttach (transporterID, passengerID, pieceNum) ->
UnitAttach (transporterID, passengerID, pieceNum) ->[source]
Params
transporterID: integerpassengerID: integerpieceNum: numberReturns
: nilfn SetUnitLoadingTransport (passengerID, transportID) ->
SetUnitLoadingTransport (passengerID, transportID) ->Disables collisions between the two units to allow colvol intersection during the approach.
[source]
Params
passengerID: integertransportID: integerReturns
: nilfn SpawnProjectile (weaponDefID, projectileParams) -> projectileID
SpawnProjectile (weaponDefID, projectileParams) -> projectileID[source]
Params
weaponDefID: integerprojectileParams: ProjectileParamsReturns
projectileID: integer?fn DeleteProjectile (projectileID) ->
DeleteProjectile (projectileID) ->Silently removes projectiles (no explosion).
[source]
Params
projectileID: integerReturns
: nilfn SpawnExplosion (posX, posY, posZ, dirX, dirY, dirZ, explosionParams) ->
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: ExplosionParamsReturns
: nilfn SpawnCEG (cegname, posX, posY, posZ, dirX, dirY, dirZ, radius, damage) -> success, cegID
SpawnCEG (cegname, posX, posY, posZ, dirX, dirY, dirZ, radius, damage) -> success, cegID[source]
Params
cegname: stringposX: 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: integerfn SpawnSFX (unitID, sfxID, posX, posY, posZ, dirX, dirY, dirZ, radius, damage, absolute) -> success
SpawnSFX (unitID, sfxID, posX, posY, posZ, dirX, dirY, dirZ, radius, damage, absolute) -> successEqual 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 SetExperienceGrade (expGrade, ExpPowerScale, ExpHealthScale, ExpReloadScale) ->
SetExperienceGrade (expGrade, ExpPowerScale, ExpHealthScale, ExpReloadScale) ->Defines how often Callins.UnitExperience will be called.
[source]
Params
expGrade: numberExpPowerScale: number?ExpHealthScale: number?ExpReloadScale: number?Returns
: nilfn SetRadarErrorParams (allyTeamID, allyteamErrorSize, baseErrorSize, baseErrorMult) ->
SetRadarErrorParams (allyTeamID, allyteamErrorSize, baseErrorSize, baseErrorMult) ->[source]
Params
allyTeamID: integerallyteamErrorSize: numberbaseErrorSize: number?baseErrorMult: number?Returns
: nilfn EditUnitCmdDesc (unitID, cmdDescID, cmdArray)
EditUnitCmdDesc (unitID, cmdDescID, cmdArray)[source]
Params
unitID: integercmdDescID: integercmdArray: CommandDescriptionfn InsertUnitCmdDesc (unitID, index, cmdDesc)
InsertUnitCmdDesc (unitID, index, cmdDesc)Insert a command description at a specific index.
[source]
Params
unitID: integerindex: integercmdDesc: CommandDescriptionfn InsertUnitCmdDesc (unitID, cmdDesc)
InsertUnitCmdDesc (unitID, cmdDesc)Insert a command description at the last position.
[source]
Params
unitID: integercmdDesc: CommandDescriptionfn GetGameFrame () -> t1, t2
GetGameFrame () -> t1, t2[source]
Returns
t1: number --frameNum % dayFramest2: number --frameNum / dayFramesfn GetWind () -> windSpeedX, windSpeedY, windSpeedZ, windStrength, windDirX, windDirY, windDirZ
GetWind () -> windSpeedX, windSpeedY, windSpeedZ, windStrength, windDirX, windDirY, windDirZ[source]
Returns
windSpeedX: numberwindSpeedY: number --(Always 0)windSpeedZ: numberwindStrength: number --(Length of windSpeed)windDirX: number --(Normalized windSpeed)windDirY: number --(Always 0)windDirZ: numberfn GetGameRulesParams () -> rulesParams
GetGameRulesParams () -> rulesParams[source]
Returns
rulesParams: RulesParams --map with rules names as key and values as valuesfn GetTeamRulesParams (teamID) -> rulesParams
GetTeamRulesParams (teamID) -> rulesParams[source]
Params
teamID: integerReturns
rulesParams: RulesParams --map with rules names as key and values as valuesfn GetPlayerRulesParams (playerID) -> rulesParams
GetPlayerRulesParams (playerID) -> rulesParams[source]
Params
playerID: integerReturns
rulesParams: RulesParams --map with rules names as key and values as valuesfn GetUnitRulesParams (unitID) -> rulesParams
GetUnitRulesParams (unitID) -> rulesParams[source]
Params
unitID: integerReturns
rulesParams: RulesParams --map with rules names as key and values as valuesfn GetFeatureRulesParams (featureID) -> rulesParams
GetFeatureRulesParams (featureID) -> rulesParams[source]
Params
featureID: integerReturns
rulesParams: RulesParams --map with rules names as key and values as valuesfn GetGameRulesParam (ruleRef) ->
GetGameRulesParam (ruleRef) ->[source]
Params
ruleRef: (number|string) --the rule index or nameReturns
: number? --|string valuefn GetTeamRulesParam (teamID, ruleRef) -> value
GetTeamRulesParam (teamID, ruleRef) -> value[source]
Params
teamID: integerruleRef: (number|string) --the rule index or nameReturns
value: (number|string)?fn GetPlayerRulesParam (playerID, ruleRef) -> value
GetPlayerRulesParam (playerID, ruleRef) -> value[source]
Params
playerID: integerruleRef: (number|string) --the rule index or nameReturns
value: (number|string)?fn GetUnitRulesParam (unitID, ruleRef) -> value
GetUnitRulesParam (unitID, ruleRef) -> value[source]
Params
unitID: integerruleRef: (number|string) --the rule index or nameReturns
value: (number|string)?fn GetFeatureRulesParam (featureID, ruleRef) -> value
GetFeatureRulesParam (featureID, ruleRef) -> value[source]
Params
featureID: integerruleRef: (number|string) --the rule index or nameReturns
value: (number|string)?fn GetMapOption (mapOption) -> value
GetMapOption (mapOption) -> value[source]
Params
mapOption: stringReturns
value: string --Value of `modOption`.fn GetMapOptions () -> mapOptions
GetMapOptions () -> mapOptions[source]
Returns
mapOptions: table<string,string> --Table with options names as keys and values as values.fn GetModOption (modOption) -> value
GetModOption (modOption) -> value[source]
Params
modOption: stringReturns
value: string --Value of `modOption`.fn GetModOptions () -> modOptions
GetModOptions () -> modOptions[source]
Returns
modOptions: table<string,string> --Table with options names as keys and values as values.fn GetFacingFromHeading (heading) -> facing
GetFacingFromHeading (heading) -> facing[source]
Params
heading: numberReturns
facing: FacingIntegerfn GetHeadingFromFacing (facing) -> heading
GetHeadingFromFacing (facing) -> heading[source]
Params
facing: FacingIntegerReturns
heading: numberfn GetSideData (sideName) -> startUnit, caseName
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
GetSideData (sideID) -> sideName, startUnit, caseName[source]
Params
sideID: integerReturns
sideName: string? --Lowercase side name.startUnit: string?caseName: string? --Original case side name.fn GetAllyTeamStartBox (allyID) -> xMin, zMin, xMax, zMax
GetAllyTeamStartBox (allyID) -> xMin, zMin, xMax, zMax[source]
Params
allyID: integerReturns
xMin: number?zMin: number?xMax: number?zMax: number?fn GetTeamStartPosition (teamID) -> x, y, x
GetTeamStartPosition (teamID) -> x, y, x[source]
Params
teamID: integerReturns
x: number?y: number?x: number?fn GetTeamList (allyTeamID) -> teamIDs
GetTeamList (allyTeamID) -> teamIDsGet all team IDs.
[source]
Params
allyTeamID: -1? --(Default: `-1`)Returns
teamIDs: number[] --List of team IDs.fn GetTeamList (allyTeamID) -> teamIDs
GetTeamList (allyTeamID) -> teamIDsGet 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
GetPlayerList (teamID, active) -> list[source]
Params
teamID: integer? --(Default: `-1`) to filter by when >= 0active: boolean? --(Default: `false`) whether to filter only active teamsReturns
list: number[]? --of playerIDsfn GetTeamInfo (teamID, getTeamKeys) -> teamID, leader, isDead, hasAI, side, allyTeam, incomeMultiplier, customTeamKeys
GetTeamInfo (teamID, getTeamKeys) -> teamID, leader, isDead, hasAI, side, allyTeam, incomeMultiplier, customTeamKeys[source]
Params
teamID: integergetTeamKeys: boolean? --(Default: `true`) whether to return the customTeamKeys tableReturns
teamID: integer?leader: numberisDead: numberhasAI: numberside: stringallyTeam: numberincomeMultiplier: numbercustomTeamKeys: table<string,string> --when getTeamKeys is true, otherwise nilfn GetTeamResources (teamID, resource) -> currentLevel, storage, pull, income, expense, share, sent, received, excess
GetTeamResources (teamID, resource) -> currentLevel, storage, pull, income, expense, share, sent, received, excess[source]
Params
teamID: integerresource: ResourceNameReturns
currentLevel: number?storage: numberpull: numberincome: numberexpense: numbershare: numbersent: numberreceived: numberexcess: numberfn GetTeamUnitStats (teamID) -> killed, died, capturedBy, capturedFrom, received, sent
GetTeamUnitStats (teamID) -> killed, died, capturedBy, capturedFrom, received, sent[source]
Params
teamID: integerReturns
killed: number?died: numbercapturedBy: numbercapturedFrom: numberreceived: numbersent: numberfn GetTeamResourceStats (teamID, resource) -> used, produced, excessed, received, sent
GetTeamResourceStats (teamID, resource) -> used, produced, excessed, received, sent[source]
Params
teamID: integerresource: ResourceNameReturns
used: number?produced: numberexcessed: numberreceived: numbersent: numberfn GetTeamDamageStats (teamID) -> damageDealt, damageReceived
GetTeamDamageStats (teamID) -> damageDealt, damageReceivedGets 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: integerReturns
damageDealt: numberdamageReceived: numberfn GetTeamStatsHistory (teamID) -> historyCount
GetTeamStatsHistory (teamID) -> historyCountGet the number of history entries.
[source]
Params
teamID: integerReturns
historyCount: integer? --The number of history entries, or `nil` if unable to resolve team.fn GetTeamMaxUnits (teamID) -> maxUnits, currentUnits
GetTeamMaxUnits (teamID) -> maxUnits, currentUnitsReturns a team’s unit cap.
Also returns the current unit count for readable teams as the 2nd value.
[source]
Params
teamID: integerReturns
maxUnits: numbercurrentUnits: number?fn GetPlayerInfo (playerID, getPlayerOpts) -> name, active, spectator, teamID, allyTeamID, pingTime, cpuUsage, country, rank, hasSkirmishAIsInTeam, playerOpts, desynced
GetPlayerInfo (playerID, getPlayerOpts) -> name, active, spectator, teamID, allyTeamID, pingTime, cpuUsage, country, rank, hasSkirmishAIsInTeam, playerOpts, desynced[source]
Params
playerID: integergetPlayerOpts: boolean? --(Default: `true`) whether to return custom player optionsReturns
name: stringactive: booleanspectator: booleanteamID: integerallyTeamID: integerpingTime: numbercpuUsage: numbercountry: stringrank: numberhasSkirmishAIsInTeam: booleanplayerOpts: { [string]: string } --when playerOpts is truedesynced: booleanfn GetPlayerControlledUnit (playerID) ->
GetPlayerControlledUnit (playerID) ->Returns unit controlled by player on FPS mode
[source]
Params
playerID: integerReturns
: number?fn GetAIInfo (teamID) -> skirmishAIID, name, hostingPlayerID, shortName, version, options
GetAIInfo (teamID) -> skirmishAIID, name, hostingPlayerID, shortName, version, options[source]
Params
teamID: integerReturns
skirmishAIID: integername: stringhostingPlayerID: integershortName: 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 AreTeamsAllied (teamID1, teamID2) ->
AreTeamsAllied (teamID1, teamID2) ->[source]
Params
teamID1: numberteamID2: numberReturns
: boolean?fn ArePlayersAllied (playerID1, playerID2) ->
ArePlayersAllied (playerID1, playerID2) ->[source]
Params
playerID1: numberplayerID2: numberReturns
: boolean?fn GetAllUnits () -> unitIDs
GetAllUnits () -> unitIDsGet 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 GetTeamUnitsSorted (teamID) -> unitsByDef
GetTeamUnitsSorted (teamID) -> unitsByDef[source]
Params
teamID: integerReturns
unitsByDef: table<integer,integer> --A table where keys are unitDefIDs and values are unitIDsfn GetTeamUnitsCounts (teamID) -> countByUnit
GetTeamUnitsCounts (teamID) -> countByUnit[source]
Params
teamID: integerReturns
countByUnit: table<number,number>? --A table where keys are unitDefIDs and values are counts.fn GetTeamUnitsByDefs (teamID, unitDefIDs) -> unitIDs
GetTeamUnitsByDefs (teamID, unitDefIDs) -> unitIDs[source]
Params
teamID: integerunitDefIDs: (number|number[])Returns
unitIDs: number[]?fn GetTeamUnitDefCount (teamID, unitDefID) -> count
GetTeamUnitDefCount (teamID, unitDefID) -> count[source]
Params
teamID: integerunitDefID: integerReturns
count: number?fn GetUnitsInRectangle (xmin, zmin, xmax, zmax, allegiance) -> unitIDs
GetUnitsInRectangle (xmin, zmin, xmax, zmax, allegiance) -> unitIDs[source]
Params
xmin: numberzmin: numberxmax: numberzmax: numberallegiance: number?Returns
unitIDs: number[]fn GetUnitsInBox (xmin, ymin, zmin, xmax, ymax, zmax, allegiance) -> unitIDs
GetUnitsInBox (xmin, ymin, zmin, xmax, ymax, zmax, allegiance) -> unitIDs[source]
Params
xmin: numberymin: numberzmin: numberxmax: numberymax: numberzmax: numberallegiance: number?Returns
unitIDs: number[]fn GetUnitsInCylinder (x, z, radius) -> unitIDs
GetUnitsInCylinder (x, z, radius) -> unitIDs[source]
Params
x: numberz: numberradius: numberReturns
unitIDs: number[]fn GetUnitsInSphere (x, y, z, radius) -> unitIDs
GetUnitsInSphere (x, y, z, radius) -> unitIDs[source]
Params
x: numbery: numberz: numberradius: numberReturns
unitIDs: number[]fn GetUnitsInPlanes (planes, allegiance) -> unitIDs
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)] <= 0Params
planes: Plane[]allegiance: integer?Returns
unitIDs: integer[]fn GetUnitArrayCentroid (units) -> centerX, centerY, centerZ
GetUnitArrayCentroid (units) -> centerX, centerY, centerZReturns the centroid of an array of units
Returns nil for an empty array
[source]
Params
units: table --{ unitID, unitID, ... }Returns
centerX: numbercenterY: numbercenterZ: numberfn GetUnitMapCentroid (units) -> centerX, centerY, centerZ
GetUnitMapCentroid (units) -> centerX, centerY, centerZReturns the centroid of a map of units
Returns nil for an empty map
[source]
Params
units: table --{ [unitID] = true, [unitID] = true, ... }Returns
centerX: numbercenterY: numbercenterZ: numberfn GetUnitNearestAlly (unitID, range) -> unitID
GetUnitNearestAlly (unitID, range) -> unitID[source]
Params
unitID: integerrange: number? --(Default: `1.0e9`)Returns
unitID: integer?fn GetUnitNearestEnemy (unitID, range, useLOS) -> unitID
GetUnitNearestEnemy (unitID, range, useLOS) -> unitID[source]
Params
unitID: integerrange: number? --(Default: `1.0e9`)useLOS: boolean? --(Default: `true`)Returns
unitID: integer?fn GetFeaturesInRectangle (xmin, zmin, xmax, zmax) -> featureIDs
GetFeaturesInRectangle (xmin, zmin, xmax, zmax) -> featureIDs[source]
Params
xmin: numberzmin: numberxmax: numberzmax: numberReturns
featureIDs: number[]fn GetFeaturesInSphere (x, y, z, radius) -> featureIDs
GetFeaturesInSphere (x, y, z, radius) -> featureIDs[source]
Params
x: numbery: numberz: numberradius: numberReturns
featureIDs: number[]fn GetFeaturesInCylinder (x, z, radius, allegiance) -> featureIDs
GetFeaturesInCylinder (x, z, radius, allegiance) -> featureIDs[source]
Params
x: numberz: numberradius: numberallegiance: number?Returns
featureIDs: number[]fn GetProjectilesInRectangle (xmin, zmin, xmax, zmax, excludeWeaponProjectiles, excludePieceProjectiles) -> projectileIDs
GetProjectilesInRectangle (xmin, zmin, xmax, zmax, excludeWeaponProjectiles, excludePieceProjectiles) -> projectileIDs[source]
Params
xmin: numberzmin: numberxmax: numberzmax: numberexcludeWeaponProjectiles: boolean? --(Default: `false`)excludePieceProjectiles: boolean? --(Default: `false`)Returns
projectileIDs: number[]fn GetProjectilesInSphere (x, y, z, radius, excludeWeaponProjectiles, excludePieceProjectiles) -> projectileIDs
GetProjectilesInSphere (x, y, z, radius, excludeWeaponProjectiles, excludePieceProjectiles) -> projectileIDs[source]
Params
x: numbery: numberz: numberradius: numberexcludeWeaponProjectiles: boolean? --(Default: false)excludePieceProjectiles: boolean? --(Default: false)Returns
projectileIDs: number[]fn ValidUnitID (unitID) ->
ValidUnitID (unitID) ->Get whether a unitID is valid
Dead units are not valid.
[source]
Params
unitID: integerReturns
: booleanfn GetUnitArmored (unitID) -> armored, armorMultiple
GetUnitArmored (unitID) -> armored, armorMultiple[source]
Params
unitID: integerReturns
armored: boolean?armorMultiple: numberfn GetUnitSeismicSignature (unitID) -> seismicSignature
GetUnitSeismicSignature (unitID) -> seismicSignature[source]
Params
unitID: integerReturns
seismicSignature: number?fn GetUnitStockpile (unitID) -> numStockpiled, numStockpileQued, buildPercent
GetUnitStockpile (unitID) -> numStockpiled, numStockpileQued, buildPercent[source]
Params
unitID: integerReturns
numStockpiled: integer?numStockpileQued: integer?buildPercent: number?fn GetUnitSensorRadius (unitID, type) -> radius
GetUnitSensorRadius (unitID, type) -> radius[source]
Params
unitID: integertype: string --one of los, airLos, radar, sonar, seismic, radarJammer, sonarJammerReturns
radius: number?fn GetUnitPosErrorParams (unitID, allyTeamID) -> posErrorVectorX, posErrorVectorY, posErrorVectorZ, posErrorDeltaX, posErrorDeltaY, posErrorDeltaZ, nextPosErrorUpdatebaseErrorMult, posErrorBit
GetUnitPosErrorParams (unitID, allyTeamID) -> posErrorVectorX, posErrorVectorY, posErrorVectorZ, posErrorDeltaX, posErrorDeltaY, posErrorDeltaZ, nextPosErrorUpdatebaseErrorMult, posErrorBit[source]
Params
unitID: integerallyTeamID: integer?Returns
posErrorVectorX: number?posErrorVectorY: numberposErrorVectorZ: numberposErrorDeltaX: numberposErrorDeltaY: numberposErrorDeltaZ: numbernextPosErrorUpdatebaseErrorMult: numberposErrorBit: booleanfn GetUnitNeutral (unitID) ->
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: integerReturns
: boolean?fn GetUnitHealth (unitID) -> health, maxHealth, paralyzeDamage, captureProgress, buildProgress
GetUnitHealth (unitID) -> health, maxHealth, paralyzeDamage, captureProgress, buildProgress[source]
Params
unitID: integerReturns
health: number?maxHealth: numberparalyzeDamage: numbercaptureProgress: numberbuildProgress: number --between 0.0-1.0fn GetUnitIsStunned (unitID) -> stunnedOrBuilt, stunned, beingBuilt
GetUnitIsStunned (unitID) -> stunnedOrBuilt, stunned, beingBuiltChecks 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: integerReturns
stunnedOrBuilt: boolean? --unit is disabledstunned: boolean --unit is either stunned via EMP or being transported by a non-fireplatformbeingBuilt: boolean --unit is under constructionfn GetUnitIsBeingBuilt (unitID) -> beingBuilt, buildProgress
GetUnitIsBeingBuilt (unitID) -> beingBuilt, buildProgress[source]
Params
unitID: integerReturns
beingBuilt: booleanbuildProgress: numberfn GetUnitResources (unitID) -> metalMake, metalUse, energyMake, energyUse
GetUnitResources (unitID) -> metalMake, metalUse, energyMake, energyUse[source]
Params
unitID: integerReturns
metalMake: number?metalUse: numberenergyMake: numberenergyUse: numberfn GetUnitStorage (unitID) -> Unit, Unit
GetUnitStorage (unitID) -> Unit, Unit[source]
Params
unitID: integerReturns
Unit: number --'s metal storageUnit: number --'s energy storagefn GetUnitCosts (unitID) -> buildTime, metalCost, energyCost
GetUnitCosts (unitID) -> buildTime, metalCost, energyCost[source]
Params
unitID: integerReturns
buildTime: number?metalCost: numberenergyCost: numberfn GetUnitCostTable (unitID) -> cost, buildTime
GetUnitCostTable (unitID) -> cost, buildTime[source]
Params
unitID: integerReturns
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
GetUnitMetalExtraction (unitID) -> metalExtraction[source]
Params
unitID: integerReturns
metalExtraction: number?fn GetUnitExperience (unitID) -> xp, limXp
GetUnitExperience (unitID) -> xp, limXp[source]
Params
unitID: integerReturns
xp: number --[0.0; +∞)limXp: number --[0.0; 1.0) as experience approaches infinityfn GetUnitBuildeeRadius (unitID) ->
GetUnitBuildeeRadius (unitID) ->[source]
Gets the unit’s radius for when targeted by build, repair, reclaim-type commands.
Params
unitID: integerReturns
: number?fn GetUnitPosition (unitID, midPos, aimPos) -> basePointX, basePointY, basePointZ, midPointX, midPointY, midPointZ, aimPointX, aimPointY, aimPointZ
GetUnitPosition (unitID, midPos, aimPos) -> basePointX, basePointY, basePointZ, midPointX, midPointY, midPointZ, aimPointX, aimPointY, aimPointZ[source]
Params
unitID: integermidPos: boolean? --(Default: `false`) return midpoint as wellaimPos: boolean? --(Default: `false`) return aimpoint as wellReturns
basePointX: number?basePointY: numberbasePointZ: numbermidPointX: number?midPointY: numbermidPointZ: numberaimPointX: number?aimPointY: numberaimPointZ: numberfn GetUnitBasePosition (unitID) -> posX, posY, posZ
GetUnitBasePosition (unitID) -> posX, posY, posZ[source]
The same as Spring.GetUnitPosition, but without the optional midpoint calculations.
See: Spring.GetUnitPosition
Params
unitID: integerReturns
posX: number?posY: number?posZ: number?fn GetUnitVectors (unitID) -> front, up, right
GetUnitVectors (unitID) -> front, up, right[source]
Params
unitID: integerReturns
front: float3?up: float3right: float3fn GetUnitRotation (unitID) -> pitch, yaw, roll
GetUnitRotation (unitID) -> pitch, yaw, roll[source]
Note: PYR order
Params
unitID: integerReturns
pitch: number --Rotation in X axisyaw: number --Rotation in Y axisroll: number --Rotation in Z axisfn GetUnitDirection (unitID) -> frontDirX, frontDirY, frontDirZ, rightDirX, rightDirY, rightDirZ, upDirX, upDirY, upDirZ
GetUnitDirection (unitID) -> frontDirX, frontDirY, frontDirZ, rightDirX, rightDirY, rightDirZ, upDirX, upDirY, upDirZ[source]
Params
unitID: integerReturns
frontDirX: numberfrontDirY: numberfrontDirZ: numberrightDirX: numberrightDirY: numberrightDirZ: numberupDirX: numberupDirY: numberupDirZ: numberfn GetUnitHeading (unitID, convertToRadians) -> heading
GetUnitHeading (unitID, convertToRadians) -> heading[source]
Params
unitID: integerconvertToRadians: boolean? --(Default: `false`)Returns
heading: numberfn GetUnitIsBuilding (unitID) -> buildeeUnitID
GetUnitIsBuilding (unitID) -> buildeeUnitIDChecks 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: integerReturns
buildeeUnitID: integer --or nilfn GetUnitWorkerTask (unitID) -> cmdID, targetID
GetUnitWorkerTask (unitID) -> cmdID, targetIDChecks 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: integerReturns
cmdID: integer --of the relevant commandtargetID: integer --if applicable (all except RESTORE)fn GetUnitEffectiveBuildRange (unitID, buildeeDefID) -> effectiveBuildRange
GetUnitEffectiveBuildRange (unitID, buildeeDefID) -> effectiveBuildRange[source]
Useful for setting move goals manually.
Params
unitID: integerbuildeeDefID: integer --or nilReturns
effectiveBuildRange: number --counted to the center of prospective buildee; buildRange if buildee nilfn GetUnitHarvestStorage (unitID) -> storedMetal, maxStoredMetal, storedEnergy, maxStoredEnergy
GetUnitHarvestStorage (unitID) -> storedMetal, maxStoredMetal, storedEnergy, maxStoredEnergyGet a unit’s carried resources
[source]
Checks resources being carried internally by the unit.
Params
unitID: integerReturns
storedMetal: numbermaxStoredMetal: numberstoredEnergy: numbermaxStoredEnergy: numberfn GetUnitInBuildStance (unitID) -> inBuildStance
GetUnitInBuildStance (unitID) -> inBuildStanceIs 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: integerReturns
inBuildStance: booleanfn GetUnitNanoPieces (unitID) -> pieceArray
GetUnitNanoPieces (unitID) -> pieceArrayGet 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: integerReturns
pieceArray: integer[]fn GetUnitTransporter (unitID) -> transportUnitID
GetUnitTransporter (unitID) -> transportUnitIDGet 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: integerReturns
transportUnitID: integer?fn GetUnitIsTransporting (unitID) -> transporteeArray
GetUnitIsTransporting (unitID) -> transporteeArrayGet units being transported
[source]
Params
unitID: integerReturns
transporteeArray: integer[]?fn GetUnitShieldState (unitID, weaponNum) -> isEnabled, currentPower
GetUnitShieldState (unitID, weaponNum) -> isEnabled, currentPower[source]
Params
unitID: integerweaponNum: number? --Optional if the unit has just one shieldReturns
isEnabled: number --Warning, number not boolean. 0 or 1currentPower: numberfn GetUnitMaxRange (unitID) -> maxRange
GetUnitMaxRange (unitID) -> maxRangeGet 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: integerReturns
maxRange: numberfn GetUnitWeaponState (unitID, weaponNum, stateName) -> stateValue
GetUnitWeaponState (unitID, weaponNum, stateName) -> stateValueCheck 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: integerweaponNum: numberstateName: stringReturns
stateValue: numberfn GetUnitWeaponTarget (unitID, weaponNum) -> TargetType, isUserTarget
GetUnitWeaponTarget (unitID, weaponNum) -> TargetType, isUserTargetChecks 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: integerweaponNum: integerReturns
TargetType: 0 --noneisUserTarget: booleanfn GetUnitWeaponTarget (unitID, weaponNum) -> TargetType, isUserTarget, targetUnitID
GetUnitWeaponTarget (unitID, weaponNum) -> TargetType, isUserTarget, targetUnitIDChecks 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: integerweaponNum: integerReturns
TargetType: 1 --unitisUserTarget: booleantargetUnitID: integerfn GetUnitWeaponTarget (unitID, weaponNum) -> TargetType, isUserTarget, targetPosition
GetUnitWeaponTarget (unitID, weaponNum) -> TargetType, isUserTarget, targetPositionChecks 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: integerweaponNum: integerReturns
TargetType: 2 --positionisUserTarget: booleantargetPosition: float3fn GetUnitWeaponTarget (unitID, weaponNum) -> TargetType, isUserTarget, targetProjectileId
GetUnitWeaponTarget (unitID, weaponNum) -> TargetType, isUserTarget, targetProjectileIdChecks 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: integerweaponNum: integerReturns
TargetType: 3 --projectileIDisUserTarget: booleantargetProjectileId: integerfn GetUnitSeparation (unitID1, unitID2, direction, subtractRadii) ->
GetUnitSeparation (unitID1, unitID2, direction, subtractRadii) ->[source]
Params
unitID1: numberunitID2: numberdirection: boolean? --(Default: `false`) to subtract from, default unitID1 - unitID2subtractRadii: boolean? --(Default: `false`) whether units radii should be subtracted from the totalReturns
: number?fn GetUnitDefDimensions (unitDefID) -> dimensions
GetUnitDefDimensions (unitDefID) -> dimensions[source]
Params
unitDefID: integerReturns
dimensions: UnitDefDimensions?fn GetUnitBlocking (unitID) -> isBlocking, isSolidObjectCollidable, isProjectileCollidable, isRaySegmentCollidable, crushable, blockEnemyPushing, blockHeightChanges
GetUnitBlocking (unitID) -> isBlocking, isSolidObjectCollidable, isProjectileCollidable, isRaySegmentCollidable, crushable, blockEnemyPushing, blockHeightChanges[source]
Params
unitID: integerReturns
isBlocking: boolean?isSolidObjectCollidable: booleanisProjectileCollidable: booleanisRaySegmentCollidable: booleancrushable: booleanblockEnemyPushing: booleanblockHeightChanges: booleanfn GetUnitCurrentCommand (unitID, cmdIndex) -> cmdID, options, tag, Command
GetUnitCurrentCommand (unitID, cmdIndex) -> cmdID, options, tag, CommandGet 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) -> The
GetUnitCommands (unitID, count) -> TheGet the count of commands for a unit.
[source]
Params
unitID: integercount: 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
GetFactoryCommands (unitID, count) -> commandsGet 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: integercount: integer --Maximum amount of commands to return, `-1` returns all commands.Returns
commands: Command[]fn GetFactoryCommands (unitID, count) -> The
GetFactoryCommands (unitID, count) -> TheGet the count of commands for a factory.
[source]
See: Spring.GetFactoryCommandCount for replacement function.
Params
unitID: integercount: 0 --Returns the number of commands in the factory queue.Returns
The: integer --number of commands in the factory queue.fn GetUnitCommandCount (unitID) -> The
GetUnitCommandCount (unitID) -> TheGet the number of commands in a unit’s queue.
[source]
Params
unitID: integerReturns
The: integer --number of commands in the unit's queue.fn GetFactoryCommandCount (unitID) -> The
GetFactoryCommandCount (unitID) -> TheGet 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: integerReturns
The: integer --number of commands in the factory queue.fn GetFactoryCounts (unitID, count, addCmds) -> counts
GetFactoryCounts (unitID, count, addCmds) -> countsGets the build queue of a factory
[source]
Params
unitID: integercount: integer? --(Default: `-1`) Number of commands to retrieve, `-1` for all.addCmds: boolean? --(Default: `false`) Retrieve commands other than buildunitReturns
counts: table<number,number>? --Build queue count by `unitDefID` or `-cmdID`, or `nil` if unit is not found.fn GetCommandQueue (unitID, count) -> cmdCount
GetCommandQueue (unitID, count) -> cmdCountGet the count of commands for a unit.
[source]
Same as Spring.GetUnitCommands
Params
unitID: integercount: 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
GetFullBuildQueue (unitID) -> buildqueueReturns the build queue
[source]
Params
unitID: integerReturns
buildqueue: table<number,number>? --indexed by unitDefID with count valuesfn GetRealBuildQueue (unitID) -> buildqueue
GetRealBuildQueue (unitID) -> buildqueueReturns the build queue cleaned of things the unit can’t build itself
[source]
Params
unitID: integerReturns
buildqueue: table<number,number>? --indexed by unitDefID with count valuesfn GetFeatureHealth (featureID) -> health, defHealth, resurrectProgress
GetFeatureHealth (featureID) -> health, defHealth, resurrectProgress[source]
Params
featureID: integerReturns
health: number?defHealth: numberresurrectProgress: numberfn GetFeaturePosition (featureID) -> x, y, z
GetFeaturePosition (featureID) -> x, y, z[source]
Params
featureID: integerReturns
x: number?y: number?z: number?fn GetFeatureSeparation (featureID1, featureID2, direction) ->
GetFeatureSeparation (featureID1, featureID2, direction) ->[source]
Params
featureID1: numberfeatureID2: numberdirection: boolean? --(Default: `false`) to subtract from, default featureID1 - featureID2Returns
: number?fn GetFeatureRotation (featureID) -> pitch, yaw, roll
GetFeatureRotation (featureID) -> pitch, yaw, roll[source]
Note: PYR order
Params
featureID: integerReturns
pitch: number? --Rotation in X axisyaw: number? --Rotation in Y axisroll: number? --Rotation in Z axisfn GetFeatureDirection (featureID) -> frontDirX, frontDirY, frontDirZ, rightDirX, rightDirY, rightDirZ, upDirX, upDirY, upDirZ
GetFeatureDirection (featureID) -> frontDirX, frontDirY, frontDirZ, rightDirX, rightDirY, rightDirZ, upDirX, upDirY, upDirZ[source]
Params
featureID: integerReturns
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
GetFeatureVelocity (featureID) -> x, y, z, w[source]
Returns nil if no feature found with ID.
Params
featureID: integerReturns
x: number?y: number?z: number?w: number?fn GetFeatureResources (featureID) -> metal, defMetal, energy, defEnergy, reclaimLeft, reclaimTime
GetFeatureResources (featureID) -> metal, defMetal, energy, defEnergy, reclaimLeft, reclaimTime[source]
Params
featureID: integerReturns
metal: number?defMetal: numberenergy: numberdefEnergy: numberreclaimLeft: numberreclaimTime: numberfn GetFeatureBlocking (featureID) -> isBlocking, isSolidObjectCollidable, isProjectileCollidable, isRaySegmentCollidable, crushable, blockEnemyPushing, blockHeightChanges
GetFeatureBlocking (featureID) -> isBlocking, isSolidObjectCollidable, isProjectileCollidable, isRaySegmentCollidable, crushable, blockEnemyPushing, blockHeightChanges[source]
Params
featureID: integerReturns
isBlocking: boolean?isSolidObjectCollidable: boolean?isProjectileCollidable: boolean?isRaySegmentCollidable: boolean?crushable: boolean?blockEnemyPushing: boolean?blockHeightChanges: boolean?fn GetFeatureResurrect (featureID) -> featureDefName, buildFacing
GetFeatureResurrect (featureID) -> featureDefName, buildFacing[source]
Returns nil if no feature found with ID.
Params
featureID: integerReturns
featureDefName: (string|"")?buildFacing: FacingInteger --facing of footprint, 0 - 3fn GetFeatureLastAttackedPiece (featureID) -> Last, frame
GetFeatureLastAttackedPiece (featureID) -> Last, frame[source]
Params
featureID: integerReturns
Last: (string|"")? --hit piece nameframe: integer? --it was last hit on, nil when featureID is not validfn GetFeatureCollisionVolumeData (featureID) ->
GetFeatureCollisionVolumeData (featureID) ->[source]
Params
featureID: integerReturns
: CollisionVolumeData?fn GetFeaturePieceCollisionVolumeData (featureID) ->
GetFeaturePieceCollisionVolumeData (featureID) ->[source]
Params
featureID: integerReturns
: CollisionVolumeData?fn GetFeatureFireTime (featureID) -> fireTime
GetFeatureFireTime (featureID) -> fireTimeGet the feature current fire timer.
[source]
Params
featureID: integerReturns
fireTime: number? --in seconds, nil when featureID is invalid.fn GetFeatureSmokeTime (featureID) -> smokeTime
GetFeatureSmokeTime (featureID) -> smokeTimeGet the feature current smoke timer.
[source]
Params
featureID: integerReturns
smokeTime: number? --in seconds, nil when featureID is invalid.fn GetProjectilePosition (projectileID) -> posX, posY, posZ
GetProjectilePosition (projectileID) -> posX, posY, posZ[source]
Params
projectileID: integerReturns
posX: number?posY: number?posZ: number?fn GetProjectileDirection (projectileID) -> dirX, dirY, dirZ
GetProjectileDirection (projectileID) -> dirX, dirY, dirZ[source]
Params
projectileID: integerReturns
dirX: number?dirY: number?dirZ: number?fn GetProjectileVelocity (projectileID) -> velX, velY, velZ, velW
GetProjectileVelocity (projectileID) -> velX, velY, velZ, velW[source]
Params
projectileID: integerReturns
velX: number?velY: number?velZ: number?velW: number?fn GetPieceProjectileParams (projectileID) -> explosionFlags, spinAngle, spinSpeed, spinVectorX, spinVectorY, spinVectorZ
GetPieceProjectileParams (projectileID) -> explosionFlags, spinAngle, spinSpeed, spinVectorX, spinVectorY, spinVectorZ[source]
Params
projectileID: integerReturns
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 = 128spinAngle: numberspinSpeed: numberspinVectorX: numberspinVectorY: numberspinVectorZ: numberfn GetProjectileTarget (projectileID) -> targetTypeInt, target
GetProjectileTarget (projectileID) -> targetTypeInt, target[source]
Params
projectileID: integerReturns
targetTypeInt: number? --where
string.byte('g') := GROUND
string.byte('u') := UNIT
string.byte('f') := FEATURE
string.byte('p') := PROJECTILEtarget: (number|float3) --targetID or targetPos when targetTypeInt == string.byte('g')fn GetProjectileType (projectileID) -> weapon, piece
GetProjectileType (projectileID) -> weapon, piece[source]
Params
projectileID: integerReturns
weapon: boolean?piece: booleanfn GetProjectileDefID (projectileID) ->
GetProjectileDefID (projectileID) ->[source]
Using this to get a weaponDefID is HIGHLY preferred to indexing WeaponDefNames via GetProjectileName
Params
projectileID: integerReturns
: number?fn GetProjectileDamages (projectileID, tag) ->
GetProjectileDamages (projectileID, tag) ->[source]
Params
projectileID: integertag: 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
IsPosInMap (x, z) -> inPlayArea, inMap[source]
Params
x: numberz: numberReturns
inPlayArea: boolean --whether the position is in the active play areainMap: boolean --whether the position is in the full map area (currently this is the same as above)fn GetGroundHeight (x, z) ->
GetGroundHeight (x, z) ->Get ground height
On sea, this returns the negative depth of the seafloor
[source]
Params
x: numberz: numberReturns
: numberfn GetWaterPlaneLevel () -> waterPlaneLevel
GetWaterPlaneLevel () -> waterPlaneLevelGet 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: numberfn GetWaterLevel (x, z) -> waterLevel
GetWaterLevel (x, z) -> waterLevelGet 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: numberz: numberReturns
waterLevel: numberfn GetGroundOrigHeight (x, z) ->
GetGroundOrigHeight (x, z) ->Get ground height as it was at game start
Returns the original height before the ground got deformed
[source]
Params
x: numberz: numberReturns
: numberfn GetGroundNormal (x, z, smoothed) -> normalX, normalY, normalZ, slope
GetGroundNormal (x, z, smoothed) -> normalX, normalY, normalZ, slope[source]
Params
x: numberz: numbersmoothed: boolean? --(Default: `false`) raw or smoothed center normalReturns
normalX: numbernormalY: numbernormalZ: numberslope: numberfn GetGroundInfo (x, z) -> ix, iz, terrainTypeIndex, name, metalExtraction, hardness, tankSpeed, kbotSpeed, hoverSpeed, shipSpeed, receiveTracks
GetGroundInfo (x, z) -> ix, iz, terrainTypeIndex, name, metalExtraction, hardness, tankSpeed, kbotSpeed, hoverSpeed, shipSpeed, receiveTracks[source]
Params
x: numberz: numberReturns
ix: numberiz: numberterrainTypeIndex: numbername: stringmetalExtraction: numberhardness: numbertankSpeed: numberkbotSpeed: numberhoverSpeed: numbershipSpeed: numberreceiveTracks: booleanfn GetGroundExtremes () -> initMinHeight, initMaxHeight, currMinHeight, currMaxHeight
GetGroundExtremes () -> initMinHeight, initMaxHeight, currMinHeight, currMaxHeight[source]
Returns
initMinHeight: numberinitMaxHeight: numbercurrMinHeight: numbercurrMaxHeight: numberfn GetTerrainTypeData (terrainTypeInfo) -> index, name, hardness, tankSpeed, kbotSpeed, hoverSpeed, shipSpeed, receiveTracks
GetTerrainTypeData (terrainTypeInfo) -> index, name, hardness, tankSpeed, kbotSpeed, hoverSpeed, shipSpeed, receiveTracks[source]
Params
terrainTypeInfo: numberReturns
index: numbername: stringhardness: numbertankSpeed: numberkbotSpeed: numberhoverSpeed: numbershipSpeed: numberreceiveTracks: booleanfn TestMoveOrder (unitDefID, posX, posY, posZ, dirX, dirY, dirZ, testTerrain, testObjects, centerOnly) ->
TestMoveOrder (unitDefID, posX, posY, posZ, dirX, dirY, dirZ, testTerrain, testObjects, centerOnly) ->[source]
Params
unitDefID: integerposX: numberposY: numberposZ: numberdirX: 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
: booleanfn TestBuildOrder (unitDefID, x, y, z, facing) -> blocking, featureID
TestBuildOrder (unitDefID, x, y, z, facing) -> blocking, featureID[source]
Params
unitDefID: integerx: numbery: numberz: numberfacing: FacingReturns
blocking: BuildOrderBlockedStatusfeatureID: integer? --A reclaimable feature in the way.fn Pos2BuildPos (unitDefID, posX, posY, posZ, buildFacing) -> buildPosX, buildPosY, buildPosZ
Pos2BuildPos (unitDefID, posX, posY, posZ, buildFacing) -> buildPosX, buildPosY, buildPosZSnaps a position to the building grid
[source]
Params
unitDefID: integerposX: numberposY: numberposZ: numberbuildFacing: number? --(Default: `0`) one of SOUTH = 0, EAST = 1, NORTH = 2, WEST = 3Returns
buildPosX: numberbuildPosY: numberbuildPosZ: numberfn ClosestBuildPos (teamID, unitDefID, posX, posY, posZ, searchRadius, minDistance, buildFacing) -> buildPosX, buildPosY, buildPosZ
ClosestBuildPos (teamID, unitDefID, posX, posY, posZ, searchRadius, minDistance, buildFacing) -> buildPosX, buildPosY, buildPosZ[source]
Params
teamID: integerunitDefID: integerposX: numberposY: numberposZ: numbersearchRadius: numberminDistance: numberbuildFacing: number --one of SOUTH = 0, EAST = 1, NORTH = 2, WEST = 3Returns
buildPosX: numberbuildPosY: numberbuildPosZ: numberfn GetPositionLosState (posX, posY, posZ, allyTeamID) -> inLosOrRadar, inLos, inRadar, inJammer
GetPositionLosState (posX, posY, posZ, allyTeamID) -> inLosOrRadar, inLos, inRadar, inJammer[source]
Params
posX: numberposY: numberposZ: numberallyTeamID: integer?Returns
inLosOrRadar: booleaninLos: booleaninRadar: booleaninJammer: booleanfn IsPosInLos (posX, posY, posZ, allyTeamID) ->
IsPosInLos (posX, posY, posZ, allyTeamID) ->[source]
Params
posX: numberposY: numberposZ: numberallyTeamID: integer?Returns
: booleanfn IsPosInRadar (posX, posY, posZ, allyTeamID) ->
IsPosInRadar (posX, posY, posZ, allyTeamID) ->[source]
Params
posX: numberposY: numberposZ: numberallyTeamID: integer?Returns
: booleanfn IsPosInAirLos (posX, posY, posZ, allyTeamID) ->
IsPosInAirLos (posX, posY, posZ, allyTeamID) ->[source]
Params
posX: numberposY: numberposZ: numberallyTeamID: integer?Returns
: booleanfn GetUnitLosState (unitID, allyTeamID, raw) -> los
GetUnitLosState (unitID, allyTeamID, raw) -> losGet unit los state (table)
[source]
Params
unitID: integerallyTeamID: 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
IsUnitInLos (unitID, allyTeamID) -> inLos[source]
Params
unitID: integerallyTeamID: integerReturns
inLos: booleanfn IsUnitInAirLos (unitID, allyTeamID) -> inAirLos
IsUnitInAirLos (unitID, allyTeamID) -> inAirLos[source]
Params
unitID: integerallyTeamID: integerReturns
inAirLos: booleanfn IsUnitInRadar (unitID, allyTeamID) -> inRadar
IsUnitInRadar (unitID, allyTeamID) -> inRadar[source]
Params
unitID: integerallyTeamID: integerReturns
inRadar: booleanfn IsUnitInJammer (unitID, allyTeamID) -> inJammer
IsUnitInJammer (unitID, allyTeamID) -> inJammer[source]
Params
unitID: integerallyTeamID: integerReturns
inJammer: booleanfn GetModelRootPiece (modelName) -> index
GetModelRootPiece (modelName) -> index[source]
Params
modelName: stringReturns
index: number --of the root piecefn GetModelPieceMap (modelName) -> pieceInfos
GetModelPieceMap (modelName) -> pieceInfos[source]
Params
modelName: stringReturns
pieceInfos: table<string,number>? --where keys are piece names and values are indicesfn GetModelPieceList (modelName) -> pieceNames
GetModelPieceList (modelName) -> pieceNames[source]
Params
modelName: stringReturns
pieceNames: string[]?fn GetUnitRootPiece (unitID) -> index
GetUnitRootPiece (unitID) -> index[source]
Params
unitID: integerReturns
index: number --of the root piecefn GetUnitPieceMap (unitID) -> pieceInfos
GetUnitPieceMap (unitID) -> pieceInfos[source]
Params
unitID: integerReturns
pieceInfos: table<string,number>? --where keys are piece names and values are indicesfn GetUnitPiecePosDir (unitID, pieceIndex) -> posX, posY, posZ, dirX, dirY, dirZ
GetUnitPiecePosDir (unitID, pieceIndex) -> posX, posY, posZ, dirX, dirY, dirZ[source]
Params
unitID: integerpieceIndex: integerReturns
posX: number?posY: numberposZ: numberdirX: numberdirY: numberdirZ: numberfn GetUnitPiecePosition (unitID, pieceIndex) -> posX, posY, posZ
GetUnitPiecePosition (unitID, pieceIndex) -> posX, posY, posZ[source]
Params
unitID: integerpieceIndex: integerReturns
posX: number?posY: numberposZ: numberfn GetUnitPieceDirection (unitID, pieceIndex) -> dirX, dirY, dirZ
GetUnitPieceDirection (unitID, pieceIndex) -> dirX, dirY, dirZ[source]
Params
unitID: integerpieceIndex: integerReturns
dirX: number?dirY: numberdirZ: numberfn GetUnitPieceMatrix (unitID) -> m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44
GetUnitPieceMatrix (unitID) -> m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44[source]
Params
unitID: integerReturns
m11: number?m12: numberm13: numberm14: numberm21: numberm22: numberm23: numberm24: numberm31: numberm32: numberm33: numberm34: numberm41: numberm42: numberm43: numberm44: numberfn GetFeatureRootPiece (featureID) -> index
GetFeatureRootPiece (featureID) -> index[source]
Params
featureID: integerReturns
index: number --of the root piecefn GetFeaturePieceMap (featureID) -> pieceInfos
GetFeaturePieceMap (featureID) -> pieceInfos[source]
Params
featureID: integerReturns
pieceInfos: table<string,number> --where keys are piece names and values are indicesfn GetFeaturePieceList (featureID) -> pieceNames
GetFeaturePieceList (featureID) -> pieceNames[source]
Params
featureID: integerReturns
pieceNames: string[]fn GetFeaturePiecePosDir (featureID, pieceIndex) -> posX, posY, posZ, dirX, dirY, dirZ
GetFeaturePiecePosDir (featureID, pieceIndex) -> posX, posY, posZ, dirX, dirY, dirZ[source]
Params
featureID: integerpieceIndex: integerReturns
posX: number?posY: numberposZ: numberdirX: numberdirY: numberdirZ: numberfn GetFeaturePiecePosition (featureID, pieceIndex) -> posX, posY, posZ
GetFeaturePiecePosition (featureID, pieceIndex) -> posX, posY, posZ[source]
Params
featureID: integerpieceIndex: integerReturns
posX: number?posY: numberposZ: numberfn GetFeaturePieceDirection (featureID, pieceIndex) -> dirX, dirY, dirZ
GetFeaturePieceDirection (featureID, pieceIndex) -> dirX, dirY, dirZ[source]
Params
featureID: integerpieceIndex: integerReturns
dirX: number?dirY: numberdirZ: numberfn GetFeaturePieceMatrix (featureID) -> m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44
GetFeaturePieceMatrix (featureID) -> m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44[source]
Params
featureID: integerReturns
m11: number?m12: numberm13: numberm14: numberm21: numberm22: numberm23: numberm24: numberm31: numberm32: numberm33: numberm34: numberm41: numberm42: numberm43: numberm44: numberfn GetUnitScriptPiece (unitID) -> pieceIndices
GetUnitScriptPiece (unitID) -> pieceIndices[source]
Params
unitID: integerReturns
pieceIndices: integer[]fn GetUnitScriptPiece (unitID, scriptPiece) -> pieceIndex
GetUnitScriptPiece (unitID, scriptPiece) -> pieceIndex[source]
Params
unitID: integerscriptPiece: integerReturns
pieceIndex: integerfn GetUnitScriptNames (unitID) -> where
GetUnitScriptNames (unitID) -> where[source]
Params
unitID: integerReturns
where: table<string,number> --keys are piece names and values are piece indicesfn TraceRayGroundInDirection (posX, posY, posZ, dirX, dirY, dirZ, testWater) -> rayLength, posX, posY, posZ
TraceRayGroundInDirection (posX, posY, posZ, dirX, dirY, dirZ, testWater) -> rayLength, posX, posY, posZChecks 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: numberposY: numberposZ: numberdirX: numberdirY: numberdirZ: numbertestWater: boolean? --(Default: `true`)Returns
rayLength: numberposX: numberposY: numberposZ: numberfn TraceRayGroundBetweenPositions (startX, startY, startZ, endX, endY, endZ, testWater) -> rayLength, posX, posY, posZ
TraceRayGroundBetweenPositions (startX, startY, startZ, endX, endY, endZ, testWater) -> rayLength, posX, posY, posZChecks 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: numberstartY: numberstartZ: numberendX: numberendY: numberendZ: numbertestWater: boolean? --(Default: `true`)Returns
rayLength: numberposX: numberposY: numberposZ: numberfn GetRadarErrorParams (allyTeamID) -> radarErrorSize, baseRadarErrorSize, baseRadarErrorMult
GetRadarErrorParams (allyTeamID) -> radarErrorSize, baseRadarErrorSize, baseRadarErrorMult[source]
Params
allyTeamID: integerReturns
radarErrorSize: number? --actual radar error size (when allyTeamID is allied to current team) or base radar error sizebaseRadarErrorSize: numberbaseRadarErrorMult: numberfn Echo (arg, ...) ->
Echo (arg, ...) ->Prints values in the spring chat console. Useful for debugging.
Hint: the default print() writes to STDOUT.
[source]
Params
arg: any...: anyReturns
: nilfn CallAsTeam (teamID, func, ...) -> The
CallAsTeam (teamID, func, ...) -> TheCalls 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
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
SYNCEDis
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
tracyfn LuaTracyPlotConfig (plotName, plotFormatType, stepwise, fill, color)
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 customizeplotFormatType: (“Number”|“Percentage”|“Memory”)? --(Default: `"Number"`)stepwise: boolean? --(Default: `true`) stepwise chartfill: boolean? --(Default: `false`) whether to fill colorcolor: integer? --(Default: `0xFFFFFF`) uint32 number as BGR colorfn LuaTracyPlot (plotName, plotValue)
LuaTracyPlot (plotName, plotValue)Update a Tracy plot with a value
[source]
Params
plotName: string --Which LuaPlot should be updatedplotValue: number --the number to show on the Tracy plottable VFS
VFSUnified 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.mdlArchive 2 (base/springcontent.sdz)
textures
├── texture1.png
├── texture2.png
└── texture3.pngVFS
textures
├── texture1.png
├── texture2.png
└── texture3.png
models
└── model1.mdlThis 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:
- The automatic dependencies
springcontent.sdzandmaphelper.sdz. - Dependencies listed in your
modinfo.lua(ormodinfo.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. - 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.luaexplosions.luaexplosion_alias.luaicontypes.luamessages.luamodrules.luaresources.luaresources_map.luasidedata.luasounds.lualuagaia/main.luadraw.lualuarules/main.luadraw.lualuaui/main.luashaders/?luaai.luamapinfo.luamapoptions.luamodinfo.luamodoptions.luavalidmaps.lua
[source]
fn Include (filename, environment, mode) -> module
Include (filename, environment, mode) -> moduleLoads 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: stringenvironment: 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
LoadFile (filename, mode) -> dataLoad 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: stringmode: string?Returns
data: string? --The contents of the file.fn FileExists (filename, mode) -> exists
FileExists (filename, mode) -> existsCheck if file exists in VFS.
[source]
Example usage:
if VFS.FileExists("mapconfig/custom_lava_config.lua", VFS.MAP) then
# ...
endParams
filename: stringmode: string?Returns
exists: boolean --`true` if the file exists, otherwise `false`.fn DirList (directory, pattern, mode, recursive) -> filenames
DirList (directory, pattern, mode, recursive) -> filenamesList files in a directory.
[source]
Example usage:
local luaFiles = VFS.DirList('units/', '*.lua', nil, true)Params
directory: stringpattern: string? --(Default: `"*"`)mode: string?recursive: boolean? --(Default: `false`)Returns
filenames: string[]fn SubDirs (directory, pattern, mode, recursive) -> dirnames
SubDirs (directory, pattern, mode, recursive) -> dirnamesList sub-directories in a directory.
[source]
Example usage:
local files = VFS.SubDirs('sounds/voice/' .. language, '*')
for _, file in ipairs(files) do
# ...
endParams
directory: stringpattern: string? --(Default: `"*"`)mode: string?recursive: boolean? --(Default: `false`)Returns
dirnames: string[]fn GetFileAbsolutePath (filename, mode) -> absolutePath
GetFileAbsolutePath (filename, mode) -> absolutePath[source]
Params
filename: stringmode: string?Returns
absolutePath: string?fn GetArchiveContainingFile (filename, mode) -> archiveName
GetArchiveContainingFile (filename, mode) -> archiveName[source]
Params
filename: stringmode: string?Returns
archiveName: string?fn UseArchive (archiveName, fun) -> Results
UseArchive (archiveName, fun) -> ResultsTemporarily load an archive from the VFS and run the given function, which can make usage of the files in the archive.
[source]
Params
archiveName: stringfun: unknownReturns
Results: any … --of the given functionfn CompressFolder (folderPath, archiveType, compressedFilePath, includeFolder, mode)
CompressFolder (folderPath, archiveType, compressedFilePath, includeFolder, mode)Compresses the specified folder.
[source]
Params
folderPath: stringarchiveType: 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
ZlibCompress (uncompressed) -> compressed[source]
Params
uncompressed: string --Data to compress.Returns
compressed: string? --Compressed data, or `nil` on error.fn ZlibDecompress (compressed) -> uncompressed
ZlibDecompress (compressed) -> uncompressed[source]
Params
compressed: string --Data to decompress.Returns
uncompressed: string? --Uncompressed data, or `nil` on error.fn PackU8 (...) ->
PackU8 (...) ->Convert unsigned 8-bit integer(s) to binary string.
[source]
Params
...: integer --Numbers to pack.Returns
: stringfn PackU8 (numbers) ->
PackU8 (numbers) ->Convert unsigned 8-bit integer(s) to binary string.
[source]
Params
numbers: integer[] --Numbers to pack.Returns
: stringfn PackU16 (...) ->
PackU16 (...) ->Convert unsigned 16-bit integer(s) to binary string.
[source]
Params
...: integer --Numbers to pack.Returns
: stringfn PackU16 (numbers) ->
PackU16 (numbers) ->Convert unsigned 16-bit integer(s) to binary string.
[source]
Params
numbers: integer[] --Numbers to pack.Returns
: stringfn PackU32 (...) ->
PackU32 (...) ->Convert unsigned 32-bit integer(s) to binary string.
[source]
Params
...: integer --Numbers to pack.Returns
: stringfn PackU32 (numbers) ->
PackU32 (numbers) ->Convert unsigned 32-bit integer(s) to binary string.
[source]
Params
numbers: integer[] --Numbers to pack.Returns
: stringfn PackS8 (...) ->
PackS8 (...) ->Convert signed 8-bit integer(s) to binary string.
[source]
Params
...: integer --Numbers to pack.Returns
: stringfn PackS8 (numbers) ->
PackS8 (numbers) ->Convert signed 8-bit integer(s) to binary string.
[source]
Params
numbers: integer[] --Numbers to pack.Returns
: stringfn PackS16 (...) ->
PackS16 (...) ->Convert signed 16-bit integer(s) to binary string.
[source]
Params
...: integer --Numbers to pack.Returns
: stringfn PackS16 (numbers) ->
PackS16 (numbers) ->Convert signed 16-bit integer(s) to binary string.
[source]
Params
numbers: integer[] --Numbers to pack.Returns
: stringfn PackS32 (...) ->
PackS32 (...) ->Convert signed 32-bit integer(s) to binary string.
[source]
Params
...: integer --Numbers to pack.Returns
: stringfn PackS32 (numbers) ->
PackS32 (numbers) ->Convert signed 32-bit integer(s) to binary string.
[source]
Params
numbers: integer[] --Numbers to pack.Returns
: stringfn PackS32 (...) ->
PackS32 (...) ->Convert signed 32-bit float(s) to binary string.
[source]
Params
...: integer --Numbers to pack.Returns
: stringfn PackS32 (numbers) ->
PackS32 (numbers) ->Convert signed 32-bit float(s) to binary string.
[source]
Params
numbers: integer[] --Numbers to pack.Returns
: stringfn UnpackU8 (str, pos) ->
UnpackU8 (str, pos) ->Convert a binary string to an unsigned 8-bit integer.
[source]
Params
str: string --Binary string.pos: integer? --Byte offset.Returns
: integerfn UnpackU16 (str, pos) ->
UnpackU16 (str, pos) ->Convert a binary string to an unsigned 16-bit integer.
[source]
Params
str: string --Binary string.pos: integer? --Byte offset.Returns
: integerfn UnpackU32 (str, pos) ->
UnpackU32 (str, pos) ->Convert a binary string to an unsigned 32-bit integer.
[source]
Params
str: string --Binary string.pos: integer? --Byte offset.Returns
: integerfn UnpackS8 (str, pos) ->
UnpackS8 (str, pos) ->Convert a binary string to a signed 8-bit integer.
[source]
Params
str: string --Binary string.pos: integer? --Byte offset.Returns
: integerfn UnpackS16 (str, pos) ->
UnpackS16 (str, pos) ->Convert a binary string to a signed 16-bit integer.
[source]
Params
str: string --Binary string.pos: integer? --Byte offset.Returns
: integerfn UnpackS32 (str, pos) ->
UnpackS32 (str, pos) ->Convert a binary string to a signed 32-bit integer.
[source]
Params
str: string --Binary string.pos: integer? --Byte offset.Returns
: integerfn UnpackF32 (str, pos) ->
UnpackF32 (str, pos) ->Convert a binary string to a signed 32-bit float.
[source]
Params
str: string --Binary string.pos: integer? --Byte offset.Returns
: integerfn GetArchivePath (archiveName) -> archivePath
GetArchivePath (archiveName) -> archivePath[source]
Params
archiveName: stringReturns
archivePath: string?fn GetArchiveInfo (archiveName) -> archiveInfo
GetArchiveInfo (archiveName) -> archiveInfo[source]
Params
archiveName: stringReturns
archiveInfo: ArchiveInfo?fn GetArchiveDependencies (archiveName) -> archiveNames
GetArchiveDependencies (archiveName) -> archiveNames[source]
Params
archiveName: stringReturns
archiveNames: string[]fn GetArchiveReplaces (archiveName) -> archiveNames
GetArchiveReplaces (archiveName) -> archiveNames[source]
Params
archiveName: stringReturns
archiveNames: string[]fn GetArchiveChecksum (archiveName) -> singleArchiveChecksum, completeArchiveChecksum
GetArchiveChecksum (archiveName) -> singleArchiveChecksum, completeArchiveChecksum[source]
Params
archiveName: stringReturns
singleArchiveChecksum: stringcompleteArchiveChecksum: stringfn GetNameFromRapidTag (rapidTag) -> archiveName
GetNameFromRapidTag (rapidTag) -> archiveName[source]
Params
rapidTag: stringReturns
archiveName: stringTypes
alias Attachment
Attachmentis
(“depth”|“stencil”|“color0”|“color1”|“color2”|“color3”|“color4”|“color5”|“color6”|“color7”|“color8”|“color9”|“color10”|“color11”|“color12”|“color13”|“color14”|“color15”)[source]
class Callins
Callins[source]
See: Gadget Widget Menu Intro SyncedCallins UnsyncedCallins
method GotChatMsg (msg, playerID)
GotChatMsg (msg, playerID)Called when a player issues a UI command e.g. types /foo or /luarules foo.
[source]
Params
msg: stringplayerID: integermethod Load (zipReader)
Load (zipReader)Called after GamePreload and before GameStart. See Lua_SaveLoad.
[source]
Params
zipReader: tablemethod GamePreload ()
GamePreload ()Called before the 0 gameframe.
Is not called when a saved game is loaded.
[source]
method GameStart ()
GameStart ()Called upon the start of the game.
[source]
Is not called when a saved game is loaded.
method GameOver (winningAllyTeams)
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)
GamePaused (playerID, paused)Called when the game is paused.
[source]
Params
playerID: integerpaused: booleanmethod GameFrame (frame)
GameFrame (frame)Called for every game simulation frame (30 per second).
[source]
Params
frame: number --Starts at frame 1method GameFramePost (frame)
GameFramePost (frame)Called at the end of every game simulation frame
[source]
Params
frame: number --Starts at frame 1method GameID (gameID)
GameID (gameID)Called once to deliver the gameID
[source]
Params
gameID: string --encoded in hex.method PlayerChanged (playerID)
PlayerChanged (playerID)Called whenever a player’s status changes e.g. becoming a spectator.
[source]
Params
playerID: integermethod PlayerAdded (playerID)
PlayerAdded (playerID)Called whenever a new player joins the game.
[source]
Params
playerID: integermethod PlayerRemoved (playerID, reason)
PlayerRemoved (playerID, reason)Called whenever a player is removed from the game.
[source]
Params
playerID: integerreason: stringmethod UnitCreated (unitID, unitDefID, unitTeam, builderID)
UnitCreated (unitID, unitDefID, unitTeam, builderID)Called at the moment the unit is created.
[source]
Params
unitID: integerunitDefID: integerunitTeam: integerbuilderID: integer?method UnitFinished (unitID, unitDefID, unitTeam)
UnitFinished (unitID, unitDefID, unitTeam)Called at the moment the unit is completed.
[source]
Params
unitID: integerunitDefID: integerunitTeam: integermethod UnitFromFactory (unitID, unitDefID, unitTeam, factID, factDefID, userOrders)
UnitFromFactory (unitID, unitDefID, unitTeam, factID, factDefID, userOrders)Called when a factory finishes construction of a unit.
[source]
Params
unitID: integerunitDefID: integerunitTeam: integerfactID: integerfactDefID: integeruserOrders: booleanmethod UnitReverseBuilt (unitID, unitDefID, unitTeam)
UnitReverseBuilt (unitID, unitDefID, unitTeam)Called when a living unit becomes a nanoframe again.
[source]
Params
unitID: integerunitDefID: integerunitTeam: integermethod UnitConstructionDecayed (unitID, unitDefID, unitTeam, timeSinceLastBuild, iterationPeriod, part)
UnitConstructionDecayed (unitID, unitDefID, unitTeam, timeSinceLastBuild, iterationPeriod, part)Called when a unit being built starts decaying.
[source]
Params
unitID: integerunitDefID: integerunitTeam: integertimeSinceLastBuild: numberiterationPeriod: numberpart: numbermethod UnitDestroyed (unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam, weaponDefID)
UnitDestroyed (unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam, weaponDefID)Called when a unit is destroyed.
[source]
Params
unitID: integerunitDefID: integerunitTeam: integerattackerID: integerattackerDefID: integerattackerTeam: numberweaponDefID: integermethod UnitTaken (unitID, unitDefID, oldTeam, newTeam)
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: integerunitDefID: integeroldTeam: numbernewTeam: numbermethod UnitGiven (unitID, unitDefID, newTeam, oldTeam)
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: integerunitDefID: integernewTeam: numberoldTeam: numbermethod UnitIdle (unitID, unitDefID, unitTeam)
UnitIdle (unitID, unitDefID, unitTeam)Called when a unit is idle (empty command queue).
[source]
Params
unitID: integerunitDefID: integerunitTeam: integermethod UnitCommand (unitID, unitDefID, unitTeam, cmdID, cmdParams, options, cmdTag)
UnitCommand (unitID, unitDefID, unitTeam, cmdID, cmdParams, options, cmdTag)Called after when a unit accepts a command, after AllowCommand returns true.
[source]
Params
unitID: integerunitDefID: integerunitTeam: integercmdID: integercmdParams: tableoptions: CommandOptionscmdTag: numbermethod UnitCmdDone (unitID, unitDefID, unitTeam, cmdID, cmdParams, options, cmdTag)
UnitCmdDone (unitID, unitDefID, unitTeam, cmdID, cmdParams, options, cmdTag)Called when a unit completes a command.
[source]
Params
unitID: integerunitDefID: integerunitTeam: integercmdID: integercmdParams: tableoptions: CommandOptionscmdTag: numbermethod UnitDamaged (unitID, unitDefID, unitTeam, damage, paralyzer, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam)
UnitDamaged (unitID, unitDefID, unitTeam, damage, paralyzer, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam)Called when a unit is damaged (after UnitPreDamaged).
[source]
Params
unitID: integerunitDefID: integerunitTeam: integerdamage: numberparalyzer: numberweaponDefID: integerprojectileID: integerattackerID: integerattackerDefID: integerattackerTeam: numbermethod UnitStunned (unitID, unitDefID, unitTeam, stunned)
UnitStunned (unitID, unitDefID, unitTeam, stunned)Called when a unit changes its stun status.
[source]
Params
unitID: integerunitDefID: integerunitTeam: integerstunned: booleanmethod UnitExperience (unitID, unitDefID, unitTeam, experience, oldExperience)
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: integerunitDefID: integerunitTeam: integerexperience: numberoldExperience: numbermethod UnitHarvestStorageFull (unitID, unitDefID, unitTeam)
UnitHarvestStorageFull (unitID, unitDefID, unitTeam)Called when a unit’s harvestStorage is full (according to its unitDef’s entry).
[source]
Params
unitID: integerunitDefID: integerunitTeam: integermethod UnitSeismicPing (x, y, z, strength, allyTeam, unitID, unitDefID)
UnitSeismicPing (x, y, z, strength, allyTeam, unitID, unitDefID)Called when a unit emits a seismic ping.
[source]
See seismicSignature.
Params
x: numbery: numberz: numberstrength: numberallyTeam: integerunitID: integerunitDefID: integermethod UnitEnteredRadar (unitID, unitTeam, allyTeam, unitDefID)
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: integerunitTeam: integerallyTeam: integerunitDefID: integermethod UnitEnteredLos (unitID, unitTeam, allyTeam, unitDefID)
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: integerunitTeam: integerallyTeam: integer --who's LOS the unit entered.unitDefID: integermethod UnitLeftRadar (unitID, unitTeam, allyTeam, unitDefID)
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: integerunitTeam: integerallyTeam: integerunitDefID: integermethod UnitLeftLos (unitID, unitTeam, allyTeam, unitDefID)
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: integerunitTeam: integerallyTeam: integerunitDefID: integermethod UnitLoaded (unitID, unitDefID, unitTeam, transportID, transportTeam)
UnitLoaded (unitID, unitDefID, unitTeam, transportID, transportTeam)Called when a unit is loaded by a transport.
[source]
Params
unitID: integerunitDefID: integerunitTeam: integertransportID: integertransportTeam: integermethod UnitUnloaded (unitID, unitDefID, unitTeam, transportID, transportTeam)
UnitUnloaded (unitID, unitDefID, unitTeam, transportID, transportTeam)Called when a unit is unloaded by a transport.
[source]
Params
unitID: integerunitDefID: integerunitTeam: integertransportID: integertransportTeam: integermethod UnitEnteredUnderwater (unitID, unitDefID, unitTeam)
UnitEnteredUnderwater (unitID, unitDefID, unitTeam)[source]
Params
unitID: integerunitDefID: integerunitTeam: integermethod UnitEnteredWater (unitID, unitDefID, unitTeam)
UnitEnteredWater (unitID, unitDefID, unitTeam)[source]
Params
unitID: integerunitDefID: integerunitTeam: integermethod UnitLeftAir (unitID, unitDefID, unitTeam)
UnitLeftAir (unitID, unitDefID, unitTeam)[source]
Params
unitID: integerunitDefID: integerunitTeam: integermethod UnitLeftUnderwater (unitID, unitDefID, unitTeam)
UnitLeftUnderwater (unitID, unitDefID, unitTeam)[source]
Params
unitID: integerunitDefID: integerunitTeam: integermethod UnitLeftWater (unitID, unitDefID, unitTeam)
UnitLeftWater (unitID, unitDefID, unitTeam)[source]
Params
unitID: integerunitDefID: integerunitTeam: integermethod UnitEnteredAir (unitID, unitDefID, unitTeam)
UnitEnteredAir (unitID, unitDefID, unitTeam)[source]
Params
unitID: integerunitDefID: integerunitTeam: integermethod UnitCloaked (unitID, unitDefID, unitTeam)
UnitCloaked (unitID, unitDefID, unitTeam)Called when a unit cloaks.
[source]
Params
unitID: integerunitDefID: integerunitTeam: integermethod UnitDecloaked (unitID, unitDefID, unitTeam)
UnitDecloaked (unitID, unitDefID, unitTeam)Called when a unit decloaks.
[source]
Params
unitID: integerunitDefID: integerunitTeam: integermethod UnitUnitCollision (colliderID, collideeID)
UnitUnitCollision (colliderID, collideeID)Called when two units collide.
Both units must be registered with Script.SetWatchUnit.
[source]
Params
colliderID: integercollideeID: integermethod UnitFeatureCollision (colliderID, collideeID)
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: integercollideeID: integermethod UnitMoveFailed (unitID, unitDefID, unitTeam)
UnitMoveFailed (unitID, unitDefID, unitTeam)[source]
Params
unitID: integerunitDefID: integerunitTeam: integermethod UnitArrivedAtGoal (unitID, unitDefID, unitTeam)
UnitArrivedAtGoal (unitID, unitDefID, unitTeam)[source]
Params
unitID: integerunitDefID: integerunitTeam: integermethod RenderUnitDestroyed (unitID, unitDefID, unitTeam)
RenderUnitDestroyed (unitID, unitDefID, unitTeam)Called just before a unit is invalid, after it finishes its death animation.
[source]
Params
unitID: integerunitDefID: integerunitTeam: integermethod FeatureCreated (featureID, allyTeamID)
FeatureCreated (featureID, allyTeamID)Called when a feature is created.
[source]
Params
featureID: integerallyTeamID: integermethod FeatureDestroyed (featureID, allyTeamID)
FeatureDestroyed (featureID, allyTeamID)Called when a feature is destroyed.
[source]
Params
featureID: integerallyTeamID: integermethod FeatureDamaged (featureID, featureDefID, featureTeam, damage, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam)
FeatureDamaged (featureID, featureDefID, featureTeam, damage, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam)Called when a feature is damaged.
[source]
Params
featureID: integerfeatureDefID: integerfeatureTeam: numberdamage: numberweaponDefID: integerprojectileID: integerattackerID: integerattackerDefID: integerattackerTeam: numbermethod ProjectileCreated (proID, proOwnerID, weaponDefID)
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: integerproOwnerID: integerweaponDefID: integermethod ProjectileDestroyed (proID, ownerID, proWeaponDefID)
ProjectileDestroyed (proID, ownerID, proWeaponDefID)Called when the projectile is destroyed.
[source]
See: Script.SetWatchProjectile Script.SetWatchWeapon
Params
proID: integerownerID: integerproWeaponDefID: integermethod Explosion (weaponDefID, px, py, pz, attackerID, projectileID) -> noGfx
Explosion (weaponDefID, px, py, pz, attackerID, projectileID) -> noGfxCalled when an explosion occurs.
[source]
Only called for weaponDefIDs registered via Script.SetWatchExplosion or Script.SetWatchWeapon.
See: Script.SetWatchExplosion Script.SetWatchWeapon
Params
weaponDefID: integerpx: numberpy: numberpz: numberattackerID: integerprojectileID: integerReturns
noGfx: boolean --if then no graphical effects are drawn by the engine for this explosion.method StockpileChanged (unitID, unitDefID, unitTeam, weaponNum, oldCount, newCount)
StockpileChanged (unitID, unitDefID, unitTeam, weaponNum, oldCount, newCount)Called when a units stockpile of weapons increases or decreases.
[source]
Params
unitID: integerunitDefID: integerunitTeam: integerweaponNum: integeroldCount: integernewCount: integermethod RecvLuaMsg (msg, playerID)
RecvLuaMsg (msg, playerID)Receives messages from unsynced sent via Spring.SendLuaRulesMsg or Spring.SendLuaUIMsg.
[source]
Params
msg: stringplayerID: integermethod Save (zip)
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
UnsyncedHeightMapUpdate () -> x1, z1, x2, z2Called when the unsynced copy of the height-map is altered.
[source]
Returns
x1: numberz1: numberx2: numberz2: numbermethod Update (dt)
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)
ViewResize (viewSizeX, viewSizeY)Called whenever the window is resized.
[source]
Params
viewSizeX: numberviewSizeY: numbermethod FontsChanged ()
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 DefaultCommand (type, id)
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 ()
DrawGenesis ()Use this callin to update textures, shaders, etc.
[source]
Doesn’t render to screen! Also available to LuaMenu.
method DrawWorldPreUnit ()
DrawWorldPreUnit ()Spring draws units, features, some water types, cloaked units, and the sun.
[source]
method DrawShadowPassTransparent ()
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 DrawGroundPreForward ()
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 DrawGroundPreDeferred ()
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 DrawGroundPostDeferred ()
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 ()
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 ()
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 DrawWorldPreParticles (drawAboveWater, drawBelowWater, drawReflection, drawRefraction)
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: booleandrawBelowWater: booleandrawReflection: booleandrawRefraction: booleanmethod DrawScreen (viewSizeX, viewSizeY)
DrawScreen (viewSizeX, viewSizeY)Also available to LuaMenu.
[source]
Params
viewSizeX: numberviewSizeY: numbermethod DrawScreenPost (viewSizeX, viewSizeY)
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: numberviewSizeY: numbermethod DrawInMiniMap (sx, sy)
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)
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)
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: integermethod KeyMapChanged ()
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
KeyPress (keyCode, mods, isRepeat, label, utf32char, scanCode, actionList) -> haltCalled 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: numbermods: KeyModifiersisRepeat: boolean --If you want an action to occur only once check for isRepeat == false.label: boolean --the name of the keyutf32char: number --(deprecated) always 0scanCode: numberactionList: table --the list of actions for this keypressReturns
halt: boolean --whether to halt the chain for consumers of the keypressmethod KeyRelease (keyCode, mods, label, utf32char, scanCode, actionList) ->
KeyRelease (keyCode, mods, label, utf32char, scanCode, actionList) ->Called when the key is released.
[source]
Params
keyCode: numbermods: KeyModifierslabel: boolean --the name of the keyutf32char: number --(deprecated) always 0scanCode: numberactionList: table --the list of actions for this keyreleaseReturns
: booleanmethod TextInput (utf8char)
TextInput (utf8char)Called whenever a key press results in text input.
[source]
Params
utf8char: stringmethod MousePress (x, y, button) -> becomeMouseOwner
MousePress (x, y, button) -> becomeMouseOwnerCalled 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: numbery: numberbutton: numberReturns
becomeMouseOwner: booleanmethod MouseRelease (x, y, button) -> becomeMouseOwner
MouseRelease (x, y, button) -> becomeMouseOwnerCalled 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: numbery: numberbutton: numberReturns
becomeMouseOwner: booleanmethod MouseMove (x, y, dx, dy, button)
MouseMove (x, y, dx, dy, button)Called when the mouse is moved.
[source]
Params
x: number --final x positiony: number --final y positiondx: number --distance travelled in xdy: number --distance travelled in ybutton: numbermethod MouseWheel (up, value)
MouseWheel (up, value)Called when the mouse wheel is moved.
[source]
Params
up: boolean --the directionvalue: number --the amount travelledmethod IsAbove (x, y) -> isAbove
IsAbove (x, y) -> isAboveCalled every Update.
[source]
Must return true for Mouse* events and Spring.GetToolTip to be called.
Params
x: numbery: numberReturns
isAbove: booleanmethod GetTooltip (x, y) -> tooltip
GetTooltip (x, y) -> tooltipCalled when Spring.IsAbove returns true.
[source]
Params
x: numbery: numberReturns
tooltip: stringmethod ActiveCommandChanged (cmdId, cmdType)
ActiveCommandChanged (cmdId, cmdType)Called when a command is issued.
[source]
Params
cmdId: integer?cmdType: integer?method CameraRotationChanged (rotX, rotY, rotZ)
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)
CameraPositionChanged (posX, posY, posZ)Called whenever the camera position changes
[source]
Params
posX: number --Camera position x in world coordinatesposY: number --Camera position y in world coordinatesposZ: number --Camera position z in world coordinatesmethod CommandNotify (cmdID, cmdParams, options) -> Returning
CommandNotify (cmdID, cmdParams, options) -> ReturningCalled when a command is issued.
[source]
Params
cmdID: integercmdParams: tableoptions: CommandOptionsReturns
Returning: boolean --true deletes the command and does not send it through the network.method AddConsoleLine (msg, priority)
AddConsoleLine (msg, priority)Called when text is entered into the console (e.g. Spring.Echo).
[source]
Params
msg: stringpriority: integermethod GroupChanged (groupID)
GroupChanged (groupID)Called when a unit is added to or removed from a control group.
[source]
Params
groupID: integermethod WorldTooltip (type, unitId) -> tooltip
WorldTooltip (type, unitId) -> tooltip[source]
Params
type: “unit”unitId: integerReturns
tooltip: stringmethod WorldTooltip (type, featureId) -> tooltip
WorldTooltip (type, featureId) -> tooltip[source]
Params
type: “feature”featureId: integerReturns
tooltip: stringmethod WorldTooltip (type, posX, posY, posZ) -> tooltip
WorldTooltip (type, posX, posY, posZ) -> tooltip[source]
Params
type: “ground”posX: numberposY: numberposZ: numberReturns
tooltip: stringmethod MapDrawCmd (playerID, type, posX, posY, posZ, label)
MapDrawCmd (playerID, type, posX, posY, posZ, label)[source]
Params
playerID: integertype: “point”posX: numberposY: numberposZ: numberlabel: stringmethod MapDrawCmd (playerID, type, pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z)
MapDrawCmd (playerID, type, pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z)[source]
Params
playerID: integertype: “line”pos1X: numberpos1Y: numberpos1Z: numberpos2X: numberpos2Y: numberpos2Z: numbermethod MapDrawCmd (playerID, type, posX, posY, posZ, radius)
MapDrawCmd (playerID, type, posX, posY, posZ, radius)[source]
Params
playerID: integertype: “erase”posX: numberposY: numberposZ: numberradius: numbermethod GameSetup (state, ready, playerStates) -> gameHandled, newReady
GameSetup (state, ready, playerStates) -> gameHandled, newReadyFired 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 playerready: boolean --whether the player is currently ready or notplayerStates: table<number,READY_STATE> --indexed by playerIDReturns
gameHandled: boolean? --disables the engine ui when truenewReady: boolean? --whether the player is ready (ignored unless `gameHandled = true`)method DownloadQueued (id, name, type)
DownloadQueued (id, name, type)Called when a Pr-downloader download is queued
[source]
Params
id: integername: stringtype: stringmethod DownloadStarted (id)
DownloadStarted (id)Called when a Pr-downloader download is started via VFS.DownloadArchive.
[source]
Params
id: integermethod DownloadFinished (id)
DownloadFinished (id)Called when a Pr-downloader download finishes successfully.
[source]
Params
id: integermethod DownloadFailed (id, errorID)
DownloadFailed (id, errorID)Called when a Pr-downloader download fails to complete.
[source]
Params
id: integererrorID: integermethod DownloadProgress (id, downloaded, total)
DownloadProgress (id, downloaded, total)Called incrementally during a Pr-downloader download.
[source]
Params
id: integerdownloaded: integertotal: integerenum CMD
CMDCommand 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 STOP
STOPis
integerStop 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 REMOVE
REMOVEis
integerRemove 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
altTag/Id switchctrlAlternative 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
WAITis
integerMakes the unit suspend processing its command queue until wait is removed.
Accepts no parameters.
[source]
field TIMEWAIT
TIMEWAITis
integerMakes the unit suspend processing its command queue for a given duration.
params{duration} Time to wait in seconds.
[source]
field DEATHWAIT
DEATHWAITis
integerMakes 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
SQUADWAITis
integerMakes 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
GATHERWAITis
integerMakes 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 ATTACK
ATTACKis
integerAttack 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
altAlso target stunned targets. Without this stunned targets will be skipped.metaOverridemanualFire, andnoAutoTargetweapon 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]
enum CMDTYPE
CMDTYPECommand type constants
Note, the CMDTYPE[] table is bidirectional. That means: CMDTYPE[CMDTYPE.ICON] := "CMDTYPE_ICON"
[source]
field ICON_UNIT_OR_MAP
ICON_UNIT_OR_MAPis
integerExpect 1 parameters in return (unitid) or 3 parameters in return (mappos).
[source]
field ICON_FRONT
ICON_FRONTis
integerExpect 3 or 6 parameters in return (middle and right side of front if a front was defined).
[source]
field ICON_UNIT_OR_AREA
ICON_UNIT_OR_AREAis
integerExpect 1 parameter in return (unitid) or 4 parameters in return (mappos+radius).
[source]
field ICON_UNIT_FEATURE_OR_AREA
ICON_UNIT_FEATURE_OR_AREAis
integerExpect 1 parameter in return (unitid or Game.maxUnits+featureid) or 4 parameters in return (mappos+radius).
[source]
field ICON_UNIT_OR_RECTANGLE
ICON_UNIT_OR_RECTANGLEis
integerExpect 1 parameter in return (unitid) or 3 parameters in return (mappos) or 6 parameters in return (startpos+endpos).
[source]
class CommandOptions
CommandOptionsFull 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]
alias CreateCommandOptions
CreateCommandOptionsis
(CommandOptionName[]|table<CommandOptionName,boolean>|CommandOptionBit|integer)[source]
class ExplosionParams
ExplosionParamsParameters 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]
enum GL
GLConstants for OpenGL API
For callouts related to OpenGL usage in Recoil, see gl.
[source]
See: gl
alias Heading
Headingis
integerInteger 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 losAccess
losAccessParameters 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]
class LuaFont
LuaFontLua opengl font object.
[source]
See: gl.LoadFont
method Begin (userDefinedBlending)
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)
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`.alias MatrixName
MatrixNameis
(“view”|“projection”|“viewprojection”|“viewinverse”|“projectioninverse”|“viewprojectioninverse”|“billboard”|“shadow”|“camera”|“camprj”|“caminv”|“camprjinv”)[source]
class MoveCtrl
MoveCtrlAccessed via Spring.MoveCtrl.
[source]
fn SetProgressState (unitID, state)
SetProgressState (unitID, state)[source]
Params
unitID: integerstate: (0|1|2|“done”|“active”|“failed”)fn SetPhysics (unitID, posX, posY, posZ, velX, velY, velZ, rotX, rotY, rotZ)
SetPhysics (unitID, posX, posY, posZ, velX, velY, velZ, rotX, rotY, rotZ)[source]
Params
unitID: integerposX: 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)
SetPosition (unitID, posX, posY, posZ)[source]
Params
unitID: integerposX: number --Position X component.posY: number --Position Y component.posZ: number --Position Z component.fn SetVelocity (unitID, velX, velY, velZ)
SetVelocity (unitID, velX, velY, velZ)[source]
Params
unitID: integervelX: number --Velocity X component.velY: number --Velocity Y component.velZ: number --Velocity Z component.fn SetRelativeVelocity (unitID, relVelX, relVelY, relVelZ)
SetRelativeVelocity (unitID, relVelX, relVelY, relVelZ)[source]
Params
unitID: integerrelVelX: number --Relative velocity X component.relVelY: number --Relative velocity Y component.relVelZ: number --Relative velocity Z component.fn SetRotation (unitID, rotX, rotY, rotZ)
SetRotation (unitID, rotX, rotY, rotZ)[source]
Params
unitID: integerrotX: number --Rotation X component.rotY: number --Rotation Y component.rotZ: number --Rotation Z component.fn SetRotationVelocity (unitID, rotVelX, rotVelY, rotVelZ)
SetRotationVelocity (unitID, rotVelX, rotVelY, rotVelZ)[source]
Params
unitID: integerrotVelX: number --Rotation velocity X component.rotVelY: number --Rotation velocity Y component.rotVelZ: number --Rotation velocity Z component.fn SetLimits (unitID, minX, minY, minZ, maxX, maxY, maxZ)
SetLimits (unitID, minX, minY, minZ, maxX, maxY, maxZ)[source]
Params
unitID: integerminX: 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 SetGunshipMoveTypeData (unitID, moveType) -> numAssignedValues
SetGunshipMoveTypeData (unitID, moveType) -> numAssignedValues[source]
Params
unitID: integermoveType: HoverAirMoveTypeReturns
numAssignedValues: numberfn SetGunshipMoveTypeData (unitID, key, value) -> numAssignedValues
SetGunshipMoveTypeData (unitID, key, value) -> numAssignedValues[source]
Params
unitID: integerkey: (GenericMoveTypeBooleanKey|“collide”|“dontLand”|“airStrafe”|“useSmoothMesh”|“bankingAllowed”)value: booleanReturns
numAssignedValues: numberfn SetGunshipMoveTypeData (unitID, key, value) -> numAssignedValues
SetGunshipMoveTypeData (unitID, key, value) -> numAssignedValues[source]
Params
unitID: integerkey: (GenericMoveTypeNumberKey|“wantedHeight”|“accRate”|“decRate”|“turnRate”|“altitudeRate”|“currentBank”|“currentPitch”…)value: numberReturns
numAssignedValues: numberfn SetAirMoveTypeData (unitID, moveType) -> numAssignedValues
SetAirMoveTypeData (unitID, moveType) -> numAssignedValues[source]
Params
unitID: integermoveType: StrafeAirMoveTypeReturns
numAssignedValues: numberfn SetAirMoveTypeData (unitID, key, value) -> numAssignedValues
SetAirMoveTypeData (unitID, key, value) -> numAssignedValues[source]
Params
unitID: integerkey: (GenericMoveTypeBooleanKey|“collide”|“useSmoothMesh”|“loopbackAttack”)value: booleanReturns
numAssignedValues: numberfn SetAirMoveTypeData (unitID, key, value) -> numAssignedValues
SetAirMoveTypeData (unitID, key, value) -> numAssignedValues[source]
Params
unitID: integerkey: (GenericMoveTypeNumberKey|“wantedHeight”|“turnRadius”|“accRate”|“decRate”|“maxAcc”|“maxDec”|“maxBank”…)value: numberReturns
numAssignedValues: numberfn SetAirMoveTypeData (unitID, key, value) -> numAssignedValues
SetAirMoveTypeData (unitID, key, value) -> numAssignedValues[source]
Params
unitID: integerkey: (“maneuverBlockTime”)value: integerReturns
numAssignedValues: numberfn SetGroundMoveTypeData (unitID, moveType) -> numAssignedValues
SetGroundMoveTypeData (unitID, moveType) -> numAssignedValues[source]
Params
unitID: integermoveType: GroundMoveTypeReturns
numAssignedValues: numberfn SetGroundMoveTypeData (unitID, key, value) -> numAssignedValues
SetGroundMoveTypeData (unitID, key, value) -> numAssignedValues[source]
Params
unitID: integerkey: (GenericMoveTypeBooleanKey|“atGoal”|“atEndOfPath”|“pushResistant”)value: booleanReturns
numAssignedValues: numberfn SetGroundMoveTypeData (unitID, key, value) -> numAssignedValues
SetGroundMoveTypeData (unitID, key, value) -> numAssignedValues[source]
Params
unitID: integerkey: (GenericMoveTypeNumberKey|“turnRate”|“turnAccel”|“accRate”|“decRate”|“myGravity”|“maxReverseDist”|“minReverseAngle”…)value: numberReturns
numAssignedValues: numberfn SetGroundMoveTypeData (unitID, key, value) -> numAssignedValues
SetGroundMoveTypeData (unitID, key, value) -> numAssignedValues[source]
Params
unitID: integerkey: (“minScriptChangeHeading”)value: integerReturns
numAssignedValues: numberfn SetMoveDef (unitID, moveDef) -> success
SetMoveDef (unitID, moveDef) -> success[source]
Params
unitID: integermoveDef: (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 RmlUi.Context
RmlUi.ContextHolds 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)
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: stringscript: RmlUi.Elementelement_context: booleanin_capture_phase: booleanmethod CreateDocument (tag) ->
CreateDocument (tag) ->Creates a new document with the tag name of tag.
[source]
Params
tag: stringReturns
: RmlUi.Documentmethod LoadDocument (document_path) ->
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: stringReturns
: RmlUi.Documentmethod UnloadDocument (document)
UnloadDocument (document)Unloads a specific document within the context.
[source]
Params
document: RmlUi.Documentmethod OpenDataModel (name, model, widget) ->
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: stringmodel: Twidget: tableReturns
: RmlUi.SolLuaDataModelmethod ProcessMouseMove (position) ->
ProcessMouseMove (position) ->Processes a mouse move event.
[source]
Params
position: RmlUi.Vector2fReturns
: booleanmethod ProcessMouseButtonDown (button, key_modifier_state) ->
ProcessMouseButtonDown (button, key_modifier_state) ->Processes a mouse button down event.
[source]
Params
button: RmlUi.MouseButtonkey_modifier_state: integerReturns
: booleanmethod ProcessMouseButtonUp (button, key_modifier_state) ->
ProcessMouseButtonUp (button, key_modifier_state) ->Processes a mouse button up event.
[source]
Params
button: RmlUi.MouseButtonkey_modifier_state: integerReturns
: booleanmethod ProcessMouseWheel (delta, key_modifier_state) ->
ProcessMouseWheel (delta, key_modifier_state) ->Processes a mouse wheel event.
[source]
Params
delta: (RmlUi.Vector2f|number)key_modifier_state: integerReturns
: booleanmethod IsMouseInteracting () ->
IsMouseInteracting () ->Returns true if the mouse is currently interacting with the context, false if not.
[source]
Returns
: booleanmethod ProcessKeyDown (key, key_modifier_state) ->
ProcessKeyDown (key, key_modifier_state) ->Processes a key down event.
[source]
Params
key: RmlUi.key_identifierkey_modifier_state: integerReturns
: booleanmethod ProcessKeyUp (key, key_modifier_state) ->
ProcessKeyUp (key, key_modifier_state) ->Processes a key up event.
[source]
Params
key: RmlUi.key_identifierkey_modifier_state: integerReturns
: booleanmethod ProcessTextInput (text) ->
ProcessTextInput (text) ->Processes a text input event.
[source]
Params
text: stringReturns
: booleanmethod EnableMouseCursor (enable)
EnableMouseCursor (enable)Enables or disables the mouse cursor for the context.
[source]
Params
enable: booleanmethod ActivateTheme (theme_name, activate)
ActivateTheme (theme_name, activate)Activates a theme for the context.
[source]
Params
theme_name: stringactivate: booleanmethod IsThemeActive (theme_name) ->
IsThemeActive (theme_name) ->Returns true if the theme is active, false if not.
[source]
Params
theme_name: stringReturns
: booleanmethod GetElementAtPoint (point, ignore) ->
GetElementAtPoint (point, ignore) ->Returns the element at the point specified by point.
[source]
Params
point: RmlUi.Vector2fignore: RmlUi.Element?Returns
: RmlUi.Elementmethod PullDocumentToFront (document)
PullDocumentToFront (document)Pulls the document to the front of the context.
[source]
Params
document: RmlUi.Documentmethod PushDocumentToBack (document)
PushDocumentToBack (document)Pushes the document to the back of the context.
[source]
Params
document: RmlUi.Documentclass RmlUi.Document
RmlUi.Documentinherits 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 ()
PullToFront ()Pulls the document in front of other documents within its context with a similar z-index.
[source]
method PushToBack ()
PushToBack ()Pushes the document behind other documents within its context with a similar z-index.
[source]
method Show (modal, focus)
Show (modal, focus)Shows the document.
[source]
Params
modal: RmlUi.RmlModalFlag? --Defaults to Focusfocus: RmlUi.RmlFocusFlag?method CreateElement (tag_name) ->
CreateElement (tag_name) ->Instances an element with a tag of tag_name.
[source]
Params
tag_name: stringReturns
: RmlUi.ElementPtrmethod CreateTextNode (text) ->
CreateTextNode (text) ->Instances a text element containing the string text.
[source]
Params
text: stringReturns
: RmlUi.ElementPtrmethod LoadInlineScript (content, source, source_line)
LoadInlineScript (content, source, source_line)Load scripts as if it were in the script tag.
[source]
Params
content: stringsource: string?source_line: integer?field widget
widgetis
table[source] A table of data that can be accessed in onevent attributes. It doesn’t have to be a widget.
class RmlUi.Element
RmlUi.ElementRepresents 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)
AddEventListener (event, listener, in_capture_phase)Adds an event listener to the element.
[source]
Params
event: stringlistener: (function|string)in_capture_phase: booleanmethod AppendChild (element) ->
AppendChild (element) ->Appends element as a child to this element.
[source]
Params
element: RmlUi.ElementPtrReturns
: RmlUi.ElementPtrmethod DispatchEvent (event, parameters, interruptible) ->
DispatchEvent (event, parameters, interruptible) ->Dispatches an event to this element.
[source]
Params
event: stringparameters: tableinterruptible: stringReturns
: booleanmethod GetAttribute (name) ->
GetAttribute (name) ->Returns the value of the attribute named name. If no such attribute exists, the empty string will be returned.
[source]
Params
name: stringReturns
: anymethod GetElementById (id) ->
GetElementById (id) ->Returns the descendant element with an id of id.
[source]
Params
id: stringReturns
: RmlUi.Elementmethod GetElementsByTagName (tag_name) ->
GetElementsByTagName (tag_name) ->Returns a list of all descendant elements with the tag of tag_name.
[source]
Params
tag_name: stringReturns
: RmlUi.ElementPtr[]method QuerySelector (query) ->
QuerySelector (query) ->Unsure what this does, but seems powerful?
[source]
Params
query: stringReturns
: RmlUi.ElementPtrmethod QuerySelectorAll (selectors)
QuerySelectorAll (selectors)Unsure what this does, but seems powerful?
[source]
Params
selectors: stringmethod HasAttribute (name) ->
HasAttribute (name) ->Returns True if the element has a value for the attribute named name, False if not.
[source]
Params
name: stringReturns
: booleanmethod HasChildNodes () ->
HasChildNodes () ->Returns True if the element has at least one child node, false if not.
[source]
Returns
: booleanmethod InsertBefore (element, adjacent_element) ->
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.ElementPtradjacent_element: RmlUi.ElementReturns
: RmlUi.Element?method IsClassSet (name) ->
IsClassSet (name) ->Returns true if the class name is set on the element, false if not.
[source]
Params
name: stringReturns
: booleanmethod RemoveAttribute (name)
RemoveAttribute (name)Removes the attribute named name from the element.
[source]
Params
name: stringmethod RemoveChild (element) ->
RemoveChild (element) ->Removes the child element element from this element.
[source]
Params
element: RmlUi.ElementReturns
: booleanmethod ReplaceChild (inserted_element, replaced_element) ->
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.ElementPtrreplaced_element: RmlUi.ElementReturns
: booleanmethod ScrollIntoView (align_with_top)
ScrollIntoView (align_with_top)Scrolls this element into view if its ancestors have hidden overflow.
[source]
Params
align_with_top: booleanmethod SetAttribute (name, value)
SetAttribute (name, value)Sets the value of the attribute named name to value.
[source]
Params
name: stringvalue: stringmethod SetClass (name, value)
SetClass (name, value)Sets (if value is true) or clears (if value is false) the class name on the element.
[source]
Params
name: stringvalue: booleanmethod GetElementsByClassName (class_name) ->
GetElementsByClassName (class_name) ->[source]
Params
class_name: stringReturns
: RmlUi.Element[]method IsPointWithinElement (point) ->
IsPointWithinElement (point) ->Is a screen-space point within this element?
[source]
Params
point: RmlUi.Vector2iReturns
: booleanmethod GetValue () -> value
GetValue () -> valueGet 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.field scroll_left
scroll_leftis
integer[source] Gets or sets the number of pixels that the content of the element is scrolled from the left.
field scroll_top
scroll_topis
integer[source] Gets or sets the number of pixels that the content of the element is scrolled from the top.
field attributes
attributesis
RmlUi.ElementAttributesProxy[source] Read-only. Proxy for accessing element attributes.
field child_nodes
child_nodesis
RmlUi.ElementChildNodesProxy[source] Read-only. Proxy for accessing child nodes of the element.
field client_left
client_leftis
integer[source] Read-only. The width of the left border of the element in pixels.
field client_height
client_heightis
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_width
client_widthis
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
first_childis
RmlUi.Element?[source] Read-only. The first child element, or nil if there are no children.
field last_child
last_childis
RmlUi.Element?[source] Read-only. The last child element, or nil if there are no children.
field next_sibling
next_siblingis
RmlUi.Element?[source] Read-only. The next sibling element, or nil if there is none.
field offset_height
offset_heightis
integer[source] Read-only. The height of the element including vertical padding and borders, in pixels.
field offset_left
offset_leftis
integer[source] Read-only. The distance from the inner left edge of the offset parent, in pixels.
field offset_top
offset_topis
integer[source] Read-only. The distance from the inner top edge of the offset parent, in pixels.
field offset_width
offset_widthis
integer[source] Read-only. The width of the element including horizontal padding and borders, in pixels.
field parent_node
parent_nodeis
RmlUi.Element?[source] Read-only. The parent node of this element, or nil if there is none.
field previous_sibling
previous_siblingis
RmlUi.Element?[source] Read-only. The previous sibling element, or nil if there is none.
field scroll_height
scroll_heightis
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
scroll_widthis
integer[source] Read-only. The total width of the element’s content, including content not visible on the screen due to overflow.
field style
styleis
RmlUi.ElementStyleProxy[source] Read-only. Proxy for accessing and modifying the element’s style properties.
field absolute_left
absolute_leftis
integer[source] Read-only. The absolute left position of the element relative to the document.
field absolute_top
absolute_topis
integer[source] Read-only. The absolute top position of the element relative to the document.
alias RmlUi.ElementAttributesProxy
RmlUi.ElementAttributesProxyis
{ [string]: (string|number|boolean) }Contains all the attributes of an element: The stuff in the opening tag i.e. <span class="my-class">
[source]
class RmlUi.ElementPtr
RmlUi.ElementPtrRepresents 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
RmlUi.ElementStyleProxyis
{ [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
RmlUi.ElementTabSetinherits from RmlUi.Element
[source]
method SetPanel (index, rml)
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: integerrml: stringmethod SetTab (index, rml)
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: integerrml: stringalias RmlUi.EventID
RmlUi.EventIDis
(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]
alias RmlUi.EventParametersProxy.TrueFalse
RmlUi.EventParametersProxy.TrueFalseis
(0|1)RmlUi uses 0 and 1 to represent boolean values here.
[source]
class RmlUi.SolLuaDataModel
RmlUi.SolLuaDataModelHandle 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)
__SetDirty (property)Set a table property dirty to trigger a rerender
[source]
Params
property: stringclass RulesSyncedCallins
RulesSyncedCallinsinherits from Callins UnsyncedCallins SyncedCallins
Callins that are sent to the synced lua file:
LuaRules/main.luaclass RulesUnsyncedCallins
RulesUnsyncedCallinsinherits from Callins UnsyncedCallins
Callins that are sent to the unsynced lua file:
LuaRules/draw.luaclass ShaderParams
ShaderParams[source]
field tcs
tcsis
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
tesis
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 fragment
fragmentis
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.
alias SoundChannel
SoundChannelis
(“general”|“battle”|“sfx”|“unitreply”|“voice”|“userinterface”|“ui”|0|1|2|3)[source]
class SyncedCallins
SyncedCallins[source]
method CommandFallback (unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions, cmdTag) -> whether
CommandFallback (unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions, cmdTag) -> whetherCalled when the unit reaches an unknown command in its queue (i.e. one not handled by the engine).
[source]
Params
unitID: integerunitDefID: integerunitTeam: integercmdID: integercmdParams: number[]cmdOptions: CommandOptionscmdTag: numberReturns
whether: boolean --to remove the command from the queuemethod AllowCommand (unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions, cmdTag, synced, fromLua) -> whether
AllowCommand (unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions, cmdTag, synced, fromLua) -> whetherCalled 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: integerunitDefID: integerunitTeam: integercmdID: integercmdParams: number[]cmdOptions: CommandOptionscmdTag: numbersynced: booleanfromLua: booleanReturns
whether: boolean --it should be let into the queue.method AllowUnitCreation (unitDefID, builderID, builderTeam, x, y, z, facing) -> allow, dropOrder
AllowUnitCreation (unitDefID, builderID, builderTeam, x, y, z, facing) -> allow, dropOrderCalled just before unit is created.
[source]
Params
unitDefID: integerbuilderID: integerbuilderTeam: integerx: numbery: numberz: numberfacing: FacingIntegerReturns
allow: booleandropOrder: booleanmethod AllowUnitTransfer (unitID, unitDefID, oldTeam, newTeam, capture) -> whether
AllowUnitTransfer (unitID, unitDefID, oldTeam, newTeam, capture) -> whetherCalled just before a unit is transferred to a different team.
[source]
Params
unitID: integerunitDefID: integeroldTeam: integernewTeam: integercapture: booleanReturns
whether: boolean --or not the transfer is permitted.method AllowUnitBuildStep (builderID, builderTeam, unitID, unitDefID, part) -> whether
AllowUnitBuildStep (builderID, builderTeam, unitID, unitDefID, part) -> whetherCalled just before a unit progresses its build percentage.
[source]
Params
builderID: integerbuilderTeam: integerunitID: integerunitDefID: integerpart: numberReturns
whether: boolean --or not the build makes progress.method AllowUnitCaptureStep (builderID, builderTeam, unitID, unitDefID, part) -> whether
AllowUnitCaptureStep (builderID, builderTeam, unitID, unitDefID, part) -> whether[source]
Params
builderID: integerbuilderTeam: integerunitID: integerunitDefID: integerpart: numberReturns
whether: boolean --or not the capture makes progress.method AllowUnitTransport (transporterID, transporterUnitDefID, transporterTeam, transporteeID, transporteeUnitDefID, transporteeTeam) -> whether
AllowUnitTransport (transporterID, transporterUnitDefID, transporterTeam, transporteeID, transporteeUnitDefID, transporteeTeam) -> whether[source]
Params
transporterID: integertransporterUnitDefID: integertransporterTeam: integertransporteeID: integertransporteeUnitDefID: integertransporteeTeam: integerReturns
whether: boolean --or not the transport is allowedmethod AllowUnitTransportLoad (transporterID, transporterUnitDefID, transporterTeam, transporteeID, transporteeUnitDefID, transporteeTeam, x, y, z) -> whether
AllowUnitTransportLoad (transporterID, transporterUnitDefID, transporterTeam, transporteeID, transporteeUnitDefID, transporteeTeam, x, y, z) -> whether[source]
Params
transporterID: integertransporterUnitDefID: integertransporterTeam: integertransporteeID: integertransporteeUnitDefID: integertransporteeTeam: integerx: numbery: numberz: numberReturns
whether: boolean --or not the transport load is allowedmethod AllowUnitTransportUnload (transporterID, transporterUnitDefID, transporterTeam, transporteeID, transporteeUnitDefID, transporteeTeam, x, y, z) -> whether
AllowUnitTransportUnload (transporterID, transporterUnitDefID, transporterTeam, transporteeID, transporteeUnitDefID, transporteeTeam, x, y, z) -> whether[source]
Params
transporterID: integertransporterUnitDefID: integertransporterTeam: integertransporteeID: integertransporteeUnitDefID: integertransporteeTeam: integerx: numbery: numberz: numberReturns
whether: boolean --or not the transport unload is allowedmethod AllowUnitCloak (unitID, enemyID) -> whether
AllowUnitCloak (unitID, enemyID) -> whether[source]
Params
unitID: integerenemyID: integer?Returns
whether: boolean --unit is allowed to cloakmethod AllowUnitCloak (unitID, objectID, weaponNum) -> whether
AllowUnitCloak (unitID, objectID, weaponNum) -> whether[source]
Params
unitID: integerobjectID: integer?weaponNum: number?Returns
whether: boolean --unit is allowed to decloakmethod AllowUnitKamikaze (unitID, targetID) -> whether
AllowUnitKamikaze (unitID, targetID) -> whether[source]
Params
unitID: integertargetID: integerReturns
whether: boolean --unit is allowed to selfdmethod AllowFeatureCreation (featureDefID, teamID, x, y, z) -> whether
AllowFeatureCreation (featureDefID, teamID, x, y, z) -> whetherCalled just before feature is created.
[source]
Params
featureDefID: integerteamID: integerx: numbery: numberz: numberReturns
whether: boolean --or not the creation is permittedmethod AllowFeatureBuildStep (builderID, builderTeam, featureID, featureDefID, part) -> whether
AllowFeatureBuildStep (builderID, builderTeam, featureID, featureDefID, part) -> whetherCalled 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: integerbuilderTeam: integerfeatureID: integerfeatureDefID: integerpart: numberReturns
whether: boolean --or not the change is permittedmethod AllowResourceLevel (teamID, res, level) -> whether
AllowResourceLevel (teamID, res, level) -> whetherCalled when a team sets the sharing level of a resource.
[source]
Params
teamID: integerres: stringlevel: numberReturns
whether: boolean --or not the sharing level is permittedmethod AllowResourceTransfer (oldTeamID, newTeamID, res, amount) -> whether
AllowResourceTransfer (oldTeamID, newTeamID, res, amount) -> whetherCalled just before resources are transferred between players.
[source]
Params
oldTeamID: integernewTeamID: integerres: stringamount: numberReturns
whether: boolean --or not the transfer is permitted.method AllowDirectUnitControl (unitID, unitDefID, unitTeam, playerID) -> allow
AllowDirectUnitControl (unitID, unitDefID, unitTeam, playerID) -> allowDetermines if this unit can be controlled directly in FPS view.
[source]
Params
unitID: integerunitDefID: integerunitTeam: integerplayerID: integerReturns
allow: booleanmethod AllowStartPosition (playerID, teamID, readyState, clampedX, clampedY, clampedZ, rawX, rawY, rawZ) -> allow
AllowStartPosition (playerID, teamID, readyState, clampedX, clampedY, clampedZ, rawX, rawY, rawZ) -> allowWhether 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: integerteamID: integerreadyState: numberclampedX: numberclampedY: numberclampedZ: numberrawX: numberrawY: numberrawZ: numberReturns
allow: booleanmethod MoveCtrlNotify (unitID, unitDefID, unitTeam, data) -> whether
MoveCtrlNotify (unitID, unitDefID, unitTeam, data) -> whetherEnable both Spring.MoveCtrl.SetCollideStop and Spring.MoveCtrl.SetTrackGround to enable this call-in.
[source]
Params
unitID: integerunitDefID: integerunitTeam: integerdata: 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
TerraformComplete (unitID, unitDefID, unitTeam, buildUnitID, buildUnitDefID, buildUnitTeam) -> ifCalled when pre-building terrain levelling terraforms are completed (c.f. levelGround)
[source]
Params
unitID: integerunitDefID: integerunitTeam: integerbuildUnitID: integerbuildUnitDefID: integerbuildUnitTeam: integerReturns
if: boolean --true the current build order is terminatedmethod UnitPreDamaged (unitID, unitDefID, unitTeam, damage, paralyzer, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam) -> newDamage, impulseMult
UnitPreDamaged (unitID, unitDefID, unitTeam, damage, paralyzer, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam) -> newDamage, impulseMultCalled 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: integerunitDefID: integerunitTeam: integerdamage: numberparalyzer: booleanweaponDefID: integer? --Synced OnlyprojectileID: integer? --Synced OnlyattackerID: integer? --Synced OnlyattackerDefID: integer? --Synced OnlyattackerTeam: integer? --Synced OnlyReturns
newDamage: numberimpulseMult: numbermethod FeaturePreDamaged (featureID, featureDefID, featureTeam, damage, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam) -> newDamage, impulseMult
FeaturePreDamaged (featureID, featureDefID, featureTeam, damage, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam) -> newDamage, impulseMultCalled before damage is applied to the feature.
[source]
Allows fine control over how much damage and impulse is applied.
Params
featureID: integerfeatureDefID: integerfeatureTeam: integerdamage: numberweaponDefID: integerprojectileID: integerattackerID: integerattackerDefID: integerattackerTeam: integerReturns
newDamage: numberimpulseMult: numbermethod ShieldPreDamaged (projectileID, projectileOwnerID, shieldWeaponNum, shieldCarrierID, bounceProjectile, beamEmitterWeaponNum, beamEmitterUnitID, startX, startY, startZ, hitX, hitY, hitZ) -> if
ShieldPreDamaged (projectileID, projectileOwnerID, shieldWeaponNum, shieldCarrierID, bounceProjectile, beamEmitterWeaponNum, beamEmitterUnitID, startX, startY, startZ, hitX, hitY, hitZ) -> ifCalled 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: integerprojectileOwnerID: integershieldWeaponNum: integershieldCarrierID: integerbounceProjectile: booleanbeamEmitterWeaponNum: integerbeamEmitterUnitID: integerstartX: numberstartY: numberstartZ: numberhitX: numberhitY: numberhitZ: numberReturns
if: boolean --true the gadget handles the collision event and the engine does not remove the projectilemethod AllowWeaponTargetCheck (attackerID, attackerWeaponNum, attackerWeaponDefID) -> allowCheck, ignoreCheck
AllowWeaponTargetCheck (attackerID, attackerWeaponNum, attackerWeaponDefID) -> allowCheck, ignoreCheckDetermines 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: integerattackerWeaponNum: integerattackerWeaponDefID: integerReturns
allowCheck: booleanignoreCheck: booleanmethod AllowWeaponTarget (attackerID, targetID, attackerWeaponNum, attackerWeaponDefID, defPriority) -> allowed, the
AllowWeaponTarget (attackerID, targetID, attackerWeaponNum, attackerWeaponDefID, defPriority) -> allowed, theControls 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: integertargetID: integerattackerWeaponNum: integerattackerWeaponDefID: integerdefPriority: numberReturns
allowed: booleanthe: 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
AllowWeaponInterceptTarget (interceptorUnitID, interceptorWeaponID, targetProjectileID) -> allowedControls 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: integerinterceptorWeaponID: integertargetProjectileID: integerReturns
allowed: booleanfn SendToUnsynced (...)
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.class UniformParam
UniformParaminherits 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 UnsyncedCallins
UnsyncedCallins[source]
method DrawUnit (unitID, drawMode) -> suppressEngineDraw
DrawUnit (unitID, drawMode) -> suppressEngineDrawFor custom rendering of units
[source]
Params
unitID: integerdrawMode: numberReturns
suppressEngineDraw: booleanmethod DrawFeature (featureID, drawMode) -> suppressEngineDraw
DrawFeature (featureID, drawMode) -> suppressEngineDrawFor custom rendering of features
[source]
Params
featureID: integerdrawMode: numberReturns
suppressEngineDraw: booleanmethod DrawShield (featureID, weaponID, drawMode) -> suppressEngineDraw
DrawShield (featureID, weaponID, drawMode) -> suppressEngineDrawFor custom rendering of shields.
[source]
Params
featureID: integerweaponID: integerdrawMode: numberReturns
suppressEngineDraw: booleanmethod DrawProjectile (projectileID, drawMode) -> suppressEngineDraw
DrawProjectile (projectileID, drawMode) -> suppressEngineDrawFor custom rendering of weapon (& other) projectiles
[source]
Params
projectileID: integerdrawMode: numberReturns
suppressEngineDraw: booleanmethod DrawMaterial (uuid, drawMode) -> suppressEngineDraw
DrawMaterial (uuid, drawMode) -> suppressEngineDraw[source]
Params
uuid: integerdrawMode: numberReturns
suppressEngineDraw: booleanclass VAO
VAOVertex Array Object
[source]
See: LuaVAO.GetVAO rts/Lua/LuaVAOImpl.cpp
method DrawArrays (glEnum, vertexCount, vertexFirst, instanceCount, instanceFirst) ->
DrawArrays (glEnum, vertexCount, vertexFirst, instanceCount, instanceFirst) ->[source]
Params
glEnum: number --primitivesModevertexCount: number?vertexFirst: number?instanceCount: number?instanceFirst: number?Returns
: nilmethod DrawElements (glEnum, drawCount, baseIndex, instanceCount, baseVertex, baseInstance) ->
DrawElements (glEnum, drawCount, baseIndex, instanceCount, baseVertex, baseInstance) ->[source]
Params
glEnum: number --primitivesModedrawCount: number?baseIndex: number?instanceCount: number?baseVertex: number?baseInstance: number?Returns
: nilmethod AddUnitsToSubmission (unitIDs) -> submittedCount
AddUnitsToSubmission (unitIDs) -> submittedCount[source]
Params
unitIDs: (number|number[])Returns
submittedCount: numbermethod AddFeaturesToSubmission (featureIDs) -> submittedCount
AddFeaturesToSubmission (featureIDs) -> submittedCount[source]
Params
featureIDs: (number|number[])Returns
submittedCount: numbermethod AddUnitDefsToSubmission (unitDefIDs) -> submittedCount
AddUnitDefsToSubmission (unitDefIDs) -> submittedCount[source]
Params
unitDefIDs: (number|number[])Returns
submittedCount: numbermethod AddFeatureDefsToSubmission (featureDefIDs) -> submittedCount
AddFeatureDefsToSubmission (featureDefIDs) -> submittedCount[source]
Params
featureDefIDs: (number|number[])Returns
submittedCount: numberclass VBO
VBOVertex Buffer Object
[source]
See: LuaVBO.GetVBO rts/Lua/LuaVBOImpl.cpp
method Define (size, attribs) ->
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
: nilmethod GetBufferSize () -> elementsCount, bufferSizeInBytes, size
GetBufferSize () -> elementsCount, bufferSizeInBytes, size[source]
Returns
elementsCount: numberbufferSizeInBytes: numbersize: numbermethod Upload (vboData, attributeIndex, elemOffset, luaStartIndex, luaFinishIndex) -> indexData, elemOffset, attrID
Upload (vboData, attributeIndex, elemOffset, luaStartIndex, luaFinishIndex) -> indexData, elemOffset, attrIDUploads 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: integerattrID: (integer|(integer,integer…))method Download (attributeIndex, elementOffset, elementCount, forceGPURead) ->
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
downloadedelementOffset: integer? --(Default: `0`) download data starting from this elementelementCount: number? --number of elements to downloadforceGPURead: boolean? --(Default: `false`) force downloading the data from GPU buffer as opposed
to using shadow RAM bufferReturns
: unknownmethod ModelsVBO () -> buffer
ModelsVBO () -> bufferBinds 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 bytesmethod InstanceDataFromUnitDefIDs (unitDefIDs, attrID, teamIdOpt, elementOffset) -> instanceData, elementOffset, attrID
InstanceDataFromUnitDefIDs (unitDefIDs, attrID, teamIdOpt, elementOffset) -> instanceData, elementOffset, attrIDFills 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: integerteamIdOpt: integer?elementOffset: integer?Returns
instanceData: (number,number,number,number)elementOffset: integerattrID: integermethod InstanceDataFromFeatureDefIDs (featureDefIDs, attrID, teamIdOpt, elementOffset) -> instanceData, elementOffset, attrID
InstanceDataFromFeatureDefIDs (featureDefIDs, attrID, teamIdOpt, elementOffset) -> instanceData, elementOffset, attrIDFills 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: integerteamIdOpt: integer?elementOffset: integer?Returns
instanceData: (number,number,number,number)elementOffset: integerattrID: integermethod InstanceDataFromUnitIDs (unitIDs, attrID, teamIdOpt, elementOffset) -> instanceData, elementOffset, attrID
InstanceDataFromUnitIDs (unitIDs, attrID, teamIdOpt, elementOffset) -> instanceData, elementOffset, attrIDFills 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: integerteamIdOpt: integer?elementOffset: integer?Returns
instanceData: (number,number,number,number)elementOffset: integerattrID: integermethod InstanceDataFromFeatureIDs (featureIDs, attrID, teamIdOpt, elementOffset) -> instanceData, elementOffset, attrID
InstanceDataFromFeatureIDs (featureIDs, attrID, teamIdOpt, elementOffset) -> instanceData, elementOffset, attrIDFills 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: integerteamIdOpt: integer?elementOffset: integer?Returns
instanceData: (number,number,number,number)elementOffset: integerattrID: integermethod MatrixDataFromProjectileIDs (projectileIDs, attrID, teamIdOpt, elementOffset) -> matDataVec, elemOffset, attrID
MatrixDataFromProjectileIDs (projectileIDs, attrID, teamIdOpt, elementOffset) -> matDataVec, elemOffset, attrID[source]
Params
projectileIDs: (integer|integer[])attrID: integerteamIdOpt: integer?elementOffset: integer?Returns
matDataVec: number[] --4x4 matrixelemOffset: integerattrID: (integer|(integer,integer…))method BindBufferRange (index, elementOffset, elementCount, target) -> bindingIndex
BindBufferRange (index, elementOffset, elementCount, target) -> bindingIndexBind 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? --glEnumReturns
bindingIndex: integer --when successful, -1 otherwisemethod UnbindBufferRange (index, elementOffset, elementCount, target) -> bindingIndex
UnbindBufferRange (index, elementOffset, elementCount, target) -> bindingIndex[source]
Params
index: integerelementOffset: integer?elementCount: number?target: number? --glEnumReturns
bindingIndex: number --when successful, -1 otherwiseclass VBOAttributeDef
VBOAttributeDef[source]
field name
nameis
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 type
typeis
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.BYTEGL.UNSIGNED_BYTEGL.SHORTGL.UNSIGNED_SHORTGL.INTGL.UNSIGNED_INTGL.FLOAT