Lua API
Overview
We list here all globals available among all different lua environments within Recoil. Some types listed here exist only as helpers for aliasing parameters and returns.
The documentation pages are still a work in progress.
Spring (table)
Members
Spring.Echo (function)
Prints values in the spring chat console. Useful for debugging.
Hint: the default print() writes to STDOUT.
[source]
Spring.Echo(any, [any, ]*) -> nilParameters
Returns
Spring.Log (function)
Logs a message to the logfile/console.
[source]
Spring.Log(string, (LogLevel|LOG)?, [string, ]*) -> nilParameters
stringsection- Sets an arbitrary section. Level filtering can be applied per-section
(LogLevel|LOG)?logLevel- (Default:
“notice”) string...- messages
Spring.RequestPath (function)
[source]Spring.RequestPath((integer|string), number, number, number, number, number, number, number?) -> userdata?Parameters
(integer|string)moveIDnumberstartXnumberstartYnumberstartZnumberendXnumberendYnumberendZnumber?radius
Returns
userdata?path
Spring.InitPathNodeCostsArray (function)
[source]Spring.InitPathNodeCostsArray(integer, integer, integer) -> booleanParameters
integeroverlayIndexintegersizeXintegersizeZ
Returns
booleansuccess
Spring.FreePathNodeCostsArray (function)
[source]Spring.FreePathNodeCostsArray(integer) -> booleanParameters
integeroverlayIndex
Returns
booleansuccess
Spring.SetPathNodeCosts (function)
[source]Spring.SetPathNodeCosts(integer) -> booleanParameters
integeroverlayIndex
Returns
booleansuccess
Spring.GetPathNodeCosts (function)
[source]Spring.GetPathNodeCosts(integer) -> (boolean|table)Parameters
integeroverlayIndex
Returns
(boolean|table)costs
Spring.SetPathNodeCost (function)
[source]Spring.SetPathNodeCost(integer, integer, number) -> booleanParameters
integeroverlayIndexintegercostIndex- 0-based index in the overlay
numbercost
Returns
booleansuccess
Spring.GetPathNodeCost (function)
[source]Spring.GetPathNodeCost(integer, integer) -> numberParameters
Returns
numbercost
Spring.GetMetalMapSize (function)
[source]Spring.GetMetalMapSize() -> integer, integerReturns
integerx- X coordinate in worldspace / Game.metalMapSquareSize.
integerz- Z coordinate in worldspace / Game.metalMapSquareSize.
Spring.GetMetalAmount (function)
Returns the amount of metal on a single square.
[source]
Spring.GetMetalAmount(integer, integer) -> numberParameters
integerx- X coordinate in worldspace / Game.metalMapSquareSize.
integerz- Z coordinate in worldspace / Game.metalMapSquareSize.
Returns
numberamount
Spring.SetMetalAmount (function)
Sets the amount of metal on a single square.
[source]
Spring.SetMetalAmount(integer, integer, number) -> nilParameters
integerx- X coordinate in worldspace / Game.metalMapSquareSize.
integerz- Z coordinate in worldspace / Game.metalMapSquareSize.
numbermetalAmount- must be between 0 and 255*maxMetal (with maxMetal from the .smd or mapinfo.lua).
Returns
Spring.GetMetalExtraction (function)
[source]Spring.GetMetalExtraction(integer, integer) -> numberParameters
integerx- X coordinate in worldspace / Game.metalMapSquareSize.
integerz- Z coordinate in worldspace / Game.metalMapSquareSize.
Returns
numberextraction
Spring.SetAlly (function)
Changes the value of the (one-sided) alliance between: firstAllyTeamID -> secondAllyTeamID.
[source]
Spring.SetAlly(AllyTeamID, AllyTeamID, boolean) -> nilParameters
Returns
Spring.SetAllyTeamStartBox (function)
Changes the start box position of an allyTeam.
[source]
Spring.SetAllyTeamStartBox(AllyTeamID, number, number, number, number) -> nilParameters
AllyTeamIDallyTeamIDnumberxMin- left start box boundary (elmos)
numberzMin- top start box boundary (elmos)
numberxMax- right start box boundary (elmos)
numberzMax- bottom start box boundary (elmos)
Returns
Spring.AssignPlayerToTeam (function)
Assigns a player to a team.
[source]
Spring.AssignPlayerToTeam(PlayerID, TeamID) -> nilParameters
Returns
Spring.SetTeamStartPosition (function)
Set the starting position of a team.
If the position argument is outside the team’s startbox, the position is clamped.
[source]
Spring.SetTeamStartPosition(TeamID, number, number, number) -> booleanParameters
Returns
booleansuccess- true if the position was set, false if the teamID is invalid
Spring.SetPlayerReadyState (function)
Set the ready state of a player.
Use to mark a player (un)ready in the pregame phase.
[source]
Spring.SetPlayerReadyState(PlayerID, boolean) -> booleanParameters
Returns
booleansuccess- true if the state was set, false if the playerID was invalid
Spring.SetGlobalLos (function)
Changes access to global line of sight for a team and its allies.
[source]
Spring.SetGlobalLos(AllyTeamID, boolean) -> nilParameters
Returns
Spring.SetCheatingEnabled (function)
Changes whether activating cheats is allowed. Note that already activated cheats (e.g. god mode) stay active even if you disallow activating.
[source]
Spring.SetCheatingEnabled(boolean) -> nilParameters
booleancheatsEnabled
Returns
Spring.SetGodMode (function)
Toggles ‘god mode’, i.e. whether control of teams other than one’s own is allowed. Affects all teams.
[source]
Spring.SetGodMode(boolean?, boolean?) -> nilParameters
boolean?controlAlliesboolean?controlEnemies
Returns
Spring.KillTeam (function)
Will declare a team to be dead (no further orders can be assigned to such teams units).
[source]
Gaia team cannot be killed.
Spring.KillTeam(TeamID) -> nilParameters
Returns
Spring.GameOver (function)
Declare game over.
[source]
Spring.GameOver(AllyTeamID[]) -> integerParameters
AllyTeamID[]winningAllyTeamIDsA 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
integerteams- Number of accepted (valid) ally teams.
Spring.SetTidal (function)
Set tidal strength
[source]
Spring.SetTidal(number?) -> nilParameters
number?strength
Returns
Spring.SetWind (function)
Set wind strength
[source]
Spring.SetWind(number?, number?) -> nilParameters
number?minStrengthnumber?maxStrength
Returns
Spring.AddTeamResource (function)
Adds metal or energy resources to the specified team. Counts as production in post-game graph statistics.
[source]
Spring.AddTeamResource(TeamID, ResourceName, number) -> nilParameters
Returns
Spring.UseTeamResource (function)
Consumes metal or energy resources of the specified team. Counts as usage in post-game graph statistics.
[source]
Spring.UseTeamResource(TeamID, ResourceName, number) -> booleanParameters
TeamIDteamIDResourceNametype- Resource type.
numberamount- Amount of resource to use.
Returns
booleanhadEnough
Spring.UseTeamResource (function overload 1)
Consumes metal and/or energy resources of the specified team. Counts as usage in post-game graph statistics.
[source]
Spring.UseTeamResource(TeamID, ResourceUsage) -> booleanParameters
Returns
booleanhadEnough
Spring.SetTeamResource (function)
[source]Spring.SetTeamResource(TeamID, (ResourceName|StorageName), number) -> nilParameters
Returns
Spring.SetTeamShareLevel (function)
Changes the resource amount for a team beyond which resources aren’t stored but transferred to other allied teams if possible.
[source]
Spring.SetTeamShareLevel(TeamID, ResourceName, number) -> nilParameters
Returns
Spring.AddTeamResourceExcessStats (function)
Records resource excess for a team without moving resources.
The engine normally tracks excess, but if you use gadget:ResourceExcess
to handle it manually it’s now also up to you to track stats.
[source]
Spring.AddTeamResourceExcessStats(TeamID, ResourceName, number) -> nilParameters
TeamIDteamIDResourceNametypenumberexcess- Amount wasted this tick.
Returns
Spring.ShareTeamResource (function)
Transfers resources between two teams. Transfers directly, without involving AllowResourceTransfer callin. Approximately equivalent to doing Use and Add for the sender and receiver, the difference being that it counts to sent/received stats rather than used/produced in end-game statistics graphs.
[source]
Spring.ShareTeamResource(TeamID, TeamID, ResourceName, number) -> nilParameters
Returns
Spring.SetGameRulesParam (function)
[source]Spring.SetGameRulesParam(string, (number|string|boolean)?, losAccess?) -> nilParameters
stringparamName(number|string|boolean)?paramValue- numeric paramValues in quotes will be converted to number.
losAccess?losAccess
Returns
Spring.SetTeamRulesParam (function)
[source]Spring.SetTeamRulesParam(TeamID, string, (number|string|boolean)?, losAccess?) -> nilParameters
TeamIDteamIDstringparamName(number|string|boolean)?paramValue- numeric paramValues in quotes will be converted to number.
losAccess?losAccess
Returns
Spring.SetPlayerRulesParam (function)
[source]Spring.SetPlayerRulesParam(PlayerID, string, (number|string|boolean)?, losAccess?) -> nilParameters
PlayerIDplayerIDstringparamName(number|string|boolean)?paramValue- numeric paramValues in quotes will be converted to number.
losAccess?losAccess
Returns
Spring.SetUnitRulesParam (function)
[source]Spring.SetUnitRulesParam(UnitID, string, (number|string|boolean)?, losAccess?) -> nilParameters
UnitIDunitIDstringparamName(number|string|boolean)?paramValue- numeric paramValues in quotes will be converted to number.
losAccess?losAccess
Returns
Spring.SetFeatureRulesParam (function)
[source]Spring.SetFeatureRulesParam(FeatureID, string, (number|string|boolean)?, losAccess?) -> nilParameters
FeatureIDfeatureIDstringparamName(number|string|boolean)?paramValue- numeric paramValues in quotes will be converted to number.
losAccess?losAccess
Returns
Spring.CallCOBScript (function)
[source]Spring.CallCOBScript(UnitID, (integer|string)?, integer, [any, ]*) -> integer ...Parameters
UnitIDunitID(integer|string)?funcName- Function ID or name.
integerretArgs- Number of values to return.
any...- Arguments
Returns
Spring.GetCOBScriptID (function)
[source]Spring.GetCOBScriptID(UnitID, string) -> integer?Parameters
Returns
integer?funcID
Spring.CreateUnit (function)
[source]Spring.CreateUnit((string|integer), number, number, number, Facing, TeamID?, boolean?, boolean?, UnitID?, UnitID?) -> UnitID?Parameters
(string|integer)unitDef- UnitDef name or ID.
numberposXnumberposYnumberposZFacingfacingTeamID?teamIDboolean?build- (Default:
false) The unit is created in “being built” state with zerobuildProgress. boolean?flattenGround- (Default:
true) The unit flattens ground, if it normally does so. UnitID?unitID- Request a specific unitID.
UnitID?builderID
Returns
Spring.DestroyUnit (function)
[source]Spring.DestroyUnit(UnitID, boolean?, boolean?, UnitID?, boolean?) -> nilParameters
UnitIDunitIDboolean?selfd- (Default:
false) makes the unit act like it self-destructed. boolean?reclaimed- (Default:
false) don’t show any DeathSequences, don’t leave a wreckage. This does not give back the resources to the team! UnitID?attackerIDboolean?cleanupImmediately- (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
Spring.TransferUnit (function)
[source]Spring.TransferUnit(UnitID, TeamID, boolean?, boolean?) -> booleanParameters
UnitIDunitIDTeamIDnewTeamIDboolean?given- (Default:
true) if false, the unit is captured. boolean?adjustUnitLimit- (Default:
false) if true, also transfer the limit slot
Returns
booleansuccessfulTransfer
Spring.TransferTeamMaxUnits (function)
Transfer capacity of units from one team to another
[source]
There are some conditions that must be satisfied for the operation to be successful:
transferAmntmust be lower or equal than the origin team current maxunits (can’t transfer limit team does not have available)transferAmntmust be lower than origin team maxunits - currentunitscount (can’t transfer limit if origin team would be already over the limit after transfer)
Spring.TransferTeamMaxUnits(TeamID, TeamID, integer) -> booleanParameters
Returns
booleansuccessfulTransfer- Whether the max unit limit was successfully transferred.
Spring.SetUnitCosts (function)
[source]Spring.SetUnitCosts(UnitID, table<number,number>) -> nilParameters
UnitIDunitIDtable<number,number>where- keys and values are, respectively and in this order: buildTime=amount, metalCost=amount, energyCost=amount
Returns
Spring.SetUnitResourcing (function)
[source]Spring.SetUnitResourcing(UnitID, string, number) -> nilParameters
Returns
Spring.SetUnitResourcing (function overload 1)
[source]Spring.SetUnitResourcing(UnitID, table<string,number>) -> nilParameters
UnitIDunitIDtable<string,number>res- keys are: “[u|c][u|m][m|e]” unconditional | conditional, use | make, metal | energy. Values are amounts
Returns
Spring.SetUnitStorage (function)
[source]Spring.SetUnitStorage(UnitID, string, number) -> nilParameters
Spring.SetUnitStorage (function overload 1)
[source]Spring.SetUnitStorage(UnitID, ResourceUsage) -> nilParameters
UnitIDunitIDResourceUsageres- keys are: “[m|e]” metal | energy. Values are amounts
Spring.SetUnitTooltip (function)
[source]Spring.SetUnitTooltip(UnitID, string) -> nilParameters
Returns
Spring.SetUnitHealth (function)
[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.
Spring.SetUnitHealth(UnitID, (number|SetUnitHealthAmounts)) -> nilParameters
UnitIDunitID(number|SetUnitHealthAmounts)health- If a number, sets the units health to that value. Pass a table to update health, capture progress, paralyze damage, and build progress.
Returns
Spring.SetUnitMaxHealth (function)
[source]Spring.SetUnitMaxHealth(UnitID, number) -> nilParameters
Returns
Spring.SetUnitStockpile (function)
[source]Spring.SetUnitStockpile(UnitID, integer?, number?) -> nilParameters
UnitIDunitIDinteger?stockpilenumber?buildPercent
Returns
Spring.SetUnitUseWeapons (function)
[source]Spring.SetUnitUseWeapons(UnitID, number?, number?) -> nilParameters
UnitIDunitIDnumber?forceUseWeaponsnumber?allowUseWeapons
Returns
Spring.SetUnitWeaponState (function)
[source]Spring.SetUnitWeaponState(UnitID, integer, WeaponState) -> nilParameters
Returns
Spring.SetUnitWeaponState (function overload 1)
[source]Spring.SetUnitWeaponState(UnitID, integer, string, number) -> nilParameters
Returns
Spring.SetUnitWeaponDamages (function)
[source]Spring.SetUnitWeaponDamages(UnitID, (integer|"selfDestruct"|"explode"), WeaponDamages) -> nilParameters
UnitIDunitID(integer|"selfDestruct"|"explode")weaponNumWeaponDamagesdamages
Returns
Spring.SetUnitWeaponDamages (function overload 1)
[source]Spring.SetUnitWeaponDamages(UnitID, (integer|"selfDestruct"|"explode"), string, number) -> nilParameters
Returns
Spring.SetUnitMaxRange (function)
[source]Spring.SetUnitMaxRange(UnitID, number) -> nilParameters
Returns
Spring.SetUnitExperience (function)
[source]Spring.SetUnitExperience(UnitID, number) -> nilParameters
UnitIDunitIDnumberexperience
Returns
Spring.AddUnitExperience (function)
[source]Spring.AddUnitExperience(UnitID, number) -> nilParameters
UnitIDunitIDnumberdeltaExperience- Can be negative to subtract, but the unit will never have negative total afterwards
Returns
Spring.SetUnitArmored (function)
[source]Spring.SetUnitArmored(UnitID, boolean?, number?) -> nilParameters
UnitIDunitIDboolean?armorednumber?armorMultiple
Returns
Spring.SetUnitLosMask (function)
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]
Spring.SetUnitLosMask(UnitID, AllyTeamID, (LosTable|LosMask|integer)) -> nilParameters
UnitIDunitIDAllyTeamIDallyTeam(LosTable|LosMask|integer)losTypes- A bitmask of LosMask bits or a table. True bits disable engine updates to visibility.
Spring.SetUnitLosState (function)
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]
Spring.SetUnitLosState(UnitID, AllyTeamID, (LosTable|LosMask|integer)) -> nilParameters
UnitIDunitIDAllyTeamIDallyTeam(LosTable|LosMask|integer)losTypes- A bitmask of LosMask bits or a table
Spring.SetUnitCloak (function)
[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.
Spring.SetUnitCloak(UnitID, (boolean|number)?, (boolean|number)?) -> nilParameters
Returns
Spring.SetUnitStealth (function)
[source]Spring.SetUnitStealth(UnitID, boolean) -> nilParameters
Returns
Spring.SetUnitSonarStealth (function)
[source]Spring.SetUnitSonarStealth(UnitID, boolean) -> nilParameters
UnitIDunitIDbooleansonarStealth
Returns
Spring.SetUnitSeismicSignature (function)
[source]Spring.SetUnitSeismicSignature(UnitID, number) -> nilParameters
Returns
Spring.SetUnitLeavesGhost (function)
Set whether unit leaves static radar ghosts.
[source]
Spring.SetUnitLeavesGhost(boolean, boolean?) -> nilParameters
booleanleavesGhostboolean?leaveDeadGhost- (Default:
false) leave a dead ghost behind if disabling and the unit had a live static ghost.
Spring.SetUnitAlwaysVisible (function)
[source]Spring.SetUnitAlwaysVisible(UnitID, boolean) -> nilParameters
UnitIDunitIDbooleanalwaysVisible
Returns
Spring.SetUnitUseAirLos (function)
[source]Spring.SetUnitUseAirLos(UnitID, boolean) -> nilParameters
Returns
Spring.SetUnitMetalExtraction (function)
[source]Spring.SetUnitMetalExtraction(UnitID, number, number?) -> nilParameters
UnitIDunitIDnumberdepth- corresponds to metal extraction rate
number?range- similar to “extractsMetal” in unitDefs.
Returns
Spring.SetUnitHarvestStorage (function)
See also harvestStorage UnitDef tag.
[source]
Spring.SetUnitHarvestStorage(UnitID, number?) -> nilParameters
Returns
Spring.SetUnitBuildParams (function)
[source]Spring.SetUnitBuildParams(UnitID, string, (number|boolean)?) -> nilParameters
UnitIDunitIDstringparamName- one of
buildRange|buildDistance|buildRange3D (number|boolean)?value- boolean when
paramNameisbuildRange3D, otherwise number.
Returns
Spring.SetUnitBuildSpeed (function)
[source]Spring.SetUnitBuildSpeed(UnitID, number, number?, number?, number?, number?) -> nilParameters
UnitIDbuilderIDnumberbuildSpeednumber?repairSpeednumber?reclaimSpeednumber?captureSpeednumber?terraformSpeed
Returns
Spring.SetUnitNanoPieces (function)
[source]
This saves a lot of engine calls, by replacing: function script.QueryNanoPiece() return currentpiece end Use it!
Spring.SetUnitNanoPieces(UnitID, table) -> nilParameters
Returns
Spring.SetUnitBlocking (function)
[source]Spring.SetUnitBlocking(UnitID, boolean?, boolean?, boolean?, boolean?, boolean?, boolean?, boolean?) -> booleanParameters
UnitIDunitIDboolean?isBlocking- If
trueadd this unit to theGroundBlockingMap, but only if it collides with solid objects (or is being set to collide with theisSolidObjectCollidableargument). Iffalse, remove this unit from theGroundBlockingMap. No change ifnil. boolean?isSolidObjectCollidable- Enable or disable collision with solid objects, or no change if
nil. boolean?isProjectileCollidable- Enable or disable collision with projectiles, or no change if
nil. boolean?isRaySegmentCollidable- Enable or disable collision with ray segments, or no change if
nil. boolean?crushable- Enable or disable crushable, or no change if
nil. boolean?blockEnemyPushing- Enable or disable blocking enemy pushing, or no change if
nil. boolean?blockHeightChanges- Enable or disable blocking height changes, or no change if
nil.
Returns
booleanisBlocking
Spring.SetUnitCrashing (function)
[source]Spring.SetUnitCrashing(UnitID, boolean?) -> booleanParameters
Returns
booleansuccess
Spring.SetUnitShieldState (function)
[source]Spring.SetUnitShieldState(UnitID, integer?, boolean?, number?) -> nilParameters
Returns
Spring.SetUnitShieldRechargeDelay (function)
[source]Spring.SetUnitShieldRechargeDelay(UnitID, integer?, number?) -> nilParameters
UnitIDunitIDinteger?weaponID- (optional if the unit only has one shield)
number?rechargeTime- (in seconds; emulates a regular hit if nil)
Returns
Spring.SetUnitFlanking (function)
[source]Spring.SetUnitFlanking(UnitID, string, number, number?, number?) -> nilParameters
UnitIDunitIDstringtype- “dir”|“minDamage”|“maxDamage”|“moveFactor”|“mode”
numberarg1- x|minDamage|maxDamage|moveFactor|mode
number?y- only when type is “dir”
number?z- only when type is “dir”
Returns
Spring.SetUnitPhysicalStateBit (function)
[source]Spring.SetUnitPhysicalStateBit(UnitID, ) -> nilParameters
Returns
Spring.GetUnitPhysicalState (function)
[source]Spring.GetUnitPhysicalState(UnitID) -> integerParameters
Returns
integerphysicalState- Unit’s PhysicalState bitmask
Spring.SetUnitNeutral (function)
[source]Spring.SetUnitNeutral(UnitID, boolean) -> boolean?Parameters
Returns
boolean?setNeutral
Spring.SetUnitTarget (function)
Defines a unit’s target.
[source]
Spring.SetUnitTarget(UnitID, UnitID?, boolean?, boolean?, boolean?, integer?) -> booleanParameters
UnitIDunitIDUnitID?enemyUnitID- when nil drops the units current target.
boolean?dgun- (Default:
false) boolean?userTarget- (Default:
false) boolean?dontForceTargetinteger?weaponNum- (Default:
-1)
Returns
booleansuccess
Spring.SetUnitTarget (function overload 1)
[source]Spring.SetUnitTarget(UnitID, number?, number?, number?, boolean?, boolean?, boolean?, integer?) -> booleanParameters
UnitIDunitIDnumber?x- when nil or not passed it will drop target and ignore other parameters
number?ynumber?zboolean?dgun- (Default:
false) boolean?userTarget- (Default:
false) boolean?dontForceTargetinteger?weaponNum- (Default:
-1)
Returns
booleansuccess
Spring.SetUnitMidAndAimPos (function)
[source]Spring.SetUnitMidAndAimPos(UnitID, number, number, number, number, number, number, boolean?) -> booleanParameters
UnitIDunitIDnumbermpX- new middle positionX of unit
numbermpY- new middle positionY of unit
numbermpZ- new middle positionZ of unit
numberapX- new positionX that enemies aim at on this unit
numberapY- new positionY that enemies aim at on this unit
numberapZ- new positionZ that enemies aim at on this unit
boolean?relative- (Default:
false) are the new coordinates relative to world (false) or unit (true) coordinates? Also, note that apy is inverted!
Returns
booleansuccess
Spring.SetUnitRadiusAndHeight (function)
[source]Spring.SetUnitRadiusAndHeight(UnitID, number?, number?) -> booleanParameters
Returns
booleansuccess
Spring.SetUnitBuildeeRadius (function)
[source]
Sets the unit’s radius for when targeted by build, repair, reclaim-type commands.
Spring.SetUnitBuildeeRadius(UnitID, number) -> nilParameters
Returns
Spring.SetUnitPieceParent (function)
Changes the pieces hierarchy of a unit by attaching a piece to a new parent.
[source]
Spring.SetUnitPieceParent(UnitID, integer, integer) -> nilParameters
UnitIDunitIDintegerAlteredPieceintegerParentPiece
Returns
Spring.SetUnitPieceMatrix (function)
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.
Spring.SetUnitPieceMatrix(UnitID, integer, number[]) -> boolean?Parameters
Returns
boolean?valid- whether the matrix can be used for the purpose of defining the piece spatial transformation. Blocks the piece animation, if true.
Spring.SetUnitCollisionVolumeData (function)
[source]Spring.SetUnitCollisionVolumeData(UnitID, number, number, number, number, number, number, integer, integer, integer) -> nilParameters
UnitIDunitIDnumberscaleXnumberscaleYnumberscaleZnumberoffsetXnumberoffsetYnumberoffsetZintegervTypeintegertTypeintegerAxis
Returns
nilenum- 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 };
Spring.SetUnitPieceCollisionVolumeData (function)
[source]Spring.SetUnitPieceCollisionVolumeData(UnitID, integer, boolean, number, number, number, number, number, number, integer?, integer?) -> nilParameters
UnitIDunitIDintegerpieceIndexbooleanenablenumberscaleXnumberscaleYnumberscaleZnumberoffsetXnumberoffsetYnumberoffsetZinteger?volumeTypeinteger?primaryAxis
Returns
Spring.SetUnitPieceVisible (function)
[source]Spring.SetUnitPieceVisible(UnitID, integer, boolean) -> nilParameters
UnitIDunitIDintegerpieceIndexbooleanvisible
Returns
Spring.SetUnitSensorRadius (function)
[source]Spring.SetUnitSensorRadius(UnitID, ("los"|"airLos"|"radar"|"sonar"|"seismic"|"radarJammer"...), integer) -> integer?Parameters
Returns
integer?newRadius- New radius, or
nilif unit is invalid.
Spring.SetUnitPosErrorParams (function)
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]
Spring.SetUnitPosErrorParams(UnitID, number?, number?, number?, number?, number?, number?, integer?) -> nilParameters
UnitIDunitIDnumber?posErrorVectorXnumber?posErrorVectorYnumber?posErrorVectorZnumber?posErrorDeltaXnumber?posErrorDeltaYnumber?posErrorDeltaZinteger?nextPosErrorUpdate
Returns
Spring.SetUnitMoveGoal (function)
Used by default commands to get in build-, attackrange etc.
[source]
Spring.SetUnitMoveGoal(UnitID, number, number, number, number?, number?, boolean?) -> nilParameters
Returns
Spring.SetUnitLandGoal (function)
Used in conjunction with Spring.UnitAttach et al. to re-implement old airbase & fuel system in Lua.
[source]
Spring.SetUnitLandGoal(UnitID, number, number, number, number?) -> nilParameters
Returns
Spring.ClearUnitGoal (function)
[source]Spring.ClearUnitGoal(UnitID, boolean?) -> nilParameters
Returns
Spring.SetUnitPhysics (function)
[source]Spring.SetUnitPhysics(UnitID, number, number, number, number, number, number, number, number, number, number, number, number) -> nilParameters
UnitIDunitIDnumberposXnumberposYnumberposZnumbervelXnumbervelYnumbervelZnumberrotXnumberrotYnumberrotZnumberdragXnumberdragYnumberdragZ
Returns
Spring.SetUnitMass (function)
[source]Spring.SetUnitMass(UnitID, number) -> nilParameters
Returns
Spring.SetUnitPosition (function)
Set unit position (2D)
[source]
Sets a unit’s position in 2D, at terrain height.
Spring.SetUnitPosition(UnitID, number, number, boolean?) -> nilParameters
UnitIDunitIDnumberxnumberzboolean?floating- (Default:
false) If true, over water the position is on surface. If false, on seafloor.
Returns
Spring.SetUnitPosition (function overload 1)
Set unit position (3D)
[source]
Sets a unit’s position in 3D, at an arbitrary height.
Spring.SetUnitPosition(UnitID, number, number, number) -> nilParameters
Returns
Spring.SetUnitRotation (function)
[source]
Note: PYR order
Spring.SetUnitRotation(UnitID, number, number, number) -> nilParameters
Returns
Spring.SetUnitDirection (function)
[source]
Set unit front direction vector. The vector is normalized in the engine.
Deprecated: It’s strongly that you use the overload that accepts
a right direction as frontDir alone doesn’t define object orientation.
Spring.SetUnitDirection(UnitID, number, number, number) -> nilParameters
Returns
Spring.SetUnitDirection (function overload 1)
[source]
Set unit front and right direction vectors.
Both vectors will be normalized in the engine.
Spring.SetUnitDirection(UnitID, number, number, number, number, number, number) -> nilParameters
Returns
Spring.SetUnitHeadingAndUpDir (function)
[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.
Spring.SetUnitHeadingAndUpDir(UnitID, Heading, number, number, number) -> nilParameters
Returns
Spring.SetUnitVelocity (function)
Set the velocity of a Unit
[source]
See Spring.SetUnitMoveCtrl for disabling/enabling this control
Spring.SetUnitVelocity(UnitID, number, number, number) -> nilParameters
Spring.SetFactoryBuggerOff (function)
[source]Spring.SetFactoryBuggerOff(UnitID, boolean?, number?, number?, Heading?, boolean?, boolean?) -> number?Parameters
UnitIDunitIDboolean?buggerOffnumber?offsetnumber?radiusHeading?relHeadingboolean?sphericalboolean?forced
Returns
number?buggerOff
Spring.BuggerOff (function)
[source]Spring.BuggerOff(number, number, number?, number, TeamID, boolean?, boolean?, UnitID?, UnitDefID[]?) -> nilParameters
numberxnumberynumber?z- uses ground height when unspecified
numberradiusTeamIDteamIDboolean?spherical- (Default:
true) boolean?forced- (Default:
true) UnitID?excludeUnitIDUnitDefID[]?excludeUnitDefIDs
Returns
Spring.AddFeatureDamage (function)
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:FeatureDamaged
Spring.AddFeatureDamage(FeatureID, number, integer?, UnitID?, WeaponDefID?, number?, number?, number?) -> nilParameters
FeatureIDfeatureIDnumberdamageinteger?paralyze- (Default:
0) equals to the paralyzetime in the WeaponDef. UnitID?attackerID- (Default:
-1) WeaponDefID?weaponID- (Default:
-1) number?impulseXnumber?impulseYnumber?impulseZ
Spring.AddUnitDamage (function)
[source]Spring.AddUnitDamage(UnitID, number, integer?, UnitID?, WeaponDefID?, number?, number?, number?) -> nilParameters
UnitIDunitIDnumberdamageinteger?paralyze- (Default:
0) equals to the paralyzetime in the WeaponDef. UnitID?attackerID- (Default:
-1) WeaponDefID?weaponID- (Default:
-1) number?impulseXnumber?impulseYnumber?impulseZ
Returns
Spring.AddUnitImpulse (function)
[source]Spring.AddUnitImpulse(UnitID, number, number, number, number?) -> nilParameters
Returns
Spring.AddUnitSeismicPing (function)
[source]Spring.AddUnitSeismicPing(UnitID, number) -> nilParameters
Returns
Spring.AddUnitResource (function)
[source]Spring.AddUnitResource(UnitID, string, number) -> nilParameters
Returns
Spring.UseUnitResource (function)
[source]Spring.UseUnitResource(UnitID, ResourceName, number) -> boolean?Parameters
Returns
boolean?okay
Spring.UseUnitResource (function overload 1)
[source]Spring.UseUnitResource(UnitID, ResourceUsage) -> boolean?Parameters
Returns
boolean?okay
Spring.AddObjectDecal (function)
[source]Spring.AddObjectDecal(UnitID) -> nilParameters
Returns
Spring.RemoveObjectDecal (function)
[source]Spring.RemoveObjectDecal(UnitID) -> nilParameters
Returns
Spring.AddGrass (function)
[source]Spring.AddGrass(number, number) -> nilParameters
Returns
Spring.RemoveGrass (function)
[source]Spring.RemoveGrass(number, number) -> nilParameters
Returns
Spring.CreateFeature (function)
[source]Spring.CreateFeature((string|integer), number, number, number, Heading?, TeamID?, FeatureID?) -> FeatureID?Parameters
(string|integer)featureDef- name or id
numberxnumberynumberzHeading?headingTeamID?teamIDFeatureID?featureID
Returns
Spring.DestroyFeature (function)
[source]Spring.DestroyFeature(FeatureID) -> nilParameters
Returns
Spring.TransferFeature (function)
Feature Control
[source]
Spring.TransferFeature(FeatureID, TeamID) -> nilParameters
Returns
Spring.SetFeatureAlwaysVisible (function)
[source]Spring.SetFeatureAlwaysVisible(FeatureID, boolean) -> nilParameters
Returns
Spring.SetFeatureUseAirLos (function)
[source]Spring.SetFeatureUseAirLos(FeatureID, boolean) -> nilParameters
Returns
Spring.SetFeatureHealth (function)
[source]Spring.SetFeatureHealth(FeatureID, number, boolean?) -> nilParameters
FeatureIDfeatureIDnumberhealthboolean?checkDestruction- (Default:
false) Whether to destroy feature if feature goes below 0 health.
Returns
Spring.SetFeatureMaxHealth (function)
[source]Spring.SetFeatureMaxHealth(FeatureID, number) -> nilParameters
Returns
Spring.SetFeatureReclaim (function)
[source]Spring.SetFeatureReclaim(FeatureID, number) -> nilParameters
Returns
Spring.SetFeatureResources (function)
[source]Spring.SetFeatureResources(FeatureID, number, number, number?, number?, number?, number?) -> nilParameters
FeatureIDfeatureIDnumbermetalnumberenergynumber?reclaimTimenumber?reclaimLeftnumber?featureDefMetalnumber?featureDefEnergy
Returns
Spring.SetFeatureResurrect (function)
[source]Spring.SetFeatureResurrect(FeatureID, (string|integer)?, Facing?, number?) -> nilParameters
FeatureIDfeatureID(string|integer)?unitDef- Can be a number id or a string name, this allows cancelling resurrection by passing
-1. Facing?facing- (Default:
“south”) number?progress- Set the level of progress.
Returns
Spring.SetFeatureMoveCtrl (function)
Enable feature movement control.
[source]
Spring.SetFeatureMoveCtrl(FeatureID, true, number?, number?, number?, number?, number?, number?) -> nilParameters
FeatureIDfeatureIDtrueenabled- Enable feature movement.
number?initialVelocityX- Initial velocity on X axis, or
nilfor no change. number?initialVelocityY- Initial velocity on Y axis, or
nilfor no change. number?initialVelocityZ- Initial velocity on Z axis, or
nilfor no change. number?accelerationX- Acceleration per frame on X axis, or
nilfor no change. number?accelerationY- Acceleration per frame on Y axis, or
nilfor no change. number?accelerationZ- Acceleration per frame on Z axis, or
nilfor no change.
Spring.SetFeatureMoveCtrl (function overload 1)
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:
lua
– 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]
Spring.SetFeatureMoveCtrl(FeatureID, false, number?, number?, number?, number?, number?, number?, number?, number?, number?) -> nilParameters
FeatureIDfeatureIDfalseenabled- Disable feature movement.
number?velocityMaskX- Lock velocity change in X dimension when not using MoveCtrl.
0to lock, non-zero to allow, ornilto for no change. number?velocityMaskY- Lock velocity change in Y dimension when not using MoveCtrl.
0to lock, non-zero to allow, ornilto for no change. number?velocityMaskZ- Lock velocity change in Z dimension when not using MoveCtrl.
0to lock, non-zero to allow, ornilto for no change. number?impulseMaskX- Lock impulse in X dimension when not using MoveCtrl.
0to lock, non-zero to allow, ornilto for no change. number?impulseMaskY- Lock impulse in Y dimension when not using MoveCtrl.
0to lock, non-zero to allow, ornilto for no change. number?impulseMaskZ- Lock impulse in Z dimension when not using MoveCtrl.
0to lock, non-zero to allow, ornilto for no change. number?movementMaskX- Lock move in X dimension when not using MoveCtrl.
0to lock the axis, non-zero to allow, ornilfor no change. number?movementMaskY- Lock move in Y dimension when not using MoveCtrl.
0to lock the axis, non-zero to allow, ornilfor no change. number?movementMaskZ- Lock move in Z dimension when not using MoveCtrl.
0to lock the axis, non-zero to allow, ornilfor no change.
Spring.SetFeaturePhysics (function)
[source]Spring.SetFeaturePhysics(FeatureID, number, number, number, number, number, number, number, number, number, number, number, number) -> nilParameters
FeatureIDfeatureIDnumberposXnumberposYnumberposZnumbervelXnumbervelYnumbervelZnumberrotXnumberrotYnumberrotZnumberdragXnumberdragYnumberdragZ
Returns
Spring.SetFeatureMass (function)
[source]Spring.SetFeatureMass(FeatureID, number) -> nilParameters
Returns
Spring.SetFeaturePosition (function)
[source]Spring.SetFeaturePosition(FeatureID, number, number, number, boolean?) -> nilParameters
Returns
Spring.SetFeatureRotation (function)
[source]
Note: PYR order
Spring.SetFeatureRotation(FeatureID, number, number, number) -> nilParameters
FeatureIDfeatureIDnumberpitch- Rotation in X axis
numberyaw- Rotation in Y axis
numberroll- Rotation in Z axis
Returns
Spring.SetFeatureDirection (function)
[source]
Set feature front direction vector. The vector is normalized in the engine.
Deprecated: It’s strongly that you use the overload that accepts
a right direction as frontDir alone doesn’t define object orientation.
Spring.SetFeatureDirection(FeatureID, number, number, number) -> nilParameters
Returns
Spring.SetFeatureDirection (function overload 1)
[source]
Set feature front and right direction vectors.
Both vectors will be normalized in the engine.
Spring.SetFeatureDirection(FeatureID, number, number, number, number, number, number) -> nilParameters
Returns
Spring.SetFeatureHeadingAndUpDir (function)
[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.
Spring.SetFeatureHeadingAndUpDir(FeatureID, Heading, number, number, number) -> nilParameters
Returns
Spring.SetFeatureVelocity (function)
Set the velocity of a Feature
[source]
See Spring.SetFeatureMoveCtrl for disabling/enabling this control
Spring.SetFeatureVelocity(FeatureID, number, number, number) -> nilParameters
Spring.SetFeatureBlocking (function)
[source]Spring.SetFeatureBlocking(FeatureID, boolean?, boolean?, boolean?, boolean?, boolean?, boolean?, boolean?) -> booleanParameters
FeatureIDfeatureIDboolean?isBlocking- If
trueadd this feature to theGroundBlockingMap, but only if it collides with solid objects (or is being set to collide with theisSolidObjectCollidableargument). Iffalse, remove this feature from theGroundBlockingMap. No change ifnil. boolean?isSolidObjectCollidable- Enable or disable collision with solid objects, or no change if
nil. boolean?isProjectileCollidable- Enable or disable collision with projectiles, or no change if
nil. boolean?isRaySegmentCollidable- Enable or disable collision with ray segments, or no change if
nil. boolean?crushable- Enable or disable crushable, or no change if
nil. boolean?blockEnemyPushing- Enable or disable blocking enemy pushing, or no change if
nil. boolean?blockHeightChanges- Enable or disable blocking height changes, or no change if
nil.
Returns
booleanisBlocking
Spring.SetFeatureNoSelect (function)
[source]Spring.SetFeatureNoSelect(FeatureID, boolean) -> nilParameters
Returns
Spring.SetFeatureMidAndAimPos (function)
[source]
Check Spring.SetUnitMidAndAimPos for further explanation of the arguments.
Spring.SetFeatureMidAndAimPos(FeatureID, number, number, number, number, number, number, boolean?) -> booleanParameters
Returns
booleansuccess
Spring.SetFeatureRadiusAndHeight (function)
[source]Spring.SetFeatureRadiusAndHeight(FeatureID, number?, number?) -> booleanParameters
Returns
booleansuccess
Spring.SetFeatureCollisionVolumeData (function)
[source]
Check Spring.SetUnitCollisionVolumeData for further explanation of the arguments.
Spring.SetFeatureCollisionVolumeData(FeatureID, number, number, number, number, number, number, integer, integer, integer) -> nilParameters
FeatureIDfeatureIDnumberscaleXnumberscaleYnumberscaleZnumberoffsetXnumberoffsetYnumberoffsetZintegervTypeintegertTypeintegerAxis
Returns
Spring.SetFeaturePieceCollisionVolumeData (function)
[source]Spring.SetFeaturePieceCollisionVolumeData(FeatureID, integer, boolean, number, number, number, number, number, number, number, number, number?) -> nilParameters
FeatureIDfeatureIDintegerpieceIndexbooleanenablenumberscaleXnumberscaleYnumberscaleZnumberoffsetXnumberoffsetYnumberoffsetZnumberAxisnumbervolumeTypenumber?primaryAxis
Returns
Spring.SetFeaturePieceVisible (function)
[source]Spring.SetFeaturePieceVisible(FeatureID, integer, boolean) -> nilParameters
FeatureIDfeatureIDintegerpieceIndexbooleanvisible
Returns
Spring.SetFeaturePieceMatrix (function)
Sets the local (i.e. parent-relative) matrix of the given piece, for a feature.
[source]
Spring.SetFeaturePieceMatrix(FeatureID, integer, number[]) -> boolean?Parameters
FeatureIDfeatureIDintegerpieceIndexnumber[]matrix- an array of 16 floats
Returns
boolean?valid- whether the matrix can be used for the purpose of defining the piece spatial transformation
Spring.SetFeatureFireTime (function)
Set the fire timer for a feature.
[source]
Starts or resets an internal feature fire timer, when reaching zero the feature will be destroyed.
Spring.SetFeatureFireTime(FeatureID, number) -> nilParameters
Spring.SetFeatureSmokeTime (function)
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.
Spring.SetFeatureSmokeTime(FeatureID, number) -> nilParameters
Spring.CreateUnitWreck (function)
Create a wreck from a unit
[source]
Spring.CreateUnitWreck(UnitID, integer?, boolean?) -> FeatureID?Parameters
UnitIDunitIDinteger?wreckLevel- (Default:
1) Wreck index to use. boolean?doSmoke- (Default:
true) Wreck emits smoke whentrue.
Returns
Spring.CreateFeatureWreck (function)
Create a wreck from a feature
[source]
Spring.CreateFeatureWreck(FeatureID, integer?, boolean?) -> FeatureID?Parameters
FeatureIDfeatureIDinteger?wreckLevel- (Default:
1) Wreck index to use. boolean?doSmoke- (Default:
false) Wreck emits smoke whentrue.
Returns
Spring.SetProjectileAlwaysVisible (function)
[source]Spring.SetProjectileAlwaysVisible(ProjectileID, boolean) -> nilParameters
Returns
Spring.SetProjectileUseAirLos (function)
[source]Spring.SetProjectileUseAirLos(ProjectileID, boolean) -> nilParameters
Returns
Spring.SetProjectileMoveControl (function)
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]
Spring.SetProjectileMoveControl(ProjectileID, boolean?) -> nilParameters
ProjectileIDprojectileIDboolean?enable
Spring.SetProjectilePosition (function)
Set the position of a projectile
[source]
Spring.SetProjectilePosition(ProjectileID, number?, number?, number?) -> nilParameters
ProjectileIDprojectileIDnumber?posX- (Default:
0) number?posY- (Default:
0) number?posZ- (Default:
0)
Spring.SetProjectileVelocity (function)
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
Spring.SetProjectileVelocity(ProjectileID, number, number, number) -> nilParameters
ProjectileIDprojectileIDnumbervelX- in elmos/frame
numbervelY- in elmos/frame
numbervelZ- in elmos/frame
Spring.SetProjectileCollision (function)
[source]Spring.SetProjectileCollision(ProjectileID) -> nilParameters
Spring.SetProjectileTarget (function)
Set projectile target (object)
[source]
Spring.SetProjectileTarget(ProjectileID, (UnitID|FeatureID|ProjectileID), ProjectileTargetType) -> boolean?Parameters
Returns
boolean?validTarget
Spring.SetProjectileTarget (function overload 1)
Set projectile target (position)
[source]
Spring.SetProjectileTarget(ProjectileID, number, number, number) -> boolean?Parameters
ProjectileIDprojectileIDnumberposXnumberposYnumberposZ
Returns
boolean?validTarget
Spring.SetProjectileTimeToLive (function)
Set Time To Live for a projectile
[source]
Spring.SetProjectileTimeToLive(ProjectileID, integer) -> nilParameters
ProjectileIDprojectileIDintegerttl- Remaining time to live in frames
Spring.SetProjectileIsIntercepted (function)
[source]Spring.SetProjectileIsIntercepted(ProjectileID) -> nilParameters
Spring.SetProjectileDamages (function)
[source]Spring.SetProjectileDamages(ProjectileID, integer, string, number) -> nilParameters
ProjectileIDprojectileIDintegerweaponNumstringkeynumbervalue
Spring.SetProjectileIgnoreTrackingError (function)
[source]Spring.SetProjectileIgnoreTrackingError(ProjectileID, boolean) -> nilParameters
Spring.SetProjectileGravity (function)
[source]Spring.SetProjectileGravity(ProjectileID, number?) -> nilParameters
ProjectileIDprojectileIDnumber?grav- (Default:
0)
Returns
Spring.SetPieceProjectileParams (function)
Set piece projectile params
Non passed or nil args don’t set params.
[source]
Spring.SetPieceProjectileParams(ProjectileID, integer?, number?, number?, number?, number?, number?) -> nilParameters
ProjectileIDprojectileIDinteger?explosionFlagsnumber?spinAnglenumber?spinSpeednumber?spinVectorXnumber?spinVectorYnumber?spinVectorZ
Spring.SetProjectileCEG (function)
[source]Spring.SetProjectileCEG(ProjectileID, string) -> nilParameters
Returns
Spring.UnitFinishCommand (function)
[source]Spring.UnitFinishCommand(UnitID) -> nilParameters
Spring.GiveOrderToUnit (function)
[source]Spring.GiveOrderToUnit(UnitID, (CMD|integer), CreateCommandParams?, CreateCommandOptions?, integer?) -> booleanParameters
UnitIDunitID(CMD|integer)cmdID- The command ID.
CreateCommandParams?params- Parameters for the given command.
CreateCommandOptions?optionsinteger?timeout- Absolute frame number. The command will be discarded after this frame. Only respected by mobile units.
Returns
booleanunitOrdered
Spring.GiveOrderToUnit (function overload 1)
Give order to specific unit.
[source]
Spring.GiveOrderToUnit(UnitID, (CMD|integer), CreateCommandParams?, CreateCommandOptions?, integer?) -> booleanParameters
UnitIDunitID(CMD|integer)cmdID- The command ID.
CreateCommandParams?params- Parameters for the given command.
CreateCommandOptions?optionsinteger?timeout- Absolute frame number. The command will be discarded after this frame. Only respected by mobile units.
Returns
Spring.GiveOrderToUnitMap (function)
Give order to multiple units, specified by table keys.
[source]
Spring.GiveOrderToUnitMap(table<UnitID,any>, (CMD|integer), CreateCommandParams?, CreateCommandOptions?, integer?) -> integerParameters
table<UnitID,any>unitMap- A table with unit IDs as keys.
(CMD|integer)cmdID- The command ID.
CreateCommandParams?params- Parameters for the given command.
CreateCommandOptions?optionsinteger?timeout- Absolute frame number. The command will be discarded after this frame. Only respected by mobile units.
Returns
integerunitsOrdered- The number of units ordered.
Spring.GiveOrderToUnitMap (function overload 1)
Give order to multiple units, specified by table keys.
[source]
Spring.GiveOrderToUnitMap(table<UnitID,any>, (CMD|integer), CreateCommandParams?, CreateCommandOptions?, integer?) -> booleanParameters
table<UnitID,any>unitMap- A table with unit IDs as keys.
(CMD|integer)cmdID- The command ID.
CreateCommandParams?params- Parameters for the given command.
CreateCommandOptions?optionsinteger?timeout- Absolute frame number. The command will be discarded after this frame. Only respected by mobile units.
Returns
booleanorderGiven
Spring.GiveOrderToUnitArray (function)
[source]Spring.GiveOrderToUnitArray(UnitID[], (CMD|integer), CreateCommandParams?, CreateCommandOptions?, integer?) -> integerParameters
UnitID[]unitIDs- An array of unit IDs.
(CMD|integer)cmdID- The command ID.
CreateCommandParams?params- Parameters for the given command.
CreateCommandOptions?optionsinteger?timeout- Absolute frame number. The command will be discarded after this frame. Only respected by mobile units.
Returns
integerunitsOrdered- The number of units ordered.
Spring.GiveOrderToUnitArray (function overload 1)
Give order to an array of units.
[source]
Spring.GiveOrderToUnitArray(UnitID[], (CMD|integer), CreateCommandParams?, CreateCommandOptions?, integer?) -> booleanParameters
UnitID[]unitIDs- Array of unit IDs.
(CMD|integer)cmdID- The command ID.
CreateCommandParams?params- Parameters for the given command.
CreateCommandOptions?optionsinteger?timeout- Absolute frame number. The command will be discarded after this frame. Only respected by mobile units.
Returns
booleanordersGiventrueif any orders were sent, otherwisefalse.
Spring.GiveOrderArrayToUnit (function)
[source]Spring.GiveOrderArrayToUnit(UnitID, CreateCommand[]) -> booleanParameters
Returns
booleanordersGiven
Spring.GiveOrderArrayToUnit (function overload 1)
[source]Spring.GiveOrderArrayToUnit(UnitID, CreateCommand[]) -> booleanParameters
UnitIDunitID- Unit ID.
CreateCommand[]commands
Returns
booleanordersGiventrueif any orders were sent, otherwisefalse.
Spring.GiveOrderArrayToUnitMap (function)
[source]Spring.GiveOrderArrayToUnitMap(table<UnitID,any>, CreateCommand[]) -> integerParameters
table<UnitID,any>unitMap- A table with unit IDs as keys.
CreateCommand[]commands
Returns
integerunitsOrdered- The number of units ordered.
Spring.GiveOrderArrayToUnitMap (function overload 1)
[source]Spring.GiveOrderArrayToUnitMap(table<UnitID,any>, CreateCommand[]) -> booleanParameters
table<UnitID,any>unitMap- A table with unit IDs as keys.
CreateCommand[]commands
Returns
booleanordersGiventrueif any orders were sent, otherwisefalse.
Spring.GiveOrderArrayToUnitArray (function)
[source]Spring.GiveOrderArrayToUnitArray(UnitID[], CreateCommand[], boolean?) -> integerParameters
UnitID[]unitIDs- Array of unit IDs.
CreateCommand[]commandsboolean?pairwise(Default:
false) Whenfalse, 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 firstlen(unitArray)commands will be assigned, and vice-versa.
Returns
integerunitsOrdered- The number of units ordered.
Spring.GiveOrderArrayToUnitArray (function overload 1)
[source]Spring.GiveOrderArrayToUnitArray(UnitID[], CreateCommand[], boolean?) -> booleanParameters
UnitID[]unitIDs- Array of unit IDs.
CreateCommand[]commandsboolean?pairwise(Default:
false) Whenfalse, 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 firstlen(unitArray)commands will be assigned, and vice-versa.
Returns
booleanordersGiventrueif any orders were sent, otherwisefalse.
Spring.LevelHeightMap (function)
Set the height of a point in the world.
[source]
Spring.LevelHeightMap(number, number, number) -> nilParameters
Spring.LevelHeightMap (function overload 1)
Set the height of a rectangle area in the world.
[source]
Spring.LevelHeightMap(number, number, number, number, number?) -> nilParameters
Returns
Spring.AdjustHeightMap (function)
Add height to a point in the world.
[source]
Spring.AdjustHeightMap(number, number, number) -> nilParameters
Spring.AdjustHeightMap (function overload 1)
Add height to a rectangle in the world.
[source]
Spring.AdjustHeightMap(number, number, number, number, number?) -> nilParameters
Returns
Spring.RevertHeightMap (function)
Restore map height at a point in the world.
[source]
Spring.RevertHeightMap(number, number, number) -> nilParameters
Spring.RevertHeightMap (function overload 1)
Restore map height of a rectangle area in the world.
[source]
Spring.RevertHeightMap(number, number, number, number, number?) -> nilParameters
Returns
Spring.AddHeightMap (function)
Can only be called in Spring.SetHeightMapFunc
[source]
Spring.AddHeightMap(number, number, number) -> integer?Parameters
Returns
integer?newHeight
Spring.SetHeightMap (function)
[source]
Can only be called in Spring.SetHeightMapFunc.
Spring.SetHeightMap(number, number, number, number?) -> integer?Parameters
Returns
integer?absHeightDiff- If
0, nothing will be changed (the terraform starts), if1the terraform will be finished.
Spring.SetHeightMapFunc (function)
[source]
Example code:
lua
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)
Spring.SetHeightMapFunc(function, [number, ]*) -> integer?Parameters
functionluaFunctionnumber...
Returns
integer?absTotalHeightMapAmountChanged
Spring.LevelOriginalHeightMap (function)
Set the height of a point in the original map height cache.
[source]
Spring.LevelOriginalHeightMap(number, number, number) -> nilParameters
Spring.LevelOriginalHeightMap (function overload 1)
Set the height of a rectangle area in the original map height cache.
[source]
Spring.LevelOriginalHeightMap(number, number, number, number, number) -> nilParameters
Spring.AdjustOriginalHeightMap (function)
Add height to a point in the original map height cache.
[source]
Spring.AdjustOriginalHeightMap(number, number, number) -> nilParameters
Spring.AdjustOriginalHeightMap (function overload 1)
Add height to a rectangle area in the original map height cache.
[source]
Spring.AdjustOriginalHeightMap(number, number, number, number, number) -> nilParameters
Spring.RevertOriginalHeightMap (function)
Restore original map height at a point in the world.
[source]
Spring.RevertOriginalHeightMap(number, number, number) -> nilParameters
Spring.RevertOriginalHeightMap (function overload 1)
Restore original map height over a rectangle in the world.
[source]
Spring.RevertOriginalHeightMap(number, number, number, number, number?) -> nilParameters
Returns
Spring.AddOriginalHeightMap (function)
[source]
Can only be called in Spring.SetOriginalHeightMapFunc
Spring.AddOriginalHeightMap(number, number, number) -> nilParameters
Returns
Spring.SetOriginalHeightMap (function)
[source]
Can only be called in Spring.SetOriginalHeightMapFunc
Spring.SetOriginalHeightMap(number, number, number, number?) -> nilParameters
Returns
Spring.SetOriginalHeightMapFunc (function)
[source]
Cannot recurse on itself
Spring.SetOriginalHeightMapFunc(function) -> nilParameters
functionheightMapFunc
Returns
Spring.RebuildSmoothMesh (function)
[source]
Heightmap changes normally take up to 25s to propagate to the smooth mesh. Use to force a mapwide update immediately.
Spring.RebuildSmoothMesh() -> nilReturns
Spring.LevelSmoothMesh (function)
[source]Spring.LevelSmoothMesh(number, number, number) -> nilParameters
Spring.LevelSmoothMesh (function overload 1)
[source]Spring.LevelSmoothMesh(number, number, number, number, number) -> nilParameters
Spring.AdjustSmoothMesh (function)
[source]Spring.AdjustSmoothMesh(number, number, number) -> nilParameters
Spring.AdjustSmoothMesh (function overload 1)
[source]Spring.AdjustSmoothMesh(number, number, number, number, number) -> nilParameters
Spring.RevertSmoothMesh (function)
[source]Spring.RevertSmoothMesh(number, number, number) -> nilParameters
numberxnumberznumberorigFactor
Spring.RevertSmoothMesh (function overload 1)
[source]Spring.RevertSmoothMesh(number, number, number, number, number) -> nilParameters
numberx1numberz1numberx2numberz2numberorigFactor
Spring.AddSmoothMesh (function)
Can only be called in Spring.SetSmoothMeshFunc.
[source]
Spring.AddSmoothMesh(number, number, number) -> number?Parameters
Returns
number?height- The new height, or
nilif coordinates are invalid.
Spring.SetSmoothMesh (function)
Can only be called in Spring.SetSmoothMeshFunc.
[source]
Spring.SetSmoothMesh(number, number, number, number?) -> number?Parameters
Returns
number?heightDifference- The absolute height difference, or
nilif coordinates are invalid.
Spring.SetSmoothMeshFunc (function)
[source]Spring.SetSmoothMeshFunc(function, any, [any, ]*) -> number?Parameters
functionluaFunctionanyargany...
Returns
Spring.SetMapSquareTerrainType (function)
[source]Spring.SetMapSquareTerrainType(number, number, integer) -> integer?Parameters
Returns
integer?oldType
Spring.SetTerrainTypeData (function)
[source]Spring.SetTerrainTypeData(integer, number?, number?, number?, number?) -> boolean?Parameters
integertypeIndexnumber?speedTanks- (Default: nil)
number?speedKBOts- (Default: nil)
number?speedHovers- (Default: nil)
number?speedShips- (Default: nil)
Returns
Spring.SetSquareBuildingMask (function)
[source]Spring.SetSquareBuildingMask(integer, integer, integer) -> nilParameters
Returns
nilSee- also buildingMask unitdef tag.
Spring.UnitWeaponFire (function)
[source]Spring.UnitWeaponFire(UnitID, integer) -> nilParameters
Returns
Spring.UnitWeaponHoldFire (function)
[source]Spring.UnitWeaponHoldFire(UnitID, integer) -> nilParameters
Returns
Spring.ForceUnitCollisionUpdate (function)
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]
Spring.ForceUnitCollisionUpdate(UnitID) -> nilParameters
Returns
Spring.UnitAttach (function)
[source]Spring.UnitAttach(UnitID, UnitID, integer, boolean?) -> nilParameters
UnitIDtransporterIDUnitIDpassengerIDintegerpieceNumboolean?force
Returns
Spring.UnitDetach (function)
[source]Spring.UnitDetach(UnitID) -> nilParameters
Returns
Spring.UnitDetachFromAir (function)
[source]Spring.UnitDetachFromAir(UnitID) -> nilParameters
Returns
Spring.SetUnitLoadingTransport (function)
Disables collisions between the two units to allow colvol intersection during the approach.
[source]
Spring.SetUnitLoadingTransport(UnitID, UnitID) -> nilParameters
Returns
Spring.SpawnProjectile (function)
[source]Spring.SpawnProjectile(WeaponDefID, ProjectileParams) -> ProjectileID?Parameters
Returns
Spring.DeleteProjectile (function)
Silently removes projectiles (no explosion).
[source]
Spring.DeleteProjectile(ProjectileID) -> nilParameters
Returns
Spring.SpawnExplosion (function)
[source]Spring.SpawnExplosion(number?, number?, number?, number?, number?, number?, ExplosionParams?) -> nilParameters
number?posX- (Default:
0) number?posY- (Default:
0) number?posZ- (Default:
0) number?dirX- (Default:
0) number?dirY- (Default:
0) number?dirZ- (Default:
0) ExplosionParams?explosionParams
Returns
Spring.SpawnCEG (function)
[source]Spring.SpawnCEG(string, number?, number?, number?, number?, number?, number?, number?, number?) -> boolean?, integerParameters
stringcegnamenumber?posX- (Default:
0) number?posY- (Default:
0) number?posZ- (Default:
0) number?dirX- (Default:
0) number?dirY- (Default:
0) number?dirZ- (Default:
0) number?radius- (Default:
0) number?damage- (Default:
0)
Returns
Spring.SpawnSFX (function)
Equal to the UnitScript versions of EmitSFX, but takes position and direction arguments (in either unit- or piece-space) instead of a piece index.
[source]
Spring.SpawnSFX(UnitID?, integer?, number?, number?, number?, number?, number?, number?, number?, number?, boolean?) -> boolean?Parameters
UnitID?unitID- (Default:
0) integer?sfxID- (Default:
0) number?posX- (Default:
0) number?posY- (Default:
0) number?posZ- (Default:
0) number?dirX- (Default:
0) number?dirY- (Default:
0) number?dirZ- (Default:
0) number?radius- (Default:
0) number?damage- (Default:
0) boolean?absolute
Returns
boolean?success
Spring.SetNoPause (function)
[source]Spring.SetNoPause(boolean) -> nilParameters
booleannoPause
Returns
Spring.SetExperienceGrade (function)
Defines how often Callins.UnitExperience will be called.
[source]
Spring.SetExperienceGrade(number, number?, number?, number?) -> nilParameters
numberexpGradenumber?ExpPowerScalenumber?ExpHealthScalenumber?ExpReloadScale
Returns
Spring.SetRadarErrorParams (function)
[source]Spring.SetRadarErrorParams(AllyTeamID, number, number?, number?) -> nilParameters
AllyTeamIDallyTeamIDnumberallyteamErrorSizenumber?baseErrorSizenumber?baseErrorMult
Returns
Spring.EditUnitCmdDesc (function)
[source]Spring.EditUnitCmdDesc(UnitID, integer, CommandDescription) -> nilParameters
Spring.InsertUnitCmdDesc (function)
Insert a command description at a specific index.
[source]
Spring.InsertUnitCmdDesc(UnitID, integer, CommandDescription) -> nilParameters
Spring.InsertUnitCmdDesc (function overload 1)
Insert a command description at the last position.
[source]
Spring.InsertUnitCmdDesc(UnitID, CommandDescription) -> nilParameters
Spring.RemoveUnitCmdDesc (function)
[source]Spring.RemoveUnitCmdDesc(UnitID, integer?) -> nilParameters
Spring.IsCheatingEnabled (function)
[source]Spring.IsCheatingEnabled() -> booleanReturns
booleanenabled
Spring.IsGodModeEnabled (function)
[source]Spring.IsGodModeEnabled() -> booleanReturns
booleanenabled
Spring.IsDevLuaEnabled (function)
[source]Spring.IsDevLuaEnabled() -> booleanReturns
booleanenabled
Spring.IsEditDefsEnabled (function)
[source]Spring.IsEditDefsEnabled() -> booleanReturns
booleanenabled
Spring.IsNoCostEnabled (function)
[source]Spring.IsNoCostEnabled() -> booleanReturns
booleanenabled
Spring.GetGlobalLos (function)
[source]Spring.GetGlobalLos(TeamID?) -> booleanParameters
Returns
booleanenabled
Spring.AreHelperAIsEnabled (function)
[source]Spring.AreHelperAIsEnabled() -> booleanReturns
booleanenabled
Spring.FixedAllies (function)
[source]Spring.FixedAllies() -> boolean?Returns
boolean?enabled
Spring.IsGameOver (function)
[source]Spring.IsGameOver() -> booleanReturns
booleanisGameOver
Spring.GetGameFrame (function)
[source]Spring.GetGameFrame() -> integer, integerReturns
Spring.GetGameSeconds (function)
[source]Spring.GetGameSeconds() -> numberReturns
numberseconds
Spring.GetTidal (function)
[source]Spring.GetTidal() -> numberReturns
numbertidalStrength
Spring.GetWind (function)
[source]Spring.GetWind() -> number, number, number, number, number, number, numberReturns
numberwindSpeedXnumberwindSpeedY- (Always 0)
numberwindSpeedZnumberwindStrength- (Length of windSpeed)
numberwindDirX- (Normalized windSpeed)
numberwindDirY- (Always 0)
numberwindDirZ
Spring.GetGameRulesParams (function)
[source]Spring.GetGameRulesParams() -> RulesParamsReturns
RulesParamsrulesParams- map with rules names as key and values as values
Spring.GetTeamRulesParams (function)
[source]Spring.GetTeamRulesParams(TeamID) -> RulesParamsParameters
Returns
RulesParamsrulesParams- map with rules names as key and values as values
Spring.GetPlayerRulesParams (function)
[source]Spring.GetPlayerRulesParams(PlayerID) -> RulesParamsParameters
Returns
RulesParamsrulesParams- map with rules names as key and values as values
Spring.GetUnitRulesParams (function)
[source]Spring.GetUnitRulesParams(UnitID) -> RulesParamsParameters
Returns
RulesParamsrulesParams- map with rules names as key and values as values
Spring.GetFeatureRulesParams (function)
[source]Spring.GetFeatureRulesParams(FeatureID) -> RulesParamsParameters
Returns
RulesParamsrulesParams- map with rules names as key and values as values
Spring.GetGameRulesParam (function)
[source]Spring.GetGameRulesParam(string) -> (number|boolean|string)?Parameters
stringname- rules-parameter key (only this argument is read)
Returns
(number|boolean|string)?value
Spring.GetTeamRulesParam (function)
[source]Spring.GetTeamRulesParam(TeamID, (number|string)) -> (number|string)?Parameters
Returns
(number|string)?value
Spring.GetPlayerRulesParam (function)
[source]Spring.GetPlayerRulesParam(PlayerID, (number|string)) -> (number|string)?Parameters
Returns
(number|string)?value
Spring.GetUnitRulesParam (function)
[source]Spring.GetUnitRulesParam(UnitID, (number|string)) -> (number|string)?Parameters
Returns
(number|string)?value
Spring.GetFeatureRulesParam (function)
[source]Spring.GetFeatureRulesParam(FeatureID, (number|string)) -> (number|string)?Parameters
Returns
(number|string)?value
Spring.GetMapOption (function)
[source]Spring.GetMapOption(string) -> stringParameters
stringmapOption
Returns
stringvalue- Value of
modOption.
Spring.GetMapOptions (function)
[source]Spring.GetMapOptions() -> table<string,string>Returns
table<string,string>mapOptions- Table with options names as keys and values as values.
Spring.GetModOption (function)
[source]Spring.GetModOption(string) -> stringParameters
stringmodOption
Returns
stringvalue- Value of
modOption.
Spring.GetModOptions (function)
[source]Spring.GetModOptions() -> table<string,string>Returns
table<string,string>modOptions- Table with options names as keys and values as values.
Spring.GetHeadingFromVector (function)
[source]Spring.GetHeadingFromVector(number, number) -> integerParameters
Returns
integerheading
Spring.GetVectorFromHeading (function)
[source]Spring.GetVectorFromHeading(integer) -> number, numberParameters
integerheading
Returns
Spring.GetFacingFromHeading (function)
[source]Spring.GetFacingFromHeading(integer) -> FacingIntegerParameters
integerheading
Returns
Spring.GetHeadingFromFacing (function)
[source]Spring.GetHeadingFromFacing(FacingInteger) -> integerParameters
Returns
integerheading
Spring.GetSideData (function)
[source]Spring.GetSideData(string) -> string?, string?Parameters
stringsideName- Case-insensitive side name.
Returns
Spring.GetSideData (function overload 1)
[source]Spring.GetSideData(integer) -> string?, string?, string?Parameters
integersideID
Returns
Spring.GetSideData (function overload 2)
[source]Spring.GetSideData() -> SideSpec[]Returns
Spring.GetGaiaTeamID (function)
[source]Spring.GetGaiaTeamID() -> TeamIDReturns
Spring.GetAllyTeamStartBox (function)
[source]Spring.GetAllyTeamStartBox(AllyTeamID) -> number?, number?, number?, number?Parameters
Returns
Spring.GetTeamStartPosition (function)
[source]Spring.GetTeamStartPosition(TeamID) -> number?, number?, number?Parameters
Returns
Spring.GetMapStartPositions (function)
[source]Spring.GetMapStartPositions() -> float3[]Returns
float3[]startPositions- array of positions indexed by teamID
Spring.GetAllyTeamList (function)
[source]Spring.GetAllyTeamList() -> AllyTeamID[]Returns
Spring.GetTeamList (function)
Get all team IDs.
[source]
Spring.GetTeamList(unknown) -> TeamID[]Parameters
unknownallyTeamID- (Default:
-1)
Returns
Spring.GetTeamList (function overload 1)
Get team IDs in a specific ally team.
[source]
Spring.GetTeamList(AllyTeamID) -> TeamID[]?Parameters
AllyTeamIDallyTeamID- The ally team ID to filter teams by. A value less than 0 will return all teams.
Returns
Spring.GetPlayerList (function)
[source]Spring.GetPlayerList(TeamID?, boolean?) -> PlayerID[]?Parameters
TeamID?teamID- (Default:
-1) to filter by when >= 0 boolean?active- (Default:
false) whether to filter only active teams
Returns
Spring.GetTeamInfo (function)
[source]Spring.GetTeamInfo(TeamID, boolean?) -> TeamID?, PlayerID, number, number, string, AllyTeamID, number, table<string,string>Parameters
TeamIDteamIDboolean?getTeamKeys- (Default:
true) whether to return the customTeamKeys table
Returns
TeamID?teamIDPlayerIDleadernumberisDeadnumberhasAIstringsideAllyTeamIDallyTeamnumberincomeMultipliertable<string,string>customTeamKeys- when getTeamKeys is true, otherwise nil
Spring.GetTeamAllyTeamID (function)
[source]Spring.GetTeamAllyTeamID(TeamID) -> AllyTeamID?Parameters
Returns
Spring.GetTeamResources (function)
[source]Spring.GetTeamResources(TeamID, ResourceName) -> number?, number, number, number, number, number, number, number, numberParameters
Returns
number?currentLevel- The current amount of the resource that the team has in storage at this moment
numberstorage- The maximum storage capacity for the resource.
numberpull- The total amount of the resource that is being requested/used by all units and buildings per second, regardless of whether the resource is actually available.
numberincome- The total amount of the resource being generated per second from all sources (e.g., mines, generators, reclaiming, etc.).
numberexpense- The total amount of the resource actually being spent per second. This is the real consumption, which may be less than pull if there isn’t enough resource available.
numbershare- The fraction (0.0 to 1.0) of the storage that the team is sharing with allied teams. A value of 0.0 means 100% of storage is shared, while 1.0 means only any excess is shared.
numbersent- The total amount of the resource that has actually been sent to allies (via sharing or manual transfer).
numberreceived- The total amount of the resource that has actually been received from allies (via sharing or manual transfer).
numberexcess- The amount of the resource that was lost due to storage overflow (wasted).
Spring.GetTeamUnitStats (function)
[source]Spring.GetTeamUnitStats(TeamID) -> integer?, integer, integer, integer, integer, integerParameters
Returns
integer?killedintegerdiedintegercapturedByintegercapturedFromintegerreceivedintegersent
Spring.GetTeamResourceStats (function)
[source]Spring.GetTeamResourceStats(TeamID, ResourceName) -> number?, number, number, number, numberParameters
Returns
Spring.GetTeamDamageStats (function)
Gets team damage dealt/received totals
[source]
Returns a team’s damage stats. Note that all damage is counted, including self-inflicted and unconfirmed out-of-sight.
Spring.GetTeamDamageStats(TeamID) -> number, numberParameters
Returns
numberdamageDealtnumberdamageReceived
Spring.GetTeamStatsHistory (function)
Get the number of history entries.
[source]
Spring.GetTeamStatsHistory(TeamID) -> integer?Parameters
Returns
integer?historyCount- The number of history entries, or
nilif unable to resolve team.
Spring.GetTeamStatsHistory (function overload 1)
Get team stats history.
[source]
Spring.GetTeamStatsHistory(TeamID, integer, integer?) -> TeamStats[]Parameters
TeamIDteamIDintegerstartIndexinteger?endIndex- (Default: startIndex)
Returns
TeamStats[]teamStatsHistory- The team stats history, or
nilif unable to resolve team.
Spring.GetTeamLuaAI (function)
[source]Spring.GetTeamLuaAI(TeamID) -> stringParameters
Returns
Spring.GetTeamMaxUnits (function)
Returns a team’s unit cap.
Also returns the current unit count for readable teams as the 2nd value.
[source]
Spring.GetTeamMaxUnits(TeamID) -> integer, integer?Parameters
Returns
integermaxUnitsinteger?currentUnits
Spring.GetPlayerInfo (function)
[source]Spring.GetPlayerInfo(PlayerID, boolean?) -> string, boolean, boolean, TeamID, AllyTeamID, number, number, string, integer, boolean, { [string]: string }, booleanParameters
PlayerIDplayerIDboolean?getPlayerOpts- (Default:
true) whether to return custom player options
Returns
stringnamebooleanactivebooleanspectatorTeamIDteamIDAllyTeamIDallyTeamIDnumberpingTimenumbercpuUsagestringcountryintegerrankbooleanhasSkirmishAIsInTeam{ [string]: string }playerOpts- when playerOpts is true
booleandesynced
Spring.GetPlayerControlledUnit (function)
Returns unit controlled by player on FPS mode
[source]
Spring.GetPlayerControlledUnit(PlayerID) -> UnitID?Parameters
Returns
Spring.GetAIInfo (function)
[source]Spring.GetAIInfo(TeamID) -> integer, string, PlayerID, string, string, table<string,string>Parameters
Returns
integerskirmishAIIDstringnamePlayerIDhostingPlayerIDstringshortName- When synced
“SYNCED_NOSHORTNAME”, otherwise the AI shortname or“UNKNOWN”. stringversion- When synced
“SYNCED_NOVERSION”, otherwise the AI version or“UNKNOWN”. table<string,string>options
Spring.GetAllyTeamInfo (function)
[source]Spring.GetAllyTeamInfo(AllyTeamID) -> table<string,string>?Parameters
Returns
Spring.AreTeamsAllied (function)
[source]Spring.AreTeamsAllied(TeamID, TeamID) -> boolean?Parameters
Returns
Spring.ArePlayersAllied (function)
[source]Spring.ArePlayersAllied(PlayerID, PlayerID) -> boolean?Parameters
Returns
Spring.GetAllUnits (function)
Get a list of all unitIDs
[source]
Note that when called from a widget, this also returns units that are only radar blips.
For units that are radar blips, you may want to check if they are in los, as GetUnitDefID() will still return true if they have previously been seen.
See UnsyncedRead.GetVisibleUnits
Spring.GetAllUnits() -> UnitID[]Returns
Spring.GetTeamUnits (function)
[source]Spring.GetTeamUnits(TeamID) -> UnitID[]?Parameters
Returns
Spring.GetTeamUnitsSorted (function)
[source]Spring.GetTeamUnitsSorted(TeamID) -> table<UnitDefID,UnitID[]>Parameters
Returns
table<UnitDefID,UnitID[]>unitsByDef- A table where keys are unitDefIDs and values are arrays of unitIDs
Spring.GetTeamUnitsCounts (function)
[source]Spring.GetTeamUnitsCounts(TeamID) -> table<UnitDefID,integer>?Parameters
Returns
table<UnitDefID,integer>?countByUnit- A table where keys are unitDefIDs and values are counts.
Spring.GetTeamUnitsByDefs (function)
[source]Spring.GetTeamUnitsByDefs(TeamID, (UnitDefID|UnitDefID[])) -> UnitID[]?Parameters
Returns
Spring.GetTeamUnitDefCount (function)
[source]Spring.GetTeamUnitDefCount(TeamID, UnitDefID) -> integer?Parameters
Returns
integer?count
Spring.GetTeamUnitCount (function)
[source]Spring.GetTeamUnitCount(TeamID) -> integer?Parameters
Returns
integer?count
Spring.GetUnitsInRectangle (function)
[source]Spring.GetUnitsInRectangle(number, number, number, number, integer?) -> UnitID[]Parameters
numberxminnumberzminnumberxmaxnumberzmaxinteger?allegiance
Returns
Spring.GetUnitsInBox (function)
[source]Spring.GetUnitsInBox(number, number, number, number, number, number, integer?) -> UnitID[]Parameters
Returns
Spring.GetUnitsInCylinder (function)
[source]Spring.GetUnitsInCylinder(number, number, number, TeamID?) -> UnitID[]Parameters
Returns
Spring.GetUnitsInSphere (function)
[source]Spring.GetUnitsInSphere(number, number, number, number) -> UnitID[]Parameters
Returns
Spring.GetUnitsInPlanes (function)
[source]
Plane normals point towards accepted space, so the acceptance criteria for each plane is:
radius = unit radius
px, py, pz = unit position
[(nx * px) + (ny * py) + (nz * pz) + (d - radius)] <= 0
Spring.GetUnitsInPlanes(Plane[], integer?) -> UnitID[]Parameters
Plane[]planesinteger?allegiance
Returns
Spring.GetUnitArrayCentroid (function)
Returns the centroid of an array of units
Returns nil for an empty array
[source]
Spring.GetUnitArrayCentroid(table) -> number, number, numberParameters
tableunits- { unitID, unitID, … }
Returns
Spring.GetUnitMapCentroid (function)
Returns the centroid of a map of units
Returns nil for an empty map
[source]
Spring.GetUnitMapCentroid(table) -> number, number, numberParameters
tableunits- { [unitID] = true, [unitID] = true, … }
Returns
Spring.GetUnitNearestAlly (function)
[source]Spring.GetUnitNearestAlly(UnitID, number?) -> UnitID?Parameters
Returns
Spring.GetUnitNearestEnemy (function)
[source]Spring.GetUnitNearestEnemy(UnitID, number?, boolean?, boolean?, boolean?) -> UnitID?Parameters
UnitIDunitIDnumber?range- (Default:
1.0e9) range of the search. boolean?useLOS- (Default:
true) requires LOS/radar visibility of allied team. boolean?sphereDistTest- (Default:
false) determines if using spherical(3D, includes target radius) or cylindrical(2D) search. boolean?checkSightDist- (Default:
false) determine if during filter process, if candidate distance to be within candidate LOS radius.
Returns
Spring.GetClosestEnemyUnit (function)
Returns the enemy unit closest to a position.
[source]
Spring.GetClosestEnemyUnit(number, number, number, number?, AllyTeamID?, boolean?, boolean?, boolean?) -> UnitID?Parameters
numberx- x coordinate of query position
numbery- y coordinate of query position
numberz- z coordinate of query position
number?range- (Default:
1.0e9) AllyTeamID?allyTeamID- whose enemies to consider, always own in non-full-read contexts
boolean?useLOS- (Default: true) requires LOS/radar visibility or not. Always true in non-full-read contexts
boolean?sphereDistTest- (Default:
false) For non-LOS mode only. Determines if using spherical(3D, includes target radius) or cylindrical(2D) search boolean?checkSightDist- (Default:
false) For non-LOS mode only. Determine if during filter process, if candidate distance to be within candidate LOS radius
Returns
Spring.GetFeaturesInRectangle (function)
[source]Spring.GetFeaturesInRectangle(number, number, number, number) -> FeatureID[]Parameters
Returns
Spring.GetFeaturesInSphere (function)
[source]Spring.GetFeaturesInSphere(number, number, number, number) -> FeatureID[]Parameters
Returns
Spring.GetFeaturesInCylinder (function)
[source]Spring.GetFeaturesInCylinder(number, number, number, integer?) -> FeatureID[]Parameters
numberxnumberznumberradiusinteger?allegiance
Returns
Spring.GetAllProjectiles (function)
[source]Spring.GetAllProjectiles(boolean?, boolean?) -> ProjectileID[]Parameters
boolean?excludeWeaponProjectiles- (Default:
false) boolean?excludePieceProjectiles- (Default:
false)
Returns
Spring.GetProjectilesInRectangle (function)
[source]Spring.GetProjectilesInRectangle(number, number, number, number, boolean?, boolean?) -> ProjectileID[]Parameters
numberxminnumberzminnumberxmaxnumberzmaxboolean?excludeWeaponProjectiles- (Default:
false) boolean?excludePieceProjectiles- (Default:
false)
Returns
Spring.GetProjectilesInSphere (function)
[source]Spring.GetProjectilesInSphere(number, number, number, number, boolean?, boolean?) -> ProjectileID[]Parameters
numberxnumberynumberznumberradiusboolean?excludeWeaponProjectiles- (Default: false)
boolean?excludePieceProjectiles- (Default: false)
Returns
Spring.ValidUnitID (function)
Get whether a unitID is valid
Dead units are not valid.
[source]
Spring.ValidUnitID(UnitID) -> booleanParameters
Returns
Spring.GetUnitStates (function)
Gets various states for the given unit.
[source]
Spring.GetUnitStates(UnitID, false, true, true) -> number, number, number, boolean, boolean, boolean, boolean, boolean?, boolean?Parameters
UnitIDunitIDfalseretTable- Return a table instead of multiple values. Defaults to
true truebinState- Include binary state (activated, etc)? Defaults to
retTable trueamtState- Include Air/Hover MoveType state if available? Defaults to
retTable
Returns
numberfireStatenumbermoveStatenumberautorepairlevel-1if not setbooleanrepeatbooleancloakbooleanactivebooleantrajectoryboolean?autoLandboolean?loopbackAttack
Spring.GetUnitArmored (function)
[source]Spring.GetUnitArmored(UnitID) -> boolean?, numberParameters
Returns
boolean?armorednumberarmorMultiple
Spring.GetUnitIsActive (function)
[source]Spring.GetUnitIsActive(UnitID) -> boolean?Parameters
Returns
boolean?isActive
Spring.GetUnitIsCloaked (function)
[source]Spring.GetUnitIsCloaked(UnitID) -> boolean?Parameters
Returns
boolean?isCloaked
Spring.GetUnitSeismicSignature (function)
[source]Spring.GetUnitSeismicSignature(UnitID) -> number?Parameters
Returns
number?seismicSignature
Spring.GetUnitLeavesGhost (function)
Get whether unit leaves static radar ghosts.
[source]
Spring.GetUnitLeavesGhost() -> number?Returns
Spring.GetUnitSelfDTime (function)
[source]Spring.GetUnitSelfDTime(UnitID) -> integer?Parameters
Returns
integer?selfDTime
Spring.GetUnitStockpile (function)
[source]Spring.GetUnitStockpile(UnitID) -> integer?, integer?, number?Parameters
Returns
integer?numStockpiledinteger?numStockpileQuednumber?buildPercent
Spring.GetUnitSensorRadius (function)
[source]Spring.GetUnitSensorRadius(UnitID, string) -> integer?Parameters
Returns
integer?radius
Spring.GetUnitPosErrorParams (function)
[source]Spring.GetUnitPosErrorParams(UnitID, AllyTeamID?) -> number?, number, number, number, number, number, integer, booleanParameters
Returns
number?posErrorVectorXnumberposErrorVectorYnumberposErrorVectorZnumberposErrorDeltaXnumberposErrorDeltaYnumberposErrorDeltaZintegernextPosErrorUpdatebooleanposErrorBit
Spring.GetUnitTooltip (function)
[source]Spring.GetUnitTooltip(UnitID) -> string?Parameters
Returns
Spring.GetUnitDefID (function)
[source]Spring.GetUnitDefID(UnitID) -> UnitDefID?Parameters
Returns
Spring.GetUnitMoveDefID (function)
[source]
Returns a numerical movedef ID and its name. For things that have
no movedef, returns false (to tell them apart from unreadable
units while keeping the if not x pattern usable). For now, the
numerical ID is not too useful so you can use the name, but this
may get deprecated at some point.
Spring.GetUnitMoveDefID(UnitID) -> (integer|false)?, string?Parameters
Returns
(integer|false)?moveDefIDstring?moveDefName
Spring.GetUnitTeam (function)
[source]Spring.GetUnitTeam(UnitID) -> TeamID?Parameters
Returns
Spring.GetUnitAllyTeam (function)
[source]Spring.GetUnitAllyTeam(UnitID) -> AllyTeamID?Parameters
Returns
Spring.GetUnitNeutral (function)
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.
Spring.GetUnitNeutral(UnitID) -> boolean?Parameters
Returns
Spring.GetUnitHealth (function)
[source]Spring.GetUnitHealth(UnitID) -> number?, number, number, number, numberParameters
Returns
number?healthnumbermaxHealthnumberparalyzeDamagenumbercaptureProgressnumberbuildProgress- between 0.0-1.0
Spring.GetUnitIsDead (function)
[source]Spring.GetUnitIsDead(UnitID) -> boolean?Parameters
Returns
Spring.GetUnitIsStunned (function)
Checks whether a unit is disabled and can’t act
The first return value is a simple OR of the following ones, any of those conditions is sufficient to disable the unit.
Note that EMP and being transported are mechanically the same and thus lumped together. Use other callouts to differentiate them if you need to.
[source]
Spring.GetUnitIsStunned(UnitID) -> boolean?, boolean, booleanParameters
Returns
boolean?stunnedOrBuilt- unit is disabled
booleanstunned- unit is either stunned via EMP or being transported by a non-fireplatform
booleanbeingBuilt- unit is under construction
Spring.GetUnitIsBeingBuilt (function)
[source]Spring.GetUnitIsBeingBuilt(UnitID) -> boolean, numberParameters
Returns
booleanbeingBuiltnumberbuildProgress
Spring.GetUnitResources (function)
[source]Spring.GetUnitResources(UnitID) -> number?, number, number, numberParameters
Returns
number?metalMakenumbermetalUsenumberenergyMakenumberenergyUse
Spring.GetUnitStorage (function)
[source]Spring.GetUnitStorage(UnitID) -> number, numberParameters
Returns
numbermetalStorage- Unit’s metal storage
numberenergyStorage- Unit’s energy storage
Spring.GetUnitCosts (function)
[source]Spring.GetUnitCosts(UnitID) -> number?, number, numberParameters
Returns
number?buildTimenumbermetalCostnumberenergyCost
Spring.GetUnitCostTable (function)
[source]Spring.GetUnitCostTable(UnitID) -> ResourceCost?, number?Parameters
Returns
ResourceCost?cost- The cost of the unit, or
nilif invalid. number?buildTime- The build time the unit, or
nilif invalid.
Spring.GetUnitMetalExtraction (function)
[source]Spring.GetUnitMetalExtraction(UnitID) -> number?Parameters
Returns
number?metalExtraction
Spring.GetUnitExperience (function)
[source]Spring.GetUnitExperience(UnitID) -> number, numberParameters
Returns
Spring.GetUnitHeight (function)
[source]Spring.GetUnitHeight(UnitID) -> number?Parameters
Returns
Spring.GetUnitRadius (function)
[source]Spring.GetUnitRadius(UnitID) -> number?Parameters
Returns
Spring.GetUnitBuildeeRadius (function)
[source]
Gets the unit’s radius for when targeted by build, repair, reclaim-type commands.
Spring.GetUnitBuildeeRadius(UnitID) -> number?Parameters
Returns
Spring.GetUnitMass (function)
[source]Spring.GetUnitMass(UnitID) -> number?Parameters
Returns
Spring.GetUnitPosition (function)
[source]Spring.GetUnitPosition(UnitID, boolean?, boolean?) -> number?, number, number, number?, number, number, number?, number, numberParameters
UnitIDunitIDboolean?midPos- (Default:
false) return midpoint as well boolean?aimPos- (Default:
false) return aimpoint as well
Returns
number?basePointXnumberbasePointYnumberbasePointZnumber?midPointXnumbermidPointYnumbermidPointZnumber?aimPointXnumberaimPointYnumberaimPointZ
Spring.GetUnitBasePosition (function)
[source]
The same as Spring.GetUnitPosition, but without the optional midpoint calculations.
Spring.GetUnitBasePosition(UnitID) -> number?, number?, number?Parameters
Returns
Spring.GetUnitVectors (function)
[source]Spring.GetUnitVectors(UnitID) -> float3?, float3, float3Parameters
Returns
Spring.GetUnitRotation (function)
[source]
Note: PYR order
Spring.GetUnitRotation(UnitID) -> number, number, numberParameters
Returns
Spring.GetUnitDirection (function)
[source]Spring.GetUnitDirection(UnitID) -> number, number, number, number, number, number, number, number, numberParameters
Returns
numberfrontDirXnumberfrontDirYnumberfrontDirZnumberrightDirXnumberrightDirYnumberrightDirZnumberupDirXnumberupDirYnumberupDirZ
Spring.GetUnitHeading (function)
[source]Spring.GetUnitHeading(UnitID, boolean?) -> numberParameters
UnitIDunitIDboolean?convertToRadians- (Default:
false)
Returns
numberheading
Spring.GetUnitVelocity (function)
[source]Spring.GetUnitVelocity(UnitID) -> nilParameters
Spring.GetUnitBuildFacing (function)
[source]Spring.GetUnitBuildFacing(UnitID) -> FacingInteger?Parameters
Returns
FacingInteger?buildFacing- facing of footprint,
0-3
Spring.GetUnitIsBuilding (function)
Checks whether a unit is currently building another (NOT for checking if it’s a structure)
[source]
Works for both mobile builders and factories.
Spring.GetUnitIsBuilding(UnitID) -> UnitID?Parameters
Returns
Spring.GetUnitWorkerTask (function)
Checks a builder’s current task
[source]
Checks what a builder is currently doing. This is not the same as Spring.GetUnitCurrentCommand, because you can have a command at the front of the queue and not be doing it (for example because the target is still too far away), and on the other hand you can also be doing a task despite not having it in front of the queue (for example you’re Guarding another builder who does). Also, it resolves the Repair command into either actual repair, or construction assist (in which case it returns the appropriate “build” command). Only build-related commands are returned (no Move or any custom commands).
The possible commands returned are repair, reclaim, resurrect, capture, restore, and build commands (negative buildee unitDefID).
Spring.GetUnitWorkerTask(UnitID) -> integer, integerParameters
Returns
Spring.GetUnitEffectiveBuildRange (function)
[source]
Useful for setting move goals manually.
Spring.GetUnitEffectiveBuildRange(UnitID, UnitDefID?) -> numberParameters
Returns
numbereffectiveBuildRange- counted to the center of prospective buildee; buildRange if buildee nil
Spring.GetUnitCurrentBuildPower (function)
[source]Spring.GetUnitCurrentBuildPower(UnitID) -> number?Parameters
Returns
number?buildPowernilif the unit is neither a builder nor a factory.
Spring.GetUnitHarvestStorage (function)
Get a unit’s carried resources
[source]
Checks resources being carried internally by the unit.
Spring.GetUnitHarvestStorage(UnitID) -> number, number, number, numberParameters
Returns
numberstoredMetalnumbermaxStoredMetalnumberstoredEnergynumbermaxStoredEnergy
Spring.GetUnitBuildParams (function)
[source]Spring.GetUnitBuildParams(UnitID, ("buildRange"|"buildDistance"|"buildRange3D")) -> (number|boolean)?Parameters
Returns
(number|boolean)?value- number for
“buildRange”or“buildDistance”, boolean for“buildRange3D”, otherwisenilfor unrecognized paramName or not allied builder unit.
Spring.GetUnitInBuildStance (function)
Is builder in build stance
[source]
Checks if a builder is in build stance, i.e. can create nanoframes. Returns nil for non-builders.
Spring.GetUnitInBuildStance(UnitID) -> booleanParameters
Returns
booleaninBuildStance
Spring.GetUnitNanoPieces (function)
Get construction FX attachment points
[source]
Returns an array of pieces which represent construction points. Default engine construction FX (nano spray) will originate there.
Only works on builders and factories, returns nil (NOT empty table) for other units.
Spring.GetUnitNanoPieces(UnitID) -> integer[]Parameters
Returns
integer[]pieceArray
Spring.GetUnitTransporter (function)
Get the transport carrying the unit
[source]
Returns the unit ID of the transport, if any. Returns nil if the unit is not being transported.
Spring.GetUnitTransporter(UnitID) -> UnitID?Parameters
Returns
Spring.GetUnitIsTransporting (function)
Get units being transported
[source]
Spring.GetUnitIsTransporting(UnitID) -> UnitID[]?Parameters
Returns
Spring.GetUnitShieldState (function)
[source]Spring.GetUnitShieldState(UnitID, integer?) -> integer, numberParameters
Returns
integerisEnabled- Warning, number not boolean. 0 or 1
numbercurrentPower
Spring.GetUnitFlanking (function)
[source]
When called without a key, returns every value. When called with one of
“mode”, “moveFactor”, “minDamage” or “maxDamage” returns just that
single number, and with “dir” returns just dirX, dirY, dirZ.
Spring.GetUnitFlanking(UnitID) -> number, number, number, number, number, number, number, numberParameters
Returns
numbermodenumbermoveFactornumberminDamagenumbermaxDamagenumberdirXnumberdirYnumberdirZnumbermobility- The amount of mobility the unit has collected up to now.
Spring.GetUnitMaxRange (function)
Get a unit’s engagement range
[source]
Returns the range at which a unit will stop to engage. By default this is the highest among the unit’s weapon ranges (hence name), but can be changed dynamically. Also note that unarmed units ignore this.
Spring.GetUnitMaxRange(UnitID) -> numberParameters
Returns
numbermaxRange
Spring.GetUnitWeaponState (function)
Check the state of a unit’s weapon
[source]
Available states to poll: “reloadFrame” (frame on which the weapon will be ready to fire), “reloadSpeed” (reload time in seconds), “range” (in elmos), “autoTargetRangeBoost” (predictive aiming range buffer, in elmos), “projectileSpeed” (in elmos/frame), “reloadTimeXP” (reload time after XP bonus, in seconds), “reaimTime” (frames between AimWeapon calls), “burst” (shots in a burst), “burstRate” (delay between shots in a burst, in seconds), “projectiles” (projectiles per shot), “salvoLeft” (shots remaining in ongoing burst), “nextSalvo” (simframe of the next shot in an ongoing burst), “accuracy” (INaccuracy after XP bonus), “sprayAngle” (spray angle after XP bonus), “targetMoveError” (extra inaccuracy against moving targets, after XP bonus) “avoidFlags” (bitmask for targeting avoidance), “ttl” (number of seconds a projectile should live) “collisionFlags” (bitmask for collisions).
The state “salvoError” is an exception and returns a table: {x, y, z}, which represents the inaccuracy error of the ongoing burst.
Spring.GetUnitWeaponState(UnitID, integer, string?) -> numberParameters
Returns
numberstateValue
Spring.GetUnitWeaponDamages (function)
[source]Spring.GetUnitWeaponDamages(UnitID) -> nilParameters
Spring.GetUnitWeaponVectors (function)
[source]Spring.GetUnitWeaponVectors(UnitID, integer) -> number?, number, number, number, number, numberParameters
Returns
Spring.GetUnitWeaponTryTarget (function)
[source]Spring.GetUnitWeaponTryTarget(UnitID, integer, UnitID) -> booleanParameters
Returns
booleancanTarget
Spring.GetUnitWeaponTryTarget (function overload 1)
[source]Spring.GetUnitWeaponTryTarget(UnitID, integer, number, number, number) -> booleanParameters
Returns
booleancanTarget
Spring.GetUnitWeaponTestTarget (function)
[source]Spring.GetUnitWeaponTestTarget(UnitID, integer, UnitID) -> booleanParameters
UnitIDunitIDintegerweaponID- weapon number (1-based Lua index)
UnitIDtargetUnitID- enemy unit to test (when fewer than five arguments)
Returns
booleanvalidTarget
Spring.GetUnitWeaponTestTarget (function overload 1)
[source]Spring.GetUnitWeaponTestTarget(UnitID, integer, number, number, number) -> booleanParameters
UnitIDunitIDintegerweaponID- weapon number (1-based Lua index)
numbertargetX- world X to test (with
targetY,targetZ; used when at least five arguments are passed) numbertargetYnumbertargetZ
Returns
booleanvalidTarget
Spring.GetUnitWeaponTestRange (function)
[source]Spring.GetUnitWeaponTestRange(UnitID, integer, UnitID) -> booleanParameters
Returns
booleaninRange
Spring.GetUnitWeaponTestRange (function overload 1)
[source]Spring.GetUnitWeaponTestRange(UnitID, integer, number, number, number) -> booleanParameters
Returns
booleaninRange
Spring.GetUnitWeaponHaveFreeLineOfFire (function)
[source]Spring.GetUnitWeaponHaveFreeLineOfFire(UnitID, integer, UnitID) -> booleanParameters
Returns
booleanhaveFreeLineOfFire
Spring.GetUnitWeaponHaveFreeLineOfFire (function overload 1)
[source]Spring.GetUnitWeaponHaveFreeLineOfFire(UnitID, integer, number, number, number) -> booleanParameters
Returns
booleanhaveFreeLineOfFire
Spring.GetUnitWeaponHaveFreeLineOfFire (function overload 2)
[source]Spring.GetUnitWeaponHaveFreeLineOfFire(UnitID, integer, number, number, number, UnitID) -> booleanParameters
Returns
booleanhaveFreeLineOfFire
Spring.GetUnitWeaponHaveFreeLineOfFire (function overload 3)
[source]Spring.GetUnitWeaponHaveFreeLineOfFire(UnitID, integer, number, number, number, number, number, number) -> booleanParameters
UnitIDunitIDintegerweaponNumnumbersrcPosXnumbersrcPosYnumbersrcPosZnumbertgtPosXnumbertgtPosYnumbertgtPosZ
Returns
booleanhaveFreeLineOfFire
Spring.GetUnitWeaponCanFire (function)
[source]Spring.GetUnitWeaponCanFire(UnitID, integer, boolean?, boolean?, boolean?) -> booleanParameters
UnitIDunitIDintegerweaponNumboolean?ignoreAngleGoodboolean?ignoreTargetTypeboolean?ignoreRequestedDir
Returns
booleancanFire
Spring.GetUnitWeaponTarget (function)
Checks a weapon’s target
Note that this doesn’t need to reflect the unit’s Attack orders or such, and that weapons can aim individually unless slaved.
[source]
Spring.GetUnitWeaponTarget(UnitID, integer) -> 0, booleanParameters
Returns
0TargetType- none
booleanisUserTarget
Spring.GetUnitWeaponTarget (function overload 1)
Checks a weapon’s target
Note that this doesn’t need to reflect the unit’s Attack orders or such, and that weapons can aim individually unless slaved.
[source]
Spring.GetUnitWeaponTarget(UnitID, integer) -> 1, boolean, UnitIDParameters
Returns
1TargetType- unit
booleanisUserTargetUnitIDtargetUnitID
Spring.GetUnitWeaponTarget (function overload 2)
Checks a weapon’s target
Note that this doesn’t need to reflect the unit’s Attack orders or such, and that weapons can aim individually unless slaved.
[source]
Spring.GetUnitWeaponTarget(UnitID, integer) -> 2, boolean, float3Parameters
Returns
2TargetType- position
booleanisUserTargetfloat3targetPosition
Spring.GetUnitWeaponTarget (function overload 3)
Checks a weapon’s target
Note that this doesn’t need to reflect the unit’s Attack orders or such, and that weapons can aim individually unless slaved.
[source]
Spring.GetUnitWeaponTarget(UnitID, integer) -> 3, boolean, ProjectileIDParameters
Returns
3TargetType- projectileID
booleanisUserTargetProjectileIDtargetProjectileId
Spring.GetUnitEstimatedPath (function)
[source]Spring.GetUnitEstimatedPath(UnitID) -> nilParameters
Spring.GetUnitLastAttacker (function)
[source]Spring.GetUnitLastAttacker(UnitID) -> UnitID?Parameters
Returns
UnitID?attackerUnitIDnilif the unit has no last attacker or the attacker is not visible.
Spring.GetUnitLastAttackedPiece (function)
[source]Spring.GetUnitLastAttackedPiece(UnitID) -> nilParameters
Spring.GetUnitCollisionVolumeData (function)
[source]Spring.GetUnitCollisionVolumeData(UnitID) -> nilParameters
Spring.GetUnitPieceCollisionVolumeData (function)
[source]Spring.GetUnitPieceCollisionVolumeData(UnitID, integer) -> number?, number?, number?, number?, number?, number?, integer?, integer?, integer?, boolean?Parameters
UnitIDunitIDintegerpieceIndex- 1-based local-model piece index
Returns
number?scaleXnumber?scaleYnumber?scaleZnumber?offsetXnumber?offsetYnumber?offsetZinteger?volumeTypeinteger?testTypeinteger?primaryAxisboolean?disabled
Spring.GetUnitSeparation (function)
[source]Spring.GetUnitSeparation(UnitID, UnitID, boolean?, boolean?) -> number?Parameters
UnitIDunitID1UnitIDunitID2boolean?direction- (Default:
false) to subtract from, default unitID1 - unitID2 boolean?subtractRadii- (Default:
false) whether units radii should be subtracted from the total
Returns
Spring.GetUnitFeatureSeparation (function)
[source]Spring.GetUnitFeatureSeparation(UnitID, FeatureID, boolean?) -> numberParameters
UnitIDunitIDFeatureIDfeatureIDboolean?flat- (Default:
false) if true, XZ (2D) distance; otherwise 3D distance
Returns
numberdistance
Spring.GetUnitDefDimensions (function)
[source]Spring.GetUnitDefDimensions(UnitDefID) -> UnitDefDimensions?Parameters
Returns
Spring.GetCEGID (function)
[source]Spring.GetCEGID() -> integerReturns
integercegID
Spring.GetUnitBlocking (function)
[source]Spring.GetUnitBlocking(UnitID) -> boolean?, boolean, boolean, boolean, boolean, boolean, booleanParameters
Returns
boolean?isBlockingbooleanisSolidObjectCollidablebooleanisProjectileCollidablebooleanisRaySegmentCollidablebooleancrushablebooleanblockEnemyPushingbooleanblockHeightChanges
Spring.GetUnitMoveTypeData (function)
[source]Spring.GetUnitMoveTypeData(UnitID) -> nilParameters
Spring.GetUnitCurrentCommand (function)
Get a command from a units command queue.
For factories, this function uses the command queue automatically assigned to new units.
[source]
See Spring.GetFactoryCommands for getting factory build queue commands
Spring.GetUnitCurrentCommand(UnitID, integer?) -> CMD?, (integer|CommandOptionBit)?, integer?, number? ...Parameters
UnitIDunitID- unitID when invalid this function returns nil.
integer?cmdIndex- (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
Spring.GetUnitCommands (function)
Get the commands for a unit.
[source]
Same as Spring.GetCommandQueue
Spring.GetUnitCommands(UnitID, integer) -> Command[]Parameters
Returns
Spring.GetUnitCommands (function overload 1)
Get the count of commands for a unit.
[source]
Deprecated: This overload is deprecated, use Spring.GetUnitCommandCount(unitId) instead.
Spring.GetUnitCommands(UnitID, 0) -> integerParameters
Returns
integercmdCount- The number of commands in the unit queue.
Spring.GetFactoryCommands (function)
Get the number or list of commands for a factory
[source]
See Spring.GetFactoryCounts to get command counts grouped by cmdID.
Spring.GetFactoryCommands(UnitID, integer) -> Command[]Parameters
Returns
Spring.GetFactoryCommands (function overload 1)
Get the count of commands for a factory.
[source]
Deprecated: This overload is deprecated, use Spring.GetFactoryCommandCount(unitId) instead.
See Spring.GetFactoryCommandCount for replacement function.
Spring.GetFactoryCommands(UnitID, 0) -> integerParameters
Returns
integercmdCount- The number of commands in the factory queue.
Spring.GetUnitCommandCount (function)
Get the number of commands in a unit’s queue.
[source]
Spring.GetUnitCommandCount(UnitID) -> integerParameters
Returns
integercmdCount- The number of commands in the unit’s queue.
Spring.GetFactoryCommandCount (function)
Get the number of commands in a factory queue.
[source]
See Spring.GetFactoryCounts to get command counts grouped by cmdID.
Spring.GetFactoryCommandCount(UnitID) -> integerParameters
Returns
integercmdCount- The number of commands in the factory queue.
Spring.GetFactoryBuggerOff (function)
[source]Spring.GetFactoryBuggerOff(UnitID) -> boolean?, number, number, number, boolean, booleanParameters
Returns
boolean?boPerformnilif the unit does not exist or is not a factory.numberboOffsetnumberboRadiusnumberboRelHeadingbooleanboShericalbooleanboForced
Spring.GetFactoryCounts (function)
Gets the build queue of a factory
[source]
Spring.GetFactoryCounts(UnitID, integer?, boolean?) -> table<number,number>?Parameters
UnitIDunitIDinteger?count- (Default:
-1) Number of commands to retrieve,-1for all. boolean?addCmds- (Default:
false) Retrieve commands other than buildunit
Returns
table<number,number>?counts- Build queue count by
unitDefIDor-cmdID, ornilif unit is not found.
Spring.GetCommandQueue (function)
Get the commands for a unit.
[source]
Same as Spring.GetUnitCommands
Deprecated: Use Spring.GetUnitCommands instead.
Spring.GetCommandQueue(UnitID, integer) -> Command[]Parameters
UnitIDunitIDintegercount- Number of commands to return,
-1returns all commands,0returns command count.
Returns
Spring.GetCommandQueue (function overload 1)
Get the count of commands for a unit.
[source]
Same as Spring.GetUnitCommands
Deprecated: Use Spring.GetUnitCommandCount instead.
Spring.GetCommandQueue(UnitID, 0) -> integerParameters
Returns
integercmdCount- The number of commands in the unit queue.
Spring.GetFullBuildQueue (function)
Returns the build queue
[source]
Spring.GetFullBuildQueue(UnitID) -> table<UnitDefID,integer>?Parameters
Returns
table<UnitDefID,integer>?buildqueue- indexed by unitDefID with count values
Spring.GetRealBuildQueue (function)
Returns the build queue cleaned of things the unit can’t build itself
[source]
Spring.GetRealBuildQueue(UnitID) -> table<UnitDefID,integer>?Parameters
Returns
table<UnitDefID,integer>?buildqueue- indexed by unitDefID with count values
Spring.GetUnitCmdDescs (function)
[source]Spring.GetUnitCmdDescs(UnitID) -> nilParameters
Spring.FindUnitCmdDesc (function)
[source]Spring.FindUnitCmdDesc(UnitID, integer) -> integer?Parameters
Returns
Spring.ValidFeatureID (function)
[source]Spring.ValidFeatureID(FeatureID) -> booleanParameters
Returns
Spring.GetAllFeatures (function)
[source]Spring.GetAllFeatures() -> FeatureID[]Returns
Spring.GetFeatureDefID (function)
[source]Spring.GetFeatureDefID(FeatureID) -> FeatureDefID?Parameters
Returns
Spring.GetFeatureTeam (function)
[source]Spring.GetFeatureTeam(FeatureID) -> TeamID?Parameters
Returns
Spring.GetFeatureAllyTeam (function)
[source]Spring.GetFeatureAllyTeam(FeatureID) -> AllyTeamID?Parameters
Returns
Spring.GetFeatureHealth (function)
[source]Spring.GetFeatureHealth(FeatureID) -> number?, number, numberParameters
Returns
number?healthnumberdefHealthnumberresurrectProgress
Spring.GetFeatureHeight (function)
[source]Spring.GetFeatureHeight(FeatureID) -> number?Parameters
Returns
Spring.GetFeatureRadius (function)
[source]Spring.GetFeatureRadius(FeatureID) -> number?Parameters
Returns
Spring.GetFeatureMass (function)
[source]Spring.GetFeatureMass(FeatureID) -> number?Parameters
Returns
Spring.GetFeaturePosition (function)
[source]Spring.GetFeaturePosition(FeatureID) -> number?, number?, number?Parameters
Returns
Spring.GetFeatureSeparation (function)
[source]Spring.GetFeatureSeparation(FeatureID, FeatureID, boolean?) -> number?Parameters
FeatureIDfeatureID1FeatureIDfeatureID2boolean?direction- (Default:
false) to subtract from, default featureID1 - featureID2
Returns
Spring.GetFeatureRotation (function)
[source]
Note: PYR order
Spring.GetFeatureRotation(FeatureID) -> number?, number?, number?Parameters
Returns
Spring.GetFeatureDirection (function)
[source]Spring.GetFeatureDirection(FeatureID) -> number?, number?, number?, number?, number?, number?, number?, number?, number?Parameters
Returns
number?frontDirXnumber?frontDirYnumber?frontDirZnumber?rightDirXnumber?rightDirYnumber?rightDirZnumber?upDirXnumber?upDirYnumber?upDirZ
Spring.GetFeatureVelocity (function)
[source]
Returns nil if no feature found with ID.
Spring.GetFeatureVelocity(FeatureID) -> number?, number?, number?, number?Parameters
Returns
Spring.GetFeatureHeading (function)
[source]Spring.GetFeatureHeading(FeatureID) -> number?Parameters
Returns
number?heading
Spring.GetFeatureResources (function)
[source]Spring.GetFeatureResources(FeatureID) -> number?, number, number, number, number, numberParameters
Returns
number?metalnumberdefMetalnumberenergynumberdefEnergynumberreclaimLeftnumberreclaimTime
Spring.GetFeatureBlocking (function)
[source]Spring.GetFeatureBlocking(FeatureID) -> boolean?, boolean?, boolean?, boolean?, boolean?, boolean?, boolean?Parameters
Returns
boolean?isBlockingboolean?isSolidObjectCollidableboolean?isProjectileCollidableboolean?isRaySegmentCollidableboolean?crushableboolean?blockEnemyPushingboolean?blockHeightChanges
Spring.GetFeatureNoSelect (function)
[source]Spring.GetFeatureNoSelect(FeatureID) -> boolean?Parameters
Returns
Spring.GetFeatureResurrect (function)
[source]
Returns nil if no feature found with ID.
Spring.GetFeatureResurrect(FeatureID) -> (string|"")?, FacingIntegerParameters
Returns
(string|"")?featureDefNameFacingIntegerbuildFacing- facing of footprint, 0 - 3
Spring.GetFeatureLastAttackedPiece (function)
[source]Spring.GetFeatureLastAttackedPiece(FeatureID) -> (string|"")?, integer?Parameters
Returns
(string|"")?pieceName- Last hit piece name
integer?frame- frame it was last hit on,
nilwhen featureID is not valid
Spring.GetFeatureCollisionVolumeData (function)
[source]Spring.GetFeatureCollisionVolumeData(FeatureID) -> CollisionVolumeData?Parameters
Returns
Spring.GetFeaturePieceCollisionVolumeData (function)
[source]Spring.GetFeaturePieceCollisionVolumeData(FeatureID) -> CollisionVolumeData?Parameters
Returns
Spring.GetFeatureFireTime (function)
Get the feature current fire timer.
[source]
Spring.GetFeatureFireTime(FeatureID) -> number?Parameters
Returns
number?fireTime- in seconds, nil when featureID is invalid.
Spring.GetFeatureSmokeTime (function)
Get the feature current smoke timer.
[source]
Spring.GetFeatureSmokeTime(FeatureID) -> number?Parameters
Returns
number?smokeTime- in seconds, nil when featureID is invalid.
Spring.GetProjectilePosition (function)
[source]Spring.GetProjectilePosition(ProjectileID) -> number?, number?, number?Parameters
Returns
Spring.GetProjectileDirection (function)
[source]Spring.GetProjectileDirection(ProjectileID) -> number?, number?, number?Parameters
Returns
Spring.GetProjectileVelocity (function)
[source]Spring.GetProjectileVelocity(ProjectileID) -> number?, number?, number?, number?Parameters
Returns
Spring.GetProjectileGravity (function)
[source]Spring.GetProjectileGravity(ProjectileID) -> number?Parameters
Returns
Spring.GetPieceProjectileParams (function)
[source]Spring.GetPieceProjectileParams(ProjectileID) -> integer?, number, number, number, number, numberParameters
Returns
integer?explosionFlags- encoded bitwise with SHATTER = 1, EXPLODE = 2, EXPLODE_ON_HIT = 2, FALL = 4, SMOKE = 8, FIRE = 16, NONE = 32, NO_CEG_TRAIL = 64, NO_HEATCLOUD = 128
numberspinAnglenumberspinSpeednumberspinVectorXnumberspinVectorYnumberspinVectorZ
Spring.GetProjectileTarget (function)
[source]Spring.GetProjectileTarget(ProjectileID) -> integer?, (UnitID|FeatureID|ProjectileID|float3)Parameters
Returns
integer?targetTypeInt- where string.byte(‘g’) := GROUND string.byte(‘u’) := UNIT string.byte(‘f’) := FEATURE string.byte(‘p’) := PROJECTILE
(UnitID|FeatureID|ProjectileID|float3)target- targetID or targetPos when targetTypeInt == string.byte(‘g’)
Spring.GetProjectileIsIntercepted (function)
[source]Spring.GetProjectileIsIntercepted(ProjectileID) -> boolean?Parameters
Returns
Spring.GetProjectileTimeToLive (function)
[source]Spring.GetProjectileTimeToLive(ProjectileID) -> integer?Parameters
Returns
Spring.GetProjectileOwnerID (function)
[source]Spring.GetProjectileOwnerID(ProjectileID) -> UnitID?Parameters
Returns
Spring.GetProjectileTeamID (function)
[source]Spring.GetProjectileTeamID(ProjectileID) -> TeamID?Parameters
Returns
Spring.GetProjectileAllyTeamID (function)
[source]Spring.GetProjectileAllyTeamID(ProjectileID) -> AllyTeamID?Parameters
Returns
Spring.GetProjectileType (function)
[source]Spring.GetProjectileType(ProjectileID) -> boolean?, booleanParameters
Returns
Spring.GetProjectileDefID (function)
[source]Spring.GetProjectileDefID(ProjectileID) -> WeaponDefID?Parameters
Returns
Spring.GetPieceProjectileName (function)
Returns the name of the model piece from which a piece projectile was spawned. Returns nil for other projectiles including weapons
[source]
Spring.GetPieceProjectileName(ProjectileID) -> string?Parameters
Returns
string?pieceName
Spring.GetProjectileDamages (function)
[source]Spring.GetProjectileDamages(ProjectileID, string) -> number?Parameters
ProjectileIDprojectileIDstringtagone 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
Spring.IsPosInMap (function)
[source]Spring.IsPosInMap(number, number) -> boolean, booleanParameters
Returns
booleaninPlayArea- whether the position is in the active play area
booleaninMap- whether the position is in the full map area (currently this is the same as above)
Spring.GetGroundHeight (function)
Get ground height
On sea, this returns the negative depth of the seafloor
[source]
Spring.GetGroundHeight(number, number) -> numberParameters
Returns
Spring.GetWaterPlaneLevel (function)
Get water plane height
Water may at some point become shaped (rivers etc) but for now it is always a flat plane. Use this function instead of GetWaterLevel to denote you are relying on that assumption.
[source]
Spring.GetWaterPlaneLevel() -> numberReturns
numberwaterPlaneLevel
Spring.GetWaterLevel (function)
Get water level in a specific position
Water is currently a flat plane, so this returns the same value regardless of XZ. However water may become more dynamic at some point so by using this you are future-proof.
[source]
Spring.GetWaterLevel(number, number) -> numberParameters
Returns
numberwaterLevel
Spring.GetGroundOrigHeight (function)
Get ground height as it was at game start
Returns the original height before the ground got deformed
[source]
Spring.GetGroundOrigHeight(number, number) -> numberParameters
Returns
Spring.GetGroundNormal (function)
[source]Spring.GetGroundNormal(number, number, boolean?) -> number, number, number, numberParameters
Returns
Spring.GetGroundInfo (function)
[source]Spring.GetGroundInfo(number, number) -> integer, integer, integer, string, number, number, number, number, number, number, booleanParameters
Returns
integerixintegerizintegerterrainTypeIndexstringnamenumbermetalExtractionnumberhardnessnumbertankSpeednumberkbotSpeednumberhoverSpeednumbershipSpeedbooleanreceiveTracks
Spring.GetGroundBlocked (function)
[source]Spring.GetGroundBlocked(number, number, number?, number?) -> string?, ObjectID?Parameters
numberx- world x coordinate (or xMin when using 4-arg form)
numberz- world z coordinate (or zMin when using 4-arg form)
number?x2- world xMax (4-arg rectangle form)
number?z2- world zMax (4-arg rectangle form)
Returns
string?objectType“feature”or“unit”ObjectID?objectID- the feature or unit ID
Spring.GetGroundExtremes (function)
[source]Spring.GetGroundExtremes() -> number, number, number, numberReturns
numberinitMinHeightnumberinitMaxHeightnumbercurrMinHeightnumbercurrMaxHeight
Spring.GetTerrainTypeData (function)
[source]Spring.GetTerrainTypeData(integer) -> integer, string, number, number, number, number, number, booleanParameters
integerterrainTypeInfo
Returns
integerindexstringnamenumberhardnessnumbertankSpeednumberkbotSpeednumberhoverSpeednumbershipSpeedbooleanreceiveTracks
Spring.GetGrass (function)
[source]Spring.GetGrass(number, number) -> numberParameters
Returns
Spring.GetSmoothMeshHeight (function)
[source]Spring.GetSmoothMeshHeight(number, number) -> numberParameters
Returns
numberheight
Spring.TestMoveOrder (function)
[source]Spring.TestMoveOrder(UnitDefID, number, number, number, number?, number?, number?, boolean?, boolean?, boolean?) -> booleanParameters
UnitDefIDunitDefIDnumberposXnumberposYnumberposZnumber?dirX- (Default:
0.0) number?dirY- (Default:
0.0) number?dirZ- (Default:
0.0) boolean?testTerrain- (Default:
true) boolean?testObjects- (Default:
true) boolean?centerOnly- (Default:
false)
Returns
Spring.TestBuildOrder (function)
[source]Spring.TestBuildOrder(UnitDefID, number, number, number, Facing) -> BuildOrderBlockedStatus, FeatureID?Parameters
Returns
BuildOrderBlockedStatusblockingFeatureID?featureID- A reclaimable feature in the way.
Spring.Pos2BuildPos (function)
Snaps a position to the building grid
[source]
Spring.Pos2BuildPos(UnitDefID, number, number, number, number?) -> number, number, numberParameters
UnitDefIDunitDefIDnumberposXnumberposYnumberposZnumber?buildFacing- (Default:
0) one of SOUTH = 0, EAST = 1, NORTH = 2, WEST = 3
Returns
Spring.ClosestBuildPos (function)
[source]Spring.ClosestBuildPos(TeamID, UnitDefID, number, number, number, number, number, number) -> number, number, numberParameters
TeamIDteamIDUnitDefIDunitDefIDnumberposXnumberposYnumberposZnumbersearchRadiusnumberminDistancenumberbuildFacing- one of SOUTH = 0, EAST = 1, NORTH = 2, WEST = 3
Returns
Spring.GetPositionLosState (function)
[source]Spring.GetPositionLosState(number, number, number, AllyTeamID?) -> boolean, boolean, boolean, booleanParameters
numberposXnumberposYnumberposZAllyTeamID?allyTeamID
Returns
booleaninLosOrRadarbooleaninLosbooleaninRadarbooleaninJammer
Spring.IsPosInLos (function)
[source]Spring.IsPosInLos(number, number, number, AllyTeamID?) -> booleanParameters
numberposXnumberposYnumberposZAllyTeamID?allyTeamID
Returns
Spring.IsPosInRadar (function)
[source]Spring.IsPosInRadar(number, number, number, AllyTeamID?) -> booleanParameters
numberposXnumberposYnumberposZAllyTeamID?allyTeamID
Returns
Spring.IsPosInAirLos (function)
[source]Spring.IsPosInAirLos(number, number, number, AllyTeamID?) -> booleanParameters
numberposXnumberposYnumberposZAllyTeamID?allyTeamID
Returns
Spring.GetUnitLosState (function)
Get unit los state (bitmask)
[source]
Spring.GetUnitLosState(UnitID, AllyTeamID?, true) -> (LosMask|integer)?Parameters
UnitIDunitIDAllyTeamID?allyTeamIDtrueraw- Return a bitmask.
Returns
Spring.GetUnitLosState (function overload 1)
Get unit los state (table)
[source]
Spring.GetUnitLosState(UnitID, AllyTeamID?, false?) -> table<("los"|"radar"...),boolean>?Parameters
UnitIDunitIDAllyTeamID?allyTeamIDfalse?raw- (Default:
false) Return a table.
Returns
table<("los"|"radar"...),boolean>?los- A table of LOS state names as keys and booleans as values, or
nilifunitIDis invalid.
Spring.IsUnitInLos (function)
[source]Spring.IsUnitInLos(UnitID, AllyTeamID?) -> booleanParameters
UnitIDunitIDAllyTeamID?allyTeamID- defaults to the calling widget/gadget’s ally team
Returns
booleaninLos
Spring.IsUnitInAirLos (function)
[source]Spring.IsUnitInAirLos(UnitID, AllyTeamID?) -> booleanParameters
UnitIDunitIDAllyTeamID?allyTeamID- defaults to the calling widget/gadget’s ally team
Returns
booleaninAirLos
Spring.IsUnitInRadar (function)
[source]Spring.IsUnitInRadar(UnitID, AllyTeamID?) -> booleanParameters
UnitIDunitIDAllyTeamID?allyTeamID- defaults to the calling widget/gadget’s ally team
Returns
booleaninRadar
Spring.IsUnitInJammer (function)
[source]Spring.IsUnitInJammer(UnitID, AllyTeamID) -> booleanParameters
Returns
booleaninJammer
Spring.GetModelRootPiece (function)
[source]Spring.GetModelRootPiece(string) -> integerParameters
stringmodelName
Returns
integerindex- of the root piece
Spring.GetModelPieceMap (function)
[source]Spring.GetModelPieceMap(string) -> table<string,integer>?Parameters
stringmodelName
Returns
table<string,integer>?pieceInfos- where keys are piece names and values are indices
Spring.GetModelPieceList (function)
[source]Spring.GetModelPieceList(string) -> string[]?Parameters
stringmodelName
Returns
string[]?pieceNames
Spring.GetUnitRootPiece (function)
[source]Spring.GetUnitRootPiece(UnitID) -> integerParameters
Returns
integerindex- of the root piece
Spring.GetUnitPieceMap (function)
[source]Spring.GetUnitPieceMap(UnitID) -> table<string,integer>?Parameters
Returns
table<string,integer>?pieceInfos- where keys are piece names and values are indices
Spring.GetUnitPieceList (function)
[source]Spring.GetUnitPieceList(UnitID) -> string[]Parameters
Returns
string[]pieceNames
Spring.GetUnitPieceInfo (function)
[source]Spring.GetUnitPieceInfo(UnitID, integer) -> PieceInfo?Parameters
UnitIDunitIDintegerpieceIndex
Returns
Spring.GetUnitPiecePosDir (function)
[source]Spring.GetUnitPiecePosDir(UnitID, integer) -> number?, number, number, number, number, numberParameters
UnitIDunitIDintegerpieceIndex
Returns
Spring.GetUnitPiecePosition (function)
[source]Spring.GetUnitPiecePosition(UnitID, integer) -> number?, number, numberParameters
UnitIDunitIDintegerpieceIndex
Returns
Spring.GetUnitPieceDirection (function)
[source]Spring.GetUnitPieceDirection(UnitID, integer) -> number?, number, numberParameters
UnitIDunitIDintegerpieceIndex
Returns
Spring.GetUnitPieceMatrix (function)
[source]Spring.GetUnitPieceMatrix(UnitID, integer) -> number?, number, number, number, number, number, number, number, number, number, number, number, number, number, number, numberParameters
UnitIDunitIDintegerpieceIndex
Returns
number?m11numberm12numberm13numberm14numberm21numberm22numberm23numberm24numberm31numberm32numberm33numberm34numberm41numberm42numberm43numberm44
Spring.GetFeatureRootPiece (function)
[source]Spring.GetFeatureRootPiece(FeatureID) -> integerParameters
Returns
integerindex- of the root piece
Spring.GetFeaturePieceMap (function)
[source]Spring.GetFeaturePieceMap(FeatureID) -> table<string,integer>Parameters
Returns
table<string,integer>pieceInfos- where keys are piece names and values are indices
Spring.GetFeaturePieceList (function)
[source]Spring.GetFeaturePieceList(FeatureID) -> string[]Parameters
Returns
string[]pieceNames
Spring.GetFeaturePieceInfo (function)
[source]Spring.GetFeaturePieceInfo(FeatureID, integer) -> PieceInfo?Parameters
FeatureIDfeatureIDintegerpieceIndex
Returns
Spring.GetFeaturePiecePosDir (function)
[source]Spring.GetFeaturePiecePosDir(FeatureID, integer) -> number?, number, number, number, number, numberParameters
FeatureIDfeatureIDintegerpieceIndex
Returns
Spring.GetFeaturePiecePosition (function)
[source]Spring.GetFeaturePiecePosition(FeatureID, integer) -> number?, number, numberParameters
FeatureIDfeatureIDintegerpieceIndex
Returns
Spring.GetFeaturePieceDirection (function)
[source]Spring.GetFeaturePieceDirection(FeatureID, integer) -> number?, number, numberParameters
FeatureIDfeatureIDintegerpieceIndex
Returns
Spring.GetFeaturePieceMatrix (function)
[source]Spring.GetFeaturePieceMatrix(FeatureID, integer) -> number?, number, number, number, number, number, number, number, number, number, number, number, number, number, number, numberParameters
FeatureIDfeatureIDintegerpieceIndex
Returns
number?m11numberm12numberm13numberm14numberm21numberm22numberm23numberm24numberm31numberm32numberm33numberm34numberm41numberm42numberm43numberm44
Spring.GetUnitScriptPiece (function)
[source]Spring.GetUnitScriptPiece(UnitID) -> integer[]Parameters
Returns
integer[]pieceIndices
Spring.GetUnitScriptPiece (function overload 1)
[source]Spring.GetUnitScriptPiece(UnitID, integer) -> integerParameters
UnitIDunitIDintegerscriptPiece
Returns
integerpieceIndex
Spring.GetUnitScriptNames (function)
[source]Spring.GetUnitScriptNames(UnitID) -> table<string,integer>Parameters
Returns
table<string,integer>pieceInfos- where keys are piece names and values are piece indices
Spring.TraceRayInDirection (function)
Traces a ray from a position in a direction
[source]
Returns all unit and/or feature hits along a ray, sorted by distance from the start position.
Spring.TraceRayInDirection(number, number, number, number, number, number, number, string) -> table[]Parameters
numberposXnumberposYnumberposZnumberdirXnumberdirYnumberdirZnumbermaxLengthstringtype- Object type to test:
“unit”,“feature”, or“both”
Returns
table[]hits- Array of
{hitLength, objectID, objectType}entries
Spring.TraceRayBetweenPositions (function)
Traces a ray between two positions
[source]
Checks for unit and/or feature collisions between two positions and returns all hits sorted by distance from the start position.
Spring.TraceRayBetweenPositions(number, number, number, number, number, number, string) -> table[]Parameters
numberstartXnumberstartYnumberstartZnumberendXnumberendYnumberendZstringtype- Object type to test:
“unit”,“feature”, or“both”
Returns
table[]hits- Array of
{hitLength, objectID, objectType}entries
Spring.TraceRayGroundInDirection (function)
Checks for a ground collision in given direction
[source]
Checks if there is surface (ground, optionally water) towards a vector and returns the distance to the closest hit and its position, if any.
Spring.TraceRayGroundInDirection(number, number, number, number, number, number, number?, boolean?) -> number?, number?, number?, number?Parameters
numberposXnumberposYnumberposZnumberdirXnumberdirYnumberdirZnumber?maxLength- (Default:
999999) boolean?testWater- (Default:
true)
Returns
Spring.TraceRayGroundBetweenPositions (function)
Checks for a ground collision between two positions
[source]
Checks if there is surface (ground, optionally water) between two positions and returns the distance to the closest hit and its position, if any.
Spring.TraceRayGroundBetweenPositions(number, number, number, number, number, number, boolean?) -> number, number, number, numberParameters
Returns
Spring.GetRadarErrorParams (function)
[source]Spring.GetRadarErrorParams(AllyTeamID) -> number?, number, numberParameters
Returns
number?radarErrorSize- actual radar error size (when allyTeamID is allied to current team) or base radar error size
numberbaseRadarErrorSizenumberbaseRadarErrorMult
Spring.Ping (function)
Send a ping request to the server
[source]
Spring.Ping(integer?) -> nilParameters
integer?pingTag
Returns
Spring.SendCommands (function)
[source]Spring.SendCommands(string[]) -> nilParameters
string[]commands
Spring.SendCommands (function overload 1)
[source]Spring.SendCommands(string, [string, ]*) -> nilParameters
Returns
Spring.SendPublicChat (function)
Sends a chat message to everyone (players and spectators).
[source]
Spring.SendPublicChat(string) -> nilParameters
stringmessage
Returns
Spring.SendAllyChat (function)
Sends a chat message to the sender’s ally team (if a spectator, to other spectators).
[source]
Spring.SendAllyChat(string) -> nilParameters
stringmessage
Returns
Spring.SendSpectatorChat (function)
Sends a chat message to spectators. Works even if you’re a player.
[source]
Spring.SendSpectatorChat(string) -> nilParameters
stringmessage
Returns
Spring.SendPrivateChat (function)
Sends a private chat message to a specific player ID.
[source]
Spring.SendPrivateChat(string, PlayerID) -> nilParameters
Returns
Spring.SendMessage (function)
[source]Spring.SendMessage(string) -> nilParameters
stringmessage
Returns
Spring.SendMessageToSpectators (function)
[source]Spring.SendMessageToSpectators(string) -> nilParameters
stringmessage"<PLAYER#>"where#is a player ID.This will be replaced with the player’s name. e.g.
lua Spring.SendMessage("did something") – “ProRusher did something”
Returns
Spring.SendMessageToPlayer (function)
[source]Spring.SendMessageToPlayer(PlayerID, string) -> nilParameters
Returns
Spring.SendMessageToTeam (function)
[source]Spring.SendMessageToTeam(TeamID, string) -> nilParameters
Returns
Spring.SendMessageToAllyTeam (function)
[source]Spring.SendMessageToAllyTeam(AllyTeamID, string) -> nilParameters
AllyTeamIDallyIDstringmessage
Returns
Spring.RequestStartPosition (function)
[source]
Requests a startpoint, as if clicking the spot with the native GUI.
Spring.RequestStartPosition(number, number, number, boolean?) -> nilParameters
Spring.LoadSoundDef (function)
Loads a SoundDefs file, the format is the same as in gamedata/sounds.lua.
[source]
Spring.LoadSoundDef(string) -> booleanParameters
stringsoundfile
Returns
booleansuccess
Spring.PlaySoundFile (function)
[source]Spring.PlaySoundFile(string, number?, number?, number?, number?, number?, number?, number?, SoundChannel?) -> booleanParameters
stringsoundfilenumber?volume- (Default: 1.0) optional; all following arguments are optional
number?posx- world position X (use with
posyandposz, or omit all three) number?posynumber?posznumber?speedx- velocity X (use with
speedyandspeedzafter position, or omit all three) number?speedynumber?speedzSoundChannel?channel- (Default:
0|“general”) optional; parsed from the last argument index after position and speed triples
Returns
booleanplaySound
Spring.PlaySoundStream (function)
Allows to play an Ogg Vorbis (.OGG) and mp3 compressed sound file.
[source]
Multiple sound streams may be played at once.
Spring.PlaySoundStream(string, number?, boolean?) -> booleanParameters
Returns
booleansuccess
Spring.StopSoundStream (function)
Terminates any SoundStream currently running.
[source]
Spring.StopSoundStream() -> nilReturns
Spring.PauseSoundStream (function)
Pause any SoundStream currently running.
[source]
Spring.PauseSoundStream() -> nilReturns
Spring.SetSoundStreamVolume (function)
Set volume for SoundStream
[source]
Spring.SetSoundStreamVolume(number) -> nilParameters
numbervolume
Returns
Spring.SetSoundEffectParams (function)
[source]Spring.SetSoundEffectParams() -> nilSpring.AddWorldIcon (function)
[source]Spring.AddWorldIcon(integer, number, number, number) -> nilParameters
Returns
Spring.AddWorldText (function)
[source]Spring.AddWorldText(string, number, number, number) -> nilParameters
Returns
Spring.AddWorldUnit (function)
[source]Spring.AddWorldUnit(UnitDefID, number, number, number, TeamID, FacingInteger) -> nilParameters
Returns
Spring.DrawUnitCommands (function)
[source]Spring.DrawUnitCommands(UnitID) -> nilParameters
Spring.DrawUnitCommands (function overload 1)
[source]Spring.DrawUnitCommands(UnitID[], false?) -> nilParameters
UnitID[]unitIDs- Unit ids.
false?tableOrArray- Set to
trueif the unit IDs should be read from the keys ofunitIDs.
Spring.DrawUnitCommands (function overload 2)
[source]Spring.DrawUnitCommands(table<UnitID,any>, true) -> nilParameters
table<UnitID,any>unitIDs- Table with unit IDs as keys.
truetableOrArray- Set to
falseif the unit IDs should be read from the values ofunitIDs.
Returns
Spring.SetCameraTarget (function)
For Spring Engine XZ represents horizontal, from north west corner of map and Y vertical, from water level and rising.
[source]
Spring.SetCameraTarget(number, number, number, number?, number?, number?, number?) -> nilParameters
numberxnumberynumberznumber?transTime- (Default:
0.5) transition duration; values below zero are clamped to zero number?dirX- (Default: current camera direction X)
number?dirY- (Default: current camera direction Y)
number?dirZ- (Default: current camera direction Z)
Returns
Spring.SetCameraOffset (function)
[source]Spring.SetCameraOffset(number?, number?, number?, number?, number?, number?) -> nilParameters
number?posX- (Default:
0) number?posY- (Default:
0) number?posZ- (Default:
0) number?tiltX- (Default:
0) number?tiltY- (Default:
0) number?tiltZ- (Default:
0)
Returns
Spring.SetCameraState (function)
Set camera state.
[source]
Spring.SetCameraState(CameraState, number?, number?, number?) -> booleanParameters
CameraStatecameraState- The fields must be consistent with the name/mode and current/new camera mode.
number?transitionTime- (Default:
0) in nanoseconds number?transitionTimeFactornumber?transitionTimeExponent
Returns
booleansettruewhen applied without errors, otherwisefalse.
Spring.RunDollyCamera (function)
Runs Dolly Camera
[source]
Spring.RunDollyCamera(number) -> nilParameters
numberruntime- Runtime in milliseconds.
Returns
Spring.PauseDollyCamera (function)
Pause Dolly Camera
[source]
Spring.PauseDollyCamera(number?) -> nilParameters
number?fraction- Fraction of the total runtime to pause at, 0 to 1 inclusive. A null value pauses at current percent
Returns
Spring.ResumeDollyCamera (function)
Resume Dolly Camera
[source]
Spring.ResumeDollyCamera() -> nilReturns
Spring.SetDollyCameraPosition (function)
Sets Dolly Camera Position
[source]
Spring.SetDollyCameraPosition(number, number, number) -> nilParameters
Returns
Spring.SetDollyCameraCurve (function)
Sets Dolly Camera movement Curve
[source]
Spring.SetDollyCameraCurve(integer, ControlPoint[], table) -> nilParameters
integerdegreeControlPoint[]cpoints- NURBS control point positions.
tableknots
Returns
Spring.SetDollyCameraMode (function)
Sets Dolly Camera movement mode
[source]
Spring.SetDollyCameraMode((1|2)) -> nilParameters
(1|2)mode1static position,2nurbs curve
Returns
Spring.SetDollyCameraRelativeMode (function)
Sets Dolly Camera movement curve to world relative or look target relative
[source]
Spring.SetDollyCameraRelativeMode(integer) -> nilParameters
integerrelativeMode1world,2look target
Returns
Spring.SetDollyCameraLookCurve (function)
Sets Dolly Camera Look Curve
[source]
Spring.SetDollyCameraLookCurve(integer, ControlPoint[], table) -> nilParameters
integerdegreeControlPoint[]cpoints- NURBS control point positions.
tableknots
Returns
Spring.SetDollyCameraLookPosition (function)
Sets Dolly Camera Look Position
[source]
Spring.SetDollyCameraLookPosition(number, number, number) -> nilParameters
Returns
Spring.SetDollyCameraLookUnit (function)
Sets target unit for Dolly Camera to look towards
[source]
Spring.SetDollyCameraLookUnit(UnitID) -> nilParameters
Returns
Spring.SelectUnit (function)
Selects a single unit
[source]
Spring.SelectUnit(UnitID?, boolean?) -> nilParameters
Returns
Spring.DeselectUnit (function)
[source]Spring.DeselectUnit(UnitID) -> nilParameters
Returns
Spring.DeselectUnitArray (function)
Deselects multiple units.
[source]
Spring.DeselectUnitArray(UnitID[]) -> nilParameters
Returns
Spring.DeselectUnitMap (function)
Deselects multiple units.
[source]
Spring.DeselectUnitMap(table<UnitID,any>) -> nilParameters
table<UnitID,any>unitMap- Table with unit IDs as keys.
Returns
Spring.SelectUnitArray (function)
Selects multiple units, or appends to selection. Accepts a table with unitIDs as values
[source]
Spring.SelectUnitArray(UnitID[], boolean?) -> nilParameters
UnitID[]unitIDs- Table with unit IDs as values.
boolean?append- (Default:
false) append to current selection
Returns
Spring.SelectUnitMap (function)
Selects multiple units, or appends to selection. Accepts a table with unitIDs as keys
[source]
Spring.SelectUnitMap(table<UnitID,any>, boolean?) -> nilParameters
table<UnitID,any>unitMap- Table with unit IDs as keys.
boolean?append- (Default:
false) append to current selection
Returns
Spring.AddMapLight (function)
[source]
requires MaxDynamicMapLights > 0
Spring.AddMapLight(LightParams) -> integerParameters
Returns
integerlightHandle
Spring.AddModelLight (function)
[source]
requires MaxDynamicMapLights > 0
Spring.AddModelLight(LightParams) -> integerParameters
Returns
integerlightHandle
Spring.UpdateMapLight (function)
[source]Spring.UpdateMapLight(integer, LightParams) -> booleanParameters
Returns
booleansuccess
Spring.UpdateModelLight (function)
[source]Spring.UpdateModelLight(integer, LightParams) -> booleanParameters
Returns
booleansuccess
Spring.AddLightTrackingTarget (function)
[source]Spring.AddLightTrackingTarget() -> nilSpring.SetMapLightTrackingState (function)
Set a map-illuminating light to start/stop tracking the position of a moving object (unit or projectile)
[source]
Spring.SetMapLightTrackingState(integer, (UnitID|ProjectileID), boolean?, boolean?) -> booleanParameters
integerlightHandle(UnitID|ProjectileID)unitOrProjectileIDboolean?enableTrackingboolean?unitOrProjectile
Returns
booleansuccess
Spring.SetModelLightTrackingState (function)
Set a model-illuminating light to start/stop tracking the position of a moving object (unit or projectile)
[source]
Spring.SetModelLightTrackingState(integer, (UnitID|ProjectileID), boolean?, boolean?) -> booleanParameters
integerlightHandle(UnitID|ProjectileID)unitOrProjectileIDboolean?enableTrackingboolean?unitOrProjectile
Returns
booleansuccess
Spring.SetMapShader (function)
[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.
Spring.SetMapShader(integer, integer) -> nilParameters
integerstandardShaderIDintegerdeferredShaderID
Returns
Spring.SetMapSquareTexture (function)
[source]Spring.SetMapSquareTexture(integer, integer, string) -> booleanParameters
integertexSqrXintegertexSqrYstringluaTexName
Returns
booleansuccess
Spring.SetMapShadingTexture (function)
[source]Spring.SetMapShadingTexture(string, string) -> booleanParameters
Returns
booleansuccess
Spring.SetSkyBoxTexture (function)
[source]Spring.SetSkyBoxTexture(string) -> nilParameters
stringtexName
Returns
Spring.SetUnitNoDraw (function)
[source]Spring.SetUnitNoDraw(UnitID, boolean) -> nilParameters
Returns
Spring.SetUnitEngineDrawMask (function)
[source]Spring.SetUnitEngineDrawMask(UnitID, number) -> nilParameters
Returns
Spring.SetUnitAlwaysUpdateMatrix (function)
[source]Spring.SetUnitAlwaysUpdateMatrix(UnitID, boolean) -> nilParameters
Returns
Spring.SetUnitNoMinimap (function)
[source]Spring.SetUnitNoMinimap(UnitID, boolean) -> nilParameters
UnitIDunitIDbooleanunitNoMinimap
Returns
Spring.SetMiniMapRotation (function)
[source]Spring.SetMiniMapRotation(number) -> nilParameters
numberrotation- amount in radians
Returns
Spring.SetUnitNoGroup (function)
[source]Spring.SetUnitNoGroup(UnitID, boolean) -> nilParameters
UnitIDunitIDbooleanunitNoGroup- Whether unit can be added to selection groups
Spring.SetUnitNoSelect (function)
[source]Spring.SetUnitNoSelect(UnitID, boolean) -> nilParameters
UnitIDunitIDbooleanunitNoSelect- whether unit can be selected or not
Returns
Spring.SetUnitLeaveTracks (function)
[source]Spring.SetUnitLeaveTracks(UnitID, boolean) -> nilParameters
UnitIDunitIDbooleanunitLeaveTracks- whether unit leaves tracks on movement
Returns
Spring.SetUnitSelectionVolumeData (function)
[source]Spring.SetUnitSelectionVolumeData(UnitID, number, number, number, number, number, number, integer, integer, integer) -> nilParameters
UnitIDunitIDnumberscaleXnumberscaleYnumberscaleZnumberoffsetXnumberoffsetYnumberoffsetZintegervTypeintegertTypeintegerAxis
Returns
Spring.SetFeatureNoDraw (function)
[source]Spring.SetFeatureNoDraw(FeatureID, boolean) -> nilParameters
Returns
Spring.SetFeatureEngineDrawMask (function)
[source]Spring.SetFeatureEngineDrawMask(FeatureID, number) -> nilParameters
Returns
Spring.SetFeatureAlwaysUpdateMatrix (function)
[source]Spring.SetFeatureAlwaysUpdateMatrix(FeatureID, number) -> nilParameters
Returns
Spring.SetFeatureFade (function)
Control whether a feature will fade or not when zoomed out.
[source]
Spring.SetFeatureFade(FeatureID, boolean) -> nilParameters
Returns
Spring.SetFeatureSelectionVolumeData (function)
[source]Spring.SetFeatureSelectionVolumeData(FeatureID, number, number, number, number, number, number, integer, integer, integer) -> nilParameters
FeatureIDfeatureIDnumberscaleXnumberscaleYnumberscaleZnumberoffsetXnumberoffsetYnumberoffsetZintegervTypeintegertTypeintegerAxis
Returns
Spring.AddUnitIcon (function)
[source]Spring.AddUnitIcon(string, string, number?, number?, number?, number?, number?, number?, number?) -> booleanParameters
stringiconNamestringtexFilenumber?sizenumber?distnumber?radAdjustnumber?u0number?v0number?u1number?v1
Returns
booleanadded
Spring.FreeUnitIcon (function)
[source]Spring.FreeUnitIcon(string) -> boolean?Parameters
stringiconName
Returns
boolean?freed
Spring.UnitIconSetDraw (function)
[source]
Use Spring.SetUnitIconDraw instead.
Deprecated
Spring.UnitIconSetDraw(UnitID, boolean) -> nilParameters
Returns
Spring.SetUnitIconDraw (function)
[source]Spring.SetUnitIconDraw(UnitID, boolean) -> nilParameters
Returns
Spring.SetUnitIcon (function)
[source]Spring.SetUnitIcon(UnitID, string?) -> nilParameters
Returns
Spring.SetUnitDefIcon (function)
[source]Spring.SetUnitDefIcon(UnitDefID, string) -> nilParameters
Returns
Spring.SetUnitDefImage (function)
[source]Spring.SetUnitDefImage(UnitDefID, string?) -> nilParameters
Returns
Spring.ExtractModArchiveFile (function)
[source]Spring.ExtractModArchiveFile(string) -> booleanParameters
stringmodfile
Returns
booleanextracted
Spring.CreateDir (function)
[source]Spring.CreateDir(string) -> boolean?Parameters
stringpath
Returns
boolean?dirCreated
Spring.SetActiveCommand (function)
[source]Spring.SetActiveCommand(string, string?) -> boolean?Parameters
stringactionstring?actionExtra
Returns
boolean?commandSet
Spring.SetActiveCommand (function overload 1)
[source]Spring.SetActiveCommand(integer, integer?, boolean?, boolean?, boolean?, boolean?, boolean?, boolean?) -> boolean?Parameters
integercmdIndexinteger?button- (Default:
1) boolean?leftClickboolean?rightClickboolean?altboolean?ctrlboolean?metaboolean?shift
Returns
boolean?commandSet
Spring.LoadCmdColorsConfig (function)
[source]Spring.LoadCmdColorsConfig(string) -> nilParameters
stringconfig
Returns
Spring.LoadCtrlPanelConfig (function)
[source]Spring.LoadCtrlPanelConfig(string) -> nilParameters
stringconfig
Returns
Spring.ForceLayoutUpdate (function)
[source]Spring.ForceLayoutUpdate() -> nilReturns
Spring.SetDrawSelectionInfo (function)
Disables the “Selected Units x” box in the GUI.
[source]
Spring.SetDrawSelectionInfo(boolean) -> nilParameters
booleanenable
Returns
Spring.SetBoxSelectionByEngine (function)
[source]Spring.SetBoxSelectionByEngine(boolean) -> nilParameters
booleanstate
Returns
Spring.SetTeamColor (function)
[source]Spring.SetTeamColor(TeamID, number, number, number, number?) -> nilParameters
Returns
Spring.SetCustomPaletteColor (function)
[source]Spring.SetCustomPaletteColor(integer, number, number, number) -> nilParameters
integerindex- 0-based index into custom palette (0..1791, maps to palette slots 256..2047)
numberrnumbergnumberb
Returns
Spring.SetUnitPaletteIndex (function)
Sets a custom color for a unit from the palette. Custom assignments are permanent until explicitly reset by passing nil, and are NOT affected by team changes.
[source]
Spring.SetUnitPaletteIndex(UnitID, integer?) -> nilParameters
UnitIDunitIDinteger?customIndex- [0..MAX_CUSTOM_COLORS) index into custom palette, or nil to reset to team color
Returns
Spring.SetFeaturePaletteIndex (function)
Sets a custom color for a feature from the palette. Custom assignments are permanent until explicitly reset by passing nil, and are NOT affected by team changes.
[source]
Spring.SetFeaturePaletteIndex(FeatureID, integer?) -> nilParameters
FeatureIDfeatureIDinteger?customIndex- [0..MAX_CUSTOM_COLORS) index into custom palette, or nil to reset to team color
Returns
Spring.AssignMouseCursor (function)
Changes/creates the cursor of a single CursorCmd.
[source]
Spring.AssignMouseCursor(string, string, boolean?, boolean?) -> boolean?Parameters
stringcmdNamestringiconFileName- not the full filename, instead it is like this: Wanted filename: Anims/cursorattack_0.bmp => iconFileName: cursorattack
boolean?overwrite- (Default:
true) boolean?hotSpotTopLeft- (Default:
false)
Returns
boolean?assigned
Spring.ReplaceMouseCursor (function)
Mass replace all occurrences of the cursor in all CursorCmds.
[source]
Spring.ReplaceMouseCursor(string, string, boolean?) -> boolean?Parameters
stringoldFileNamestringnewFileNameboolean?hotSpotTopLeft- (Default:
false)
Returns
boolean?assigned
Spring.SetCustomCommandDrawData (function)
Register your custom cmd so it gets visible in the unit’s cmd queue
[source]
Spring.SetCustomCommandDrawData(integer, (string|integer)?, rgba?, boolean?) -> nilParameters
integercmdID(string|integer)?cmdReference- The name or ID of an icon for command. Pass
nilto clear draw data for command. rgba?color- (Default: white)
boolean?showArea- (Default:
false)
Returns
Spring.WarpMouse (function)
[source]Spring.WarpMouse(integer, integer) -> nilParameters
Returns
Spring.SetMouseCursor (function)
[source]Spring.SetMouseCursor(string, number?) -> nilParameters
stringcursorNamenumber?cursorScale- (Default:
1.0)
Returns
Spring.SetLosViewColors (function)
[source]Spring.SetLosViewColors(rgb, rgb, rgb, rgb, rgb) -> nilParameters
Returns
Spring.SetNanoProjectileParams (function)
[source]Spring.SetNanoProjectileParams(number?, number?, number?, number?, number?, number?) -> nilParameters
number?rotVal- (Default:
0) in degrees number?rotVel- (Default:
0) in degrees number?rotAcc- (Default:
0) in degrees number?rotValRng- (Default:
0) in degrees number?rotVelRng- (Default:
0) in degrees number?rotAccRng- (Default:
0) in degrees
Returns
Spring.SetConfigInt (function)
[source]Spring.SetConfigInt(string, integer, boolean?) -> nilParameters
stringnameintegervalueboolean?useOverlay- (Default:
false) Iftrue, the value will only be set in memory, and not be restored for the next game.
Returns
Spring.SetConfigFloat (function)
[source]Spring.SetConfigFloat(string, number, boolean?) -> nilParameters
stringnamenumbervalueboolean?useOverlay- (Default:
false) Iftrue, the value will only be set in memory, and not be restored for the next game.
Returns
Spring.SetConfigString (function)
[source]Spring.SetConfigString(string, string, boolean?) -> nilParameters
stringnamestringvalueboolean?useOverlay- (Default:
false) Iftrue, the value will only be set in memory, and not be restored for the next game.
Returns
Spring.Quit (function)
Closes the application
[source]
Spring.Quit() -> nilReturns
Spring.SetUnitGroup (function)
[source]Spring.SetUnitGroup(UnitID, GroupID) -> nilParameters
Returns
Spring.GiveOrder (function)
Give order to selected units.
[source]
Spring.GiveOrder((CMD|integer), CreateCommandParams?, CreateCommandOptions?, integer?) -> booleanParameters
(CMD|integer)cmdID- The command ID.
CreateCommandParams?params- Parameters for the given command.
CreateCommandOptions?optionsinteger?timeout- Absolute frame number. The command will be discarded after this frame. Only respected by mobile units.
Returns
Spring.SetBuildSpacing (function)
[source]Spring.SetBuildSpacing(integer) -> nilParameters
integerspacing
Returns
Spring.SetBuildFacing (function)
[source]Spring.SetBuildFacing(FacingInteger) -> nilParameters
Returns
Spring.SendLuaUIMsg (function)
[source]Spring.SendLuaUIMsg(string, string?) -> nilParameters
Returns
Spring.SendLuaGaiaMsg (function)
[source]Spring.SendLuaGaiaMsg(string) -> nilParameters
stringmessage
Returns
Spring.SendLuaRulesMsg (function)
[source]Spring.SendLuaRulesMsg(string) -> nilParameters
stringmessage
Returns
Spring.SendLuaMenuMsg (function)
[source]Spring.SendLuaMenuMsg(string) -> nilParameters
stringmsg
Spring.SetShareLevel (function)
[source]Spring.SetShareLevel(string, number) -> nilParameters
stringresource- metal | energy
numbershareLevel
Returns
Spring.ShareResources (function)
[source]Spring.ShareResources(TeamID, string) -> nilParameters
Returns
Spring.ShareResources (function overload 1)
[source]Spring.ShareResources(TeamID, string, number) -> nilParameters
Returns
Spring.SetLastMessagePosition (function)
[source]Spring.SetLastMessagePosition(number, number, number) -> nilParameters
Returns
Spring.MarkerAddPoint (function)
[source]Spring.MarkerAddPoint(number, number, number, string?, boolean?, PlayerID?) -> nilParameters
numberxnumberynumberzstring?text- (Default:
"") boolean?localOnlyPlayerID?playerID- Local labels pretend they are from this player
Returns
Spring.MarkerAddLine (function)
[source]Spring.MarkerAddLine(number, number, number, number, number, number, boolean?, PlayerID?) -> nilParameters
Returns
Spring.MarkerErasePosition (function)
[source]
Issue an erase command for markers on the map.
Spring.MarkerErasePosition(number, number, number, nil, boolean?, PlayerID?, boolean?) -> nilParameters
numberxnumberynumberznilunused- This argument is ignored.
boolean?localOnly- (Default:
false) do not issue a network message, erase only for the current player PlayerID?playerId- when not specified it uses the issuer playerId
boolean?alwaysErase- (Default:
false) erase any marker whenlocalOnlyand current player is spectating. Allows spectators to erase players markers locally
Returns
Spring.SetAtmosphere (function)
Set atmosphere parameters
[source]
Spring.SetAtmosphere(AtmosphereParams) -> nilParameters
Spring.SetSunDirection (function)
[source]Spring.SetSunDirection(number, number, number, number?) -> nilParameters
Returns
Spring.SetSunLighting (function)
Modify sun lighting parameters.
lua
Spring.SetSunLighting({groundAmbientColor = {1, 0.1, 1}, groundDiffuseColor = {1, 0.1, 1} })
[source]
Spring.SetSunLighting(SunLightingParams) -> nilParameters
Spring.SetMapRenderingParams (function)
Allows to change map rendering params at runtime.
[source]
Spring.SetMapRenderingParams(MapRenderingParams) -> nilParameters
Returns
Spring.ForceTesselationUpdate (function)
[source]Spring.ForceTesselationUpdate(boolean?, boolean?) -> booleanParameters
Returns
booleanupdated
Spring.SendSkirmishAIMessage (function)
[source]Spring.SendSkirmishAIMessage(TeamID, string) -> boolean?Parameters
Returns
boolean?ai_processed
Spring.SetLogSectionFilterLevel (function)
[source]Spring.SetLogSectionFilterLevel(string, (string|number)?) -> nilParameters
stringsectionName(string|number)?logLevel
Returns
Spring.GarbageCollectCtrl (function)
[source]Spring.GarbageCollectCtrl(integer?, integer?, integer?, integer?, number?, number?, number?, number?) -> nilParameters
integer?itersPerBatchinteger?numStepsPerIterinteger?minStepsPerIterinteger?maxStepsPerIternumber?minLoopRunTimenumber?maxLoopRunTimenumber?baseRunTimeMultnumber?baseMemLoadMult
Returns
Spring.SetAutoShowMetal (function)
[source]Spring.SetAutoShowMetal(boolean) -> nilParameters
booleanautoShow
Returns
Spring.SetDrawSky (function)
[source]Spring.SetDrawSky(boolean) -> nilParameters
booleandrawSky
Returns
Spring.SetDrawWater (function)
[source]Spring.SetDrawWater(boolean) -> nilParameters
booleandrawWater
Returns
Spring.SetDrawGround (function)
[source]Spring.SetDrawGround(boolean) -> nilParameters
booleandrawGround
Returns
Spring.SetDrawGroundDeferred (function)
[source]Spring.SetDrawGroundDeferred(boolean, boolean?) -> nilParameters
booleandrawGroundDeferredboolean?drawGroundForward- allows disabling of the forward pass
Returns
Spring.SetDrawModelsDeferred (function)
[source]Spring.SetDrawModelsDeferred(boolean, boolean, boolean?, boolean?) -> nilParameters
booleandrawUnitsDeferredbooleandrawFeaturesDeferredboolean?drawUnitsForward- allows disabling of the respective forward passes
boolean?drawFeaturesForward- allows disabling of the respective forward passes
Returns
Spring.SetEngineBuildSquareRendering (function)
[source]Spring.SetEngineBuildSquareRendering(boolean) -> nilParameters
booleanenabled
Returns
Spring.SetVideoCapturingMode (function)
This doesn’t actually record the game in any way, it just regulates the framerate and interpolations.
[source]
Spring.SetVideoCapturingMode(boolean) -> nilParameters
booleanallowCaptureMode
Returns
Spring.SetVideoCapturingTimeOffset (function)
[source]Spring.SetVideoCapturingTimeOffset(boolean) -> nilParameters
booleantimeOffset
Returns
Spring.SetWaterParams (function)
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]
Spring.SetWaterParams(WaterParams) -> nilParameters
Returns
Spring.PreloadUnitDefModel (function)
[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.
Spring.PreloadUnitDefModel(UnitDefID) -> nilParameters
Returns
Spring.PreloadFeatureDefModel (function)
[source]Spring.PreloadFeatureDefModel(FeatureDefID) -> nilParameters
Returns
Spring.PreloadSoundItem (function)
[source]Spring.PreloadSoundItem(string) -> nilParameters
stringname
Returns
Spring.LoadModelTextures (function)
[source]Spring.LoadModelTextures(string?) -> boolean?Parameters
string?modelName
Returns
boolean?success
Spring.CreateGroundDecal (function)
[source]Spring.CreateGroundDecal() -> DecalID?Returns
Spring.DestroyGroundDecal (function)
[source]Spring.DestroyGroundDecal(DecalID) -> booleanParameters
Returns
booleandelSuccess
Spring.SetGroundDecalPosAndDims (function)
[source]Spring.SetGroundDecalPosAndDims(DecalID, number?, number?, number?, number?, number?) -> booleanParameters
DecalIDdecalIDnumber?midPosX- (Default: currMidPosX)
number?midPosZ- (Default: currMidPosZ)
number?sizeX- (Default: currSizeX)
number?sizeZ- (Default: currSizeZ)
number?projCubeHeight- (Default: calculateProjCubeHeight)
Returns
booleandecalSet
Spring.SetGroundDecalQuadPosAndHeight (function)
[source]
Use for non-rectangular decals
Spring.SetGroundDecalQuadPosAndHeight(DecalID, xz?, xz?, xz?, xz?, number?) -> booleanParameters
DecalIDdecalIDxz?posTL- (Default: currPosTL)
xz?posTR- (Default: currPosTR)
xz?posBR- (Default: currPosBR)
xz?posBL- (Default: currPosBL)
number?projCubeHeight- (Default: calculateProjCubeHeight)
Returns
booleandecalSet
Spring.SetGroundDecalRotation (function)
[source]Spring.SetGroundDecalRotation(DecalID, number?) -> booleanParameters
Returns
booleandecalSet
Spring.SetGroundDecalTexture (function)
[source]Spring.SetGroundDecalTexture(DecalID, string, boolean?) -> boolean?Parameters
DecalIDdecalIDstringtextureName- 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)
boolean?isMainTex- (Default:
true) If false, it sets the normals/glow map
Returns
boolean?decalSet
Spring.SetGroundDecalTextureParams (function)
[source]Spring.SetGroundDecalTextureParams(DecalID, number?, number?) -> boolean?Parameters
DecalIDdecalIDnumber?texWrapDistance- (Default: currTexWrapDistance) if non-zero sets the mode to repeat the texture along the left-right direction of the decal every texWrapFactor elmos
number?texTraveledDistance- (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
boolean?decalSet
Spring.SetGroundDecalAlpha (function)
[source]Spring.SetGroundDecalAlpha(DecalID, number?, number?) -> booleanParameters
DecalIDdecalIDnumber?alpha- (Default: currAlpha) Between 0 and 1
number?alphaFalloff- (Default: currAlphaFalloff) Between 0 and 1, per second
Returns
booleandecalSet
Spring.SetGroundDecalNormal (function)
[source]
Sets projection cube normal to orient in 3D space. In case the normal (0,0,0) then normal is picked from the terrain
Spring.SetGroundDecalNormal(DecalID, number?, number?, number?) -> booleanParameters
Returns
booleandecalSet
Spring.SetGroundDecalTint (function)
[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
Spring.SetGroundDecalTint(DecalID, number?, number?, number?, number?) -> booleanParameters
DecalIDdecalIDnumber?tintColR- (Default: curTintColR)
number?tintColG- (Default: curTintColG)
number?tintColB- (Default: curTintColB)
number?tintColA- (Default: curTintColA)
Returns
booleandecalSet
Spring.SetGroundDecalMisc (function)
[source]
Sets varios secondary parameters of a decal
Spring.SetGroundDecalMisc(DecalID, number?, number?, number?, number?, number?) -> booleanParameters
DecalIDdecalIDnumber?dotElimExp- (Default: curValue) pow(max(dot(decalProjVector, SurfaceNormal), 0.0), dotElimExp), used to reduce decal artifacts on surfaces non-collinear with the projection vector
number?refHeight- (Default: curValue)
number?minHeight- (Default: curValue)
number?maxHeight- (Default: curValue)
number?forceHeightMode- (Default: curValue) in case forceHeightMode==1.0 ==> force relative height: midPoint.y = refHeight + clamp(midPoint.y - refHeight, minHeight); forceHeightMode==2.0 ==> force absolute height: midPoint.y = midPoint.y, clamp(midPoint.y, minHeight, maxHeight); other forceHeightMode values do not enforce the height of the center position
Returns
booleandecalSet
Spring.SetGroundDecalCreationFrame (function)
[source]
Use separate min and max for “gradient” style decals such as tank tracks
Spring.SetGroundDecalCreationFrame(DecalID, number?, number?) -> booleanParameters
DecalIDdecalIDnumber?creationFrameMin- (Default: currCreationFrameMin)
number?creationFrameMax- (Default: currCreationFrameMax)
Returns
booleandecalSet
Spring.SetGroundDecalGlowParams (function)
[source]
Set decal glow parameters
Spring.SetGroundDecalGlowParams(DecalID, number?, number?) -> booleanParameters
DecalIDdecalIDnumber?glow- Between 0 and 1 (Default: currGlow)
number?glowFalloff- Between 0 and 1, per second (Default: currGlowFallOff)
Returns
booleandecalSet
Spring.SetGroundDecalUserData (function)
[source]
Set decal user data. Useful in conjunction with custom decal shaders
Spring.SetGroundDecalUserData(DecalID, integer, number?, number?, number?, number?) -> booleanParameters
DecalIDdecalIDintegerudQuad- vec4 index, must be within [0;1] for now
number?x- Any valid Lua float number (Default: current data)
number?y- Any valid Lua float number (Default: current data)
number?z- Any valid Lua float number (Default: current data)
number?w- Any valid Lua float number (Default: current data)
Returns
booleandecalSet
Spring.SDLSetTextInputRect (function)
[source]Spring.SDLSetTextInputRect(integer, integer, integer, integer) -> nilParameters
Returns
Spring.SDLStartTextInput (function)
[source]Spring.SDLStartTextInput() -> nilReturns
Spring.SDLStopTextInput (function)
[source]Spring.SDLStopTextInput() -> nilReturns
Spring.SetWindowGeometry (function)
[source]Spring.SetWindowGeometry(integer, integer, integer, integer, integer, boolean, boolean) -> nilParameters
integerdisplayIndexintegerwinRelPosXintegerwinRelPosYintegerwinSizeXintegerwinSizeYbooleanfullScreenbooleanborderless
Returns
Spring.SetWindowMinimized (function)
[source]Spring.SetWindowMinimized() -> booleanReturns
booleanminimized
Spring.SetWindowMaximized (function)
[source]Spring.SetWindowMaximized() -> booleanReturns
booleanmaximized
Spring.Reload (function)
[source]Spring.Reload(string) -> nilParameters
stringstartScript- the CONTENT of the script.txt spring should use to start.
Returns
Spring.Restart (function)
[source]
If this call returns, something went wrong
Spring.Restart(string, string) -> nilParameters
stringcommandline_args- commandline arguments passed to spring executable.
stringstartScript
Returns
Spring.Start (function)
Launches a new Spring instance without terminating the existing one.
[source]
If this call returns, something went wrong
Spring.Start(string, string) -> nilParameters
stringcommandline_args- commandline arguments passed to spring executable.
stringstartScript- 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
Spring.SetWMIcon (function)
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.
Spring.SetWMIcon(string, boolean?) -> nilParameters
stringiconFileNameboolean?autoFree
Returns
Spring.SetWMCaption (function)
Set the window title for the process
[source]
Spring.SetWMCaption(string, string?) -> nilParameters
stringtitle- (Default:
“Spring <version>") string?titleShort(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
Spring.ClearWatchDogTimer (function)
[source]Spring.ClearWatchDogTimer(string?) -> nilParameters
string?threadName- (Default: main)
Returns
Spring.SetClipboard (function)
[source]Spring.SetClipboard(string) -> nilParameters
stringtext
Returns
Spring.Yield (function)
Relinquish control of the game loading thread and OpenGL context back to the UI (LuaIntro).
[source]
Should be called after each widget/unsynced gadget is loaded in widget/gadget handler. Use it to draw screen updates and process windows events.
Spring.Yield() -> booleanReturns
booleancontinueYielding- when true caller should continue calling Spring.Yield during the widgets/gadgets load, when false it shouldn’t call it any longer.
Spring.IsReplay (function)
[source]Spring.IsReplay() -> booleanReturns
booleanisReplay
Spring.GetReplayLength (function)
[source]Spring.GetReplayLength() -> number?Returns
number?timeInSeconds
Spring.GetGameName (function)
[source]Spring.GetGameName() -> stringReturns
stringname
Spring.GetReplayFilePath (function)
If a replay is currently being watched, returns its file path.
[source]
Spring.GetReplayFilePath() -> stringReturns
stringfilePath
Spring.GetReplayRecordingFilePath (function)
If a replay is being recorded, returns its projected file path. Note that replay contents are only written there at game exit. Note also that watching a replay also records a meta-replay if the DemoFromDemo springsetting is set.
[source]
Spring.GetReplayRecordingFilePath() -> stringReturns
stringfilePath
Spring.GetMenuName (function)
[source]Spring.GetMenuName() -> stringReturns
stringname- name .. version from Modinfo.lua. E.g. “Spring: 1944 test-5640-ac2d15b”.
Spring.GetProfilerTimeRecord (function)
[source]Spring.GetProfilerTimeRecord(string, boolean?) -> number, number, number, number, number, table<integer,number>?Parameters
stringprofilerNameboolean?frameData- (Default:
false)
Returns
numbertotal- in ms
numbercurrent- in ms
numbermax_dtnumbertime_pctnumberpeak_pcttable<integer,number>?frameData- Table where key is the frame index and value is duration.
Spring.GetProfilerRecordNames (function)
[source]Spring.GetProfilerRecordNames() -> string[]Returns
string[]profilerNames
Spring.GetLuaMemUsage (function)
[source]Spring.GetLuaMemUsage() -> number, number, number, number, number, number, number, numberReturns
numberluaHandleAllocedMem- in kilobytes
numberluaHandleNumAllocs- divided by 1000
numberluaGlobalAllocedMem- in kilobytes
numberluaGlobalNumAllocs- divided by 1000
numberluaUnsyncedGlobalAllocedMem- in kilobytes
numberluaUnsyncedGlobalNumAllocs- divided by 1000
numberluaSyncedGlobalAllocedMem- in kilobytes
numberluaSyncedGlobalNumAllocs- divided by 1000
Spring.GetVidMemUsage (function)
[source]Spring.GetVidMemUsage() -> number, numberReturns
numberusedMem- in MB
numberavailableMem- in MB
Spring.GetTimer (function)
Get a timer with millisecond resolution
[source]
Spring.GetTimer() -> integerReturns
Spring.GetTimerMicros (function)
Get a timer with microsecond resolution
[source]
Spring.GetTimerMicros() -> integerReturns
Spring.GetFrameTimer (function)
Get a timer for the start of the frame
[source]
This should give better results for camera interpolations
Spring.GetFrameTimer(boolean?) -> integerParameters
boolean?lastFrameTime- (Default:
false) whether to use last frame time instead of last frame start
Returns
Spring.DiffTimers (function)
[source]Spring.DiffTimers(integer, integer, boolean?, boolean?) -> numberParameters
integerendTimerintegerstartTimerboolean?returnMs- (Default:
false) whether to returntimeAmountin milliseconds as opposed to seconds boolean?fromMicroSecs- (Default:
false) whether timers are in microseconds instead of milliseconds
Returns
numbertimeAmount
Spring.GetNumDisplays (function)
[source]Spring.GetNumDisplays() -> integerReturns
integernumDisplays- as returned by
SDL_GetNumVideoDisplays
Spring.GetViewGeometry (function)
Get main view geometry (map and game rendering)
[source]
Spring.GetViewGeometry() -> integer, integer, integer, integerReturns
integerviewSizeX- in px
integerviewSizeY- in px
integerviewPosX- offset from leftmost screen left border in px
integerviewPosY- offset from bottommost screen bottom border in px
Spring.GetDualViewGeometry (function)
Get dual view geometry (minimap when enabled)
[source]
Spring.GetDualViewGeometry() -> integer, integer, integer, integerReturns
integerdualViewSizeX- in px
integerdualViewSizeY- in px
integerdualViewPosX- offset from leftmost screen left border in px
integerdualViewPosY- offset from bottommost screen bottom border in px
Spring.GetWindowGeometry (function)
Get main window geometry
[source]
Spring.GetWindowGeometry() -> integer, integer, integer, integer, integer, integer, integer, integerReturns
integerwinSizeX- in px
integerwinSizeY- in px
integerwinPosX- in px
integerwinPosY- in px
integerwindowBorderTop- in px
integerwindowBorderLeft- in px
integerwindowBorderBottom- in px
integerwindowBorderRight- in px
Spring.GetWindowDisplayMode (function)
Get main window display mode
[source]
Spring.GetWindowDisplayMode() -> integer, integer, integer, integerReturns
Spring.GetScreenGeometry (function)
Get screen geometry
[source]
Spring.GetScreenGeometry(integer?, boolean?) -> integer, integer, integer, integer, integer, integer, integer, integer, integer?, integer?, integer?, integer?Parameters
integer?displayIndex- (Default:
-1) boolean?queryUsable- (Default:
false)
Returns
integerscreenSizeX- in px
integerscreenSizeY- in px
integerscreenPosX- in px
integerscreenPosY- in px
integerwindowBorderTop- in px
integerwindowBorderLeft- in px
integerwindowBorderBottom- in px
integerwindowBorderRight- in px
integer?screenUsableSizeX- in px
integer?screenUsableSizeY- in px
integer?screenUsablePosX- in px
integer?screenUsablePosY- in px
Spring.GetMiniMapGeometry (function)
Get minimap geometry
[source]
Spring.GetMiniMapGeometry() -> integer, integer, integer, integer, boolean, booleanReturns
integerminimapPosX- in px
integerminimapPosY- in px
integerminimapSizeX- in px
integerminimapSizeY- in px
booleanminimizedbooleanmaximized
Spring.GetMiniMapRotation (function)
Get minimap rotation
[source]
Spring.GetMiniMapRotation() -> numberReturns
numberrotation- in radians
Spring.GetMiniMapDualScreen (function)
[source]Spring.GetMiniMapDualScreen() -> ("left"|"right"|false)Returns
("left"|"right"|false)position“left”or“right”when dual screen is enabled, otherwisefalse.
Spring.GetSelectionBox (function)
Get vertices from currently active selection box
[source]
Returns nil when selection box is inactive
See Spring.GetUnitsInScreenRectangle
Spring.GetSelectionBox() -> number?, number?, number?, number?Returns
Spring.GetDrawSelectionInfo (function)
[source]Spring.GetDrawSelectionInfo() -> booleanReturns
Spring.IsAboveMiniMap (function)
[source]Spring.IsAboveMiniMap(integer, integer) -> booleanParameters
Returns
booleanisAbove
Spring.GetDrawFrame (function)
[source]Spring.GetDrawFrame() -> integer, integerReturns
integerlow_16bitintegerhigh_16bit
Spring.GetFrameTimeOffset (function)
[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.
Spring.GetFrameTimeOffset() -> number?Returns
number?offset- of the current draw frame from the last sim frame, expressed in fractions of a frame
Spring.GetGameSecondsInterpolated (function)
Gets game time for drawing purposes
[source]
Returns the game time, taking the interpolated draw frame into account.
Spring.GetGameSecondsInterpolated() -> numberReturns
numbertime- in seconds
Spring.GetLastUpdateSeconds (function)
[source]Spring.GetLastUpdateSeconds() -> number?Returns
number?lastUpdateSeconds
Spring.GetVideoCapturingMode (function)
[source]Spring.GetVideoCapturingMode() -> booleanReturns
booleanallowRecord
Spring.GetPrevFrameSyncChecksum (function)
Returns the engine’s sync checksum for the previous simframe, useful for testing. The returned string is NOT convertible to a number within Lua.
Returns a dummy value if Platform.hasSyncChecksums is false, or if no frames were processed yet.
[source]
Spring.GetPrevFrameSyncChecksum() -> stringReturns
stringchecksum
Spring.IsUnitAllied (function)
[source]Spring.IsUnitAllied(UnitID) -> boolean?Parameters
Returns
boolean?isAllied- nil with unitID cannot be parsed
Spring.IsUnitSelected (function)
[source]Spring.IsUnitSelected(UnitID) -> boolean?Parameters
Returns
boolean?isSelected- nil when unitID cannot be parsed
Spring.GetUnitLuaDraw (function)
[source]Spring.GetUnitLuaDraw(UnitID) -> boolean?Parameters
Returns
boolean?draw- nil when unitID cannot be parsed
Spring.GetUnitNoDraw (function)
[source]Spring.GetUnitNoDraw(UnitID) -> boolean?Parameters
Returns
boolean?noDrawnilwhen unitID cannot be parsed
Spring.GetUnitEngineDrawMask (function)
[source]Spring.GetUnitEngineDrawMask(UnitID) -> boolean?Parameters
Returns
boolean?drawMasknilwhen unitID cannot be parsed
Spring.GetUnitAlwaysUpdateMatrix (function)
[source]Spring.GetUnitAlwaysUpdateMatrix(UnitID) -> boolean?Parameters
Returns
boolean?alwaysUpdateMatrixnilwhen unitID cannot be parsed
Spring.GetUnitDrawFlag (function)
[source]Spring.GetUnitDrawFlag(UnitID) -> number?Parameters
Returns
number?drawFlagnilwhen unitID cannot be parsed
Spring.GetUnitNoMinimap (function)
[source]Spring.GetUnitNoMinimap(UnitID) -> boolean?Parameters
Returns
boolean?noMinimapnilwhen unitID cannot be parsed
Spring.GetUnitNoGroup (function)
Check if a unit is not allowed to be added to a group by a player.
[source]
Spring.GetUnitNoGroup(UnitID) -> boolean?Parameters
Returns
boolean?noGrouptrueif the unit is not allowed to be added to a group,falseif it is allowed to be added to a group, ornilwhenunitIDis not valid.
Spring.GetUnitNoSelect (function)
[source]Spring.GetUnitNoSelect(UnitID) -> boolean?Parameters
Returns
boolean?noSelectnilwhenunitIDcannot be parsed.
Spring.UnitIconGetDraw (function)
[source]Spring.UnitIconGetDraw(UnitID) -> boolean?Parameters
Returns
boolean?drawIcon
Spring.GetUnitIconData (function)
Get unit icon data
[source]
Spring.GetUnitIconData(UnitID, boolean?) -> IconData?Parameters
UnitIDunitIDboolean?fullData- (Default: false) Whether additional information about the icon is returned, otherwise only
nameandatlasTexCoordsare returned
Returns
IconData?nilif unit is not found or unit currentIconIndex is invalid
Spring.GetUnitIcon (function)
Get unit icon name
[source]
Spring.GetUnitIcon(UnitID) -> stringParameters
Returns
stringiconName
Spring.GetIconData (function)
Get icon data
[source]
Spring.GetIconData(string, boolean?) -> IconData?Parameters
stringiconNameboolean?fullData- (Default: false) Whether additional information about the icon is returned, otherwise only
nameandatlasTexCoordsare returned
Returns
IconData?nilif iconName lookup fails
Spring.GetAllIconDataArray (function)
Get icon data
[source]
Spring.GetAllIconDataArray(boolean?) -> IconData[]Parameters
boolean?fullData- (Default: false) Whether additional information about each icon is returned, otherwise only
nameandatlasTexCoordsare returned
Returns
Spring.GetUnitSelectionVolumeData (function)
[source]Spring.GetUnitSelectionVolumeData(UnitID) -> number?, number, number, number, number, number, integer, integer, integer, booleanParameters
Returns
number?scaleX- nil when unitID cannot be parsed
numberscaleYnumberscaleZnumberoffsetXnumberoffsetYnumberoffsetZintegervolumeTypeintegeruseContHitTestintegergetPrimaryAxisbooleanignoreHits
Spring.GetFeatureLuaDraw (function)
[source]Spring.GetFeatureLuaDraw(FeatureID) -> boolean?Parameters
Returns
boolean?luaDrawnilwhen featureID cannot be parsed
Spring.GetFeatureNoDraw (function)
[source]Spring.GetFeatureNoDraw(FeatureID) -> boolean?Parameters
Returns
boolean?noDrawnilwhen featureID cannot be parsed
Spring.GetFeatureEngineDrawMask (function)
[source]Spring.GetFeatureEngineDrawMask(FeatureID) -> boolean?Parameters
Returns
boolean?drawMasknilwhen featureID cannot be parsed
Spring.GetFeatureAlwaysUpdateMatrix (function)
[source]Spring.GetFeatureAlwaysUpdateMatrix(FeatureID) -> boolean?Parameters
Returns
boolean?alwaysUpdateMatrixnilwhen featureID cannot be parsed
Spring.GetFeatureDrawFlag (function)
[source]Spring.GetFeatureDrawFlag(FeatureID) -> number?Parameters
Returns
number?drawFlagnilwhen featureID cannot be parsed
Spring.GetFeatureSelectionVolumeData (function)
[source]Spring.GetFeatureSelectionVolumeData(FeatureID) -> number?, number, number, number, number, number, integer, integer, integer, booleanParameters
Returns
number?scaleX- nil when featureID cannot be parsed
numberscaleYnumberscaleZnumberoffsetXnumberoffsetYnumberoffsetZintegervolumeTypeintegeruseContHitTestintegergetPrimaryAxisbooleanignoreHits
Spring.GetUnitTransformMatrix (function)
[source]Spring.GetUnitTransformMatrix(UnitID) -> nilParameters
Returns
Spring.GetUnitTransformMatrix (function overload 1)
[source]Spring.GetUnitTransformMatrix(UnitID) -> number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, numberParameters
Returns
numberm11numberm12numberm13numberm14numberm21numberm22numberm23numberm24numberm31numberm32numberm33numberm34numberm41numberm42numberm43numberm44
Spring.GetFeatureTransformMatrix (function)
[source]Spring.GetFeatureTransformMatrix(FeatureID) -> nilParameters
Returns
Spring.GetFeatureTransformMatrix (function overload 1)
[source]Spring.GetFeatureTransformMatrix(FeatureID) -> number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, numberParameters
Returns
numberm11numberm12numberm13numberm14numberm21numberm22numberm23numberm24numberm31numberm32numberm33numberm34numberm41numberm42numberm43numberm44
Spring.IsUnitInView (function)
[source]Spring.IsUnitInView(UnitID) -> boolean?Parameters
Returns
boolean?inView- nil when unitID cannot be parsed
Spring.IsUnitVisible (function)
[source]Spring.IsUnitVisible(UnitID, number?, boolean) -> boolean?Parameters
Returns
boolean?isVisible- nil when unitID cannot be parsed
Spring.IsUnitIcon (function)
[source]Spring.IsUnitIcon(UnitID) -> boolean?Parameters
Returns
boolean?isUnitIcon- nil when unitID cannot be parsed
Spring.IsAABBInView (function)
[source]Spring.IsAABBInView(number, number, number, number, number, number) -> booleanParameters
Returns
booleaninView
Spring.IsSphereInView (function)
[source]Spring.IsSphereInView(number, number, number, number?) -> booleanParameters
Returns
booleaninView
Spring.GetUnitViewPosition (function)
[source]Spring.GetUnitViewPosition(UnitID, boolean?) -> number?, number, numberParameters
Returns
Spring.GetVisibleUnits (function)
[source]Spring.GetVisibleUnits(TeamID?, number?, boolean?) -> UnitID[]?Parameters
Returns
Spring.GetVisibleFeatures (function)
[source]Spring.GetVisibleFeatures(TeamID?, number?, boolean?, boolean?) -> FeatureID[]?Parameters
TeamID?teamID- (Default:
-1) number?radius- (Default:
30) boolean?icons- (Default:
true) boolean?geos- (Default:
true)
Returns
Spring.GetVisibleProjectiles (function)
[source]Spring.GetVisibleProjectiles(AllyTeamID?, boolean?, boolean?, boolean?) -> ProjectileID[]?Parameters
AllyTeamID?allyTeamID- (Default:
-1) boolean?addSyncedProjectiles- (Default:
true) boolean?addWeaponProjectiles- (Default:
true) boolean?addPieceProjectiles- (Default:
true)
Returns
Spring.GetRenderUnits (function)
[source]Spring.GetRenderUnits(DrawMask, true) -> UnitID[], DrawFlag[]Parameters
DrawMaskdrawMask- (Default:
0) Filter objects by their draw flags. truesendMask- Whether to send objects draw flags as second return
Returns
Spring.GetRenderUnits (function overload 1)
[source]Spring.GetRenderUnits(DrawMask, false?) -> UnitID[]Parameters
DrawMaskdrawMask- (Default:
0) Filter objects by their draw flags. false?sendMask- Whether to send objects draw flags as second return
Returns
Spring.GetRenderUnitsDrawFlagChanged (function)
[source]
Gets a list of IDs of units that have had their draw flags changed, and the corresponding flags.
Spring.GetRenderUnitsDrawFlagChanged(true) -> UnitID[], DrawFlag[]Parameters
truesendMask- Whether to send objects draw flags as second return.
Returns
Spring.GetRenderUnitsDrawFlagChanged (function overload 1)
[source]
Gets a list of IDs of units that have had their draw flags changed, and the corresponding flags.
Spring.GetRenderUnitsDrawFlagChanged(false?) -> UnitID[]Parameters
false?sendMask- Whether to send objects draw flags as second return.
Returns
Spring.GetRenderFeatures (function)
[source]Spring.GetRenderFeatures(DrawMask, true) -> FeatureID[], DrawFlag[]Parameters
DrawMaskdrawMask- (Default:
0) Filter objects by their draw flags. truesendMask- Whether to send objects draw flags as second return
Returns
Spring.GetRenderFeatures (function overload 1)
[source]Spring.GetRenderFeatures(DrawMask, false?) -> FeatureID[]Parameters
DrawMaskdrawMask- (Default:
0) Filter objects by their draw flags. false?sendMask- Whether to send objects draw flags as second return
Returns
Spring.GetRenderFeaturesDrawFlagChanged (function)
[source]
Gets a list of IDs of features that have had their draw flags changed, and the corresponding flags.
Spring.GetRenderFeaturesDrawFlagChanged(true) -> FeatureID[], DrawFlag[]Parameters
truesendMask- Whether to send objects draw flags as second return.
Returns
Spring.GetRenderFeaturesDrawFlagChanged (function overload 1)
[source]
Gets a list of IDs of features that have had their draw flags changed, and the corresponding flags.
Spring.GetRenderFeaturesDrawFlagChanged(false?) -> FeatureID[]Parameters
false?sendMask- Whether to send objects draw flags as second return.
Returns
Spring.ClearUnitsPreviousDrawFlag (function)
[source]Spring.ClearUnitsPreviousDrawFlag() -> nilSpring.ClearFeaturesPreviousDrawFlag (function)
[source]Spring.ClearFeaturesPreviousDrawFlag() -> nilSpring.GetUnitsInScreenRectangle (function)
Get units inside a rectangle area on the map
[source]
Spring.GetUnitsInScreenRectangle(number, number, number, number, integer?) -> UnitID[]?Parameters
numberleftnumbertopnumberrightnumberbottominteger?allegiance- (Default:
-1) teamID when > 0, when < 0 one of AllUnits = -1, MyUnits = -2, AllyUnits = -3, EnemyUnits = -4
Returns
Spring.GetFeaturesInScreenRectangle (function)
Get features inside a rectangle area on the map
[source]
Spring.GetFeaturesInScreenRectangle(number, number, number, number) -> FeatureID[]?Parameters
Returns
Spring.GetLocalPlayerID (function)
[source]Spring.GetLocalPlayerID() -> PlayerIDReturns
Spring.GetMyPlayerID (function)
[source]
Alias of GetLocalPlayerID
Spring.GetMyPlayerID() -> PlayerIDReturns
Spring.GetLocalTeamID (function)
[source]Spring.GetLocalTeamID() -> TeamIDReturns
Spring.GetMyTeamID (function)
[source]
Alias of GetLocalTeamID
Spring.GetMyTeamID() -> TeamIDReturns
Spring.GetLocalAllyTeamID (function)
[source]Spring.GetLocalAllyTeamID() -> AllyTeamIDReturns
Spring.GetMyAllyTeamID (function)
[source]
Alias of GetLocalAllyTeamID
Spring.GetMyAllyTeamID() -> AllyTeamIDReturns
Spring.GetSpectatingState (function)
[source]Spring.GetSpectatingState() -> boolean, boolean, booleanReturns
booleanspectatingbooleanspectatingFullViewbooleanspectatingFullSelect
Spring.GetSelectedUnits (function)
[source]Spring.GetSelectedUnits() -> UnitID[]Returns
Spring.GetSelectedUnitsSorted (function)
Get selected units aggregated by unitDefID
[source]
Spring.GetSelectedUnitsSorted() -> table<UnitDefID,UnitID[]>, integerReturns
Spring.GetSelectedUnitsCounts (function)
Get an aggregate count of selected units per unitDefID
[source]
Spring.GetSelectedUnitsCounts() -> table<UnitDefID,integer>, integerReturns
table<UnitDefID,integer>unitsCountsintegercountDefs- the number of unitDefIDs
Spring.GetSelectedUnitsCount (function)
Returns the amount of selected units
[source]
Spring.GetSelectedUnitsCount() -> integerReturns
integerselectedUnitsCount
Spring.GetBoxSelectionByEngine (function)
Get if selection box is handled by engine.
[source]
See Spring.SetBoxSelectionByEngine
Spring.GetBoxSelectionByEngine() -> booleanReturns
booleanisHandledByEnginetrueif the engine will select units inside selection box on release, otherwisefalse.
Spring.IsGUIHidden (function)
[source]Spring.IsGUIHidden() -> booleanReturns
Spring.HaveShadows (function)
[source]Spring.HaveShadows() -> booleanReturns
booleanshadowsLoaded
Spring.HaveAdvShading (function)
[source]Spring.HaveAdvShading() -> boolean, booleanReturns
booleanuseAdvShadingbooleangroundUseAdvShading
Spring.GetWaterMode (function)
[source]See rts/Rendering/Env/IWater.h
Spring.GetWaterMode() -> integer, stringReturns
integerwaterRendererIDstringwaterRendererName
Spring.GetMapDrawMode (function)
[source]Spring.GetMapDrawMode() -> ("normal"|"height"|"metal"|"pathTraversability"|"los")Returns
Spring.GetMapSquareTexture (function)
[source]Spring.GetMapSquareTexture(integer, integer, integer, string, integer?) -> boolean?Parameters
integertexSquareXintegertexSquareYintegerlodMinstringluaTexNameinteger?lodMax- (Default: lodMin)
Returns
boolean?success
Spring.GetLosViewColors (function)
[source]Spring.GetLosViewColors() -> rgb, rgb, rgb, rgb, rgbReturns
Spring.GetNanoProjectileParams (function)
[source]Spring.GetNanoProjectileParams() -> number, number, number, number, number, numberReturns
numberrotVal- in degrees
numberrotVel- in degrees
numberrotAcc- in degrees
numberrotValRng- in degrees
numberrotVelRng- in degrees
numberrotAccRng- in degrees
Spring.GetCameraNames (function)
Get available cameras.
[source]
Spring.GetCameraNames() -> table<string,integer>Returns
table<string,integer>indexByName- Table where where keys are names and values are indices.
Spring.GetCameraState (function)
[source]Spring.GetCameraState(false) -> CameraName, any ...Parameters
falseuseTable
Returns
CameraNamenameany ...depends- on the current controller mode.
Spring.GetCameraState (function overload 1)
[source]Spring.GetCameraState(true?) -> CameraStateParameters
true?useTable- (Default:
true) Return a table instead of multiple values.
Returns
Spring.GetCameraPosition (function)
[source]Spring.GetCameraPosition() -> number, number, numberReturns
Spring.GetCameraDirection (function)
[source]Spring.GetCameraDirection() -> number, number, numberReturns
Spring.GetCameraRotation (function)
Get camera rotation in radians.
[source]
Spring.GetCameraRotation() -> number, number, numberReturns
numberrotX- Rotation around X axis in radians.
numberrotY- Rotation around Y axis in radians.
numberrotZ- Rotation around Z axis in radians.
Spring.GetCameraFOV (function)
[source]Spring.GetCameraFOV() -> number, numberReturns
Spring.GetCameraVectors (function)
[source]Spring.GetCameraVectors() -> CameraVectorsReturns
Spring.WorldToScreenCoords (function)
[source]Spring.WorldToScreenCoords(number, number, number) -> number, number, numberParameters
Returns
Spring.TraceScreenRay (function)
Get information about a ray traced from screen to world position
[source]
Extended to allow a custom plane, parameters are (0, 1, 0, D=0) where D is the offset D can be specified in the third argument (if all the bools are false) or in the seventh (as shown).
Intersection coordinates are returned in t[4],t[5],t[6] when the ray goes offmap and includeSky is true), or when no unit or feature is hit (or onlyCoords is true).
This will only work for units & objects with the default collision sphere. Per Piece collision and custom collision objects are not supported.
The unit must be selectable, to appear to a screen trace ray.
Spring.TraceScreenRay(integer, integer, boolean?, boolean?, boolean?, boolean?, number?) -> string?, (UnitID|FeatureID|string|xyz)?, (FeatureID|string)?, xyz?Parameters
integerscreenX- position on x axis in mouse coordinates (origin on left border of view)
integerscreenY- position on y axis in mouse coordinates (origin on top border of view)
boolean?onlyCoords- (Default:
false) return only description (1st return value) and coordinates (2nd return value) boolean?useMinimap- (Default:
false) if position arguments are contained by minimap, use the minimap corresponding world position boolean?includeSky- (Default:
false) boolean?ignoreWater- (Default:
false) number?heightOffset- (Default:
0)
Returns
string?description- of traced position
(UnitID|FeatureID|string|xyz)?unitID- or feature, position triple when onlyCoords=true
(FeatureID|string)?featureID- or ground
xyz?coords
Spring.GetPixelDir (function)
[source]Spring.GetPixelDir(integer, integer) -> number, number, numberParameters
Returns
Spring.GetTeamColor (function)
[source]Spring.GetTeamColor(TeamID) -> number?, number?, number?, number?Parameters
Returns
number?r- factor from 0 to 1
number?g- factor from 0 to 1
number?b- factor from 0 to 1
number?a- factor from 0 to 1
Spring.GetTeamOrigColor (function)
[source]Spring.GetTeamOrigColor(TeamID) -> number?, number?, number?, number?Parameters
Returns
number?r- factor from 0 to 1
number?g- factor from 0 to 1
number?b- factor from 0 to 1
number?a- factor from 0 to 1
Spring.GetCustomPaletteColor (function)
[source]Spring.GetCustomPaletteColor(integer) -> number?, number?, number?Parameters
integerindex- 0-based index into custom palette
Returns
Spring.GetUnitPaletteIndex (function)
Returns the custom palette index for a unit, or nil if using team color.
[source]
Spring.GetUnitPaletteIndex(UnitID) -> integer?Parameters
Returns
integer?customIndex- [0..MAX_CUSTOM_COLORS) if unit uses a custom color, nil if using team color
Spring.GetFeaturePaletteIndex (function)
Returns the custom palette index for a feature, or nil if using team color.
[source]
Spring.GetFeaturePaletteIndex(FeatureID) -> integer?Parameters
Returns
integer?customIndex- [0..MAX_CUSTOM_COLORS) if feature uses a custom color, nil if using team color
Spring.GetDrawSeconds (function)
[source]Spring.GetDrawSeconds() -> integerReturns
integertime- Time in seconds.
Spring.GetSoundDevices (function)
[source]Spring.GetSoundDevices() -> SoundDeviceSpec[]Returns
SoundDeviceSpec[]devices- Sound devices.
Spring.GetSoundStreamTime (function)
[source]Spring.GetSoundStreamTime() -> number, numberReturns
Spring.GetSoundEffectParams (function)
[source]Spring.GetSoundEffectParams() -> table?Returns
table?soundEffectParamsnilon headless/no-sound builds or when EFX is unsupported.
Spring.GetFPS (function)
[source]Spring.GetFPS() -> integerReturns
integerfps
Spring.GetGameSpeed (function)
[source]Spring.GetGameSpeed() -> number, number, booleanReturns
numberwantedSpeedFactornumberspeedFactorbooleanpaused
Spring.GetGameState (function)
[source]Spring.GetGameState(number?) -> boolean, boolean, boolean, booleanParameters
number?maxLatency- (Default:
500) used forisSimLaggingreturn parameter
Returns
booleandoneLoadingbooleanisSavedGamebooleanisClientPausedbooleanisSimLagging
Spring.GetActiveCommand (function)
[source]Spring.GetActiveCommand() -> integer?, integer?, integer?, string?Returns
Spring.GetDefaultCommand (function)
[source]Spring.GetDefaultCommand() -> integer?, integer?, integer?, string?Returns
Spring.GetActiveCmdDescs (function)
[source]Spring.GetActiveCmdDescs() -> CommandDescription[]Returns
Spring.GetActiveCmdDesc (function)
[source]Spring.GetActiveCmdDesc(integer) -> CommandDescription?Parameters
integercmdIndex
Returns
Spring.GetCmdDescIndex (function)
[source]Spring.GetCmdDescIndex(integer) -> integer?Parameters
integercmdID
Returns
integer?cmdDescIndex
Spring.GetBuildFacing (function)
[source]Spring.GetBuildFacing() -> FacingIntegerReturns
Spring.GetBuildSpacing (function)
[source]Spring.GetBuildSpacing() -> integerReturns
integerbuildSpacing
Spring.GetGatherMode (function)
[source]Spring.GetGatherMode() -> integerReturns
integergatherMode
Spring.GetActivePage (function)
[source]Spring.GetActivePage() -> integer, integerReturns
integeractivePageintegermaxPage
Spring.GetMouseState (function)
[source]Spring.GetMouseState() -> integer, integer, boolean, boolean, boolean, boolean, booleanReturns
integerxintegerybooleanlmbPressed- left mouse button pressed
booleanmmbPressed- middle mouse button pressed
booleanrmbPressed- right mouse button pressed
booleanoffscreenbooleanmmbScroll
Spring.GetMouseCursor (function)
[source]Spring.GetMouseCursor() -> string, numberReturns
stringcursorNamenumbercursorScale
Spring.GetMouseStartPosition (function)
[source]Spring.GetMouseStartPosition(integer) -> integer, integer, number, number, number, number, number, numberParameters
integerbutton
Returns
Spring.GetMouseButtonsPressed (function)
[source]
Get pressed status for specific buttons.
Spring.GetMouseButtonsPressed(integer, [integer, ]*) -> boolean ...Parameters
Returns
boolean ...Pressed- status for the buttons.
Spring.GetClipboard (function)
[source]Spring.GetClipboard() -> stringReturns
stringtext
Spring.IsUserWriting (function)
[source]Spring.IsUserWriting() -> booleanReturns
Spring.GetLastMessagePositions (function)
[source]Spring.GetLastMessagePositions() -> xyz[]Returns
Spring.GetConsoleBuffer (function)
[source]Spring.GetConsoleBuffer(integer) -> { priority: integer, text: string }[]Parameters
integermaxLines
Returns
{ priority: integer, text: string }[]buffer
Spring.GetCurrentTooltip (function)
[source]Spring.GetCurrentTooltip() -> stringReturns
stringtooltip
Spring.GetKeyFromScanSymbol (function)
[source]Spring.GetKeyFromScanSymbol(string?) -> stringParameters
string?scanSymbol
Returns
stringkeyName
Spring.GetKeyState (function)
[source]Spring.GetKeyState(integer) -> booleanParameters
integerkeyCode
Returns
booleanpressed
Spring.GetModKeyState (function)
[source]Spring.GetModKeyState() -> boolean, boolean, boolean, booleanReturns
Spring.GetPressedKeys (function)
[source]Spring.GetPressedKeys() -> table<(integer|string),true>Returns
table<(integer|string),true>keys- where keys are keyCodes or key names
Spring.GetPressedScans (function)
[source]Spring.GetPressedScans() -> table<(integer|string),true>Returns
table<(integer|string),true>scans- where keys are scanCodes or scan names
Spring.GetInvertQueueKey (function)
[source]Spring.GetInvertQueueKey() -> number?Returns
number?queueKey
Spring.GetKeyCode (function)
[source]Spring.GetKeyCode(string) -> integerParameters
stringkeySym
Returns
integerkeyCode
Spring.GetKeySymbol (function)
[source]Spring.GetKeySymbol(integer) -> string, stringParameters
integerkeyCode
Returns
stringkeyCodeNamestringkeyCodeDefaultName- name when there are not aliases
Spring.GetScanSymbol (function)
[source]Spring.GetScanSymbol(integer) -> string, stringParameters
integerscanCode
Returns
stringscanCodeNamestringscanCodeDefaultName- name when there are not aliases
Spring.GetKeyBindings (function)
[source]Spring.GetKeyBindings(string?, string?) -> KeyBinding[]Parameters
Returns
Spring.GetActionHotKeys (function)
[source]Spring.GetActionHotKeys(string) -> string[]?Parameters
stringactionName
Returns
string[]?hotkeys
Spring.GetGroupList (function)
[source]Spring.GetGroupList() -> table<GroupID,integer>?Returns
table<GroupID,integer>?groupCounts
Spring.GetSelectedGroup (function)
[source]Spring.GetSelectedGroup() -> GroupIDReturns
Spring.GetUnitGroup (function)
[source]Spring.GetUnitGroup(UnitID) -> GroupID?Parameters
Returns
Spring.GetGroupUnits (function)
[source]Spring.GetGroupUnits(GroupID) -> UnitID[]?Parameters
Returns
Spring.GetGroupUnitsSorted (function)
[source]Spring.GetGroupUnitsSorted(GroupID) -> table<UnitDefID,UnitID[]>?Parameters
Returns
table<UnitDefID,UnitID[]>?unitsIDs
Spring.GetGroupUnitsCounts (function)
[source]Spring.GetGroupUnitsCounts(GroupID) -> table<UnitDefID,integer>?Parameters
Returns
table<UnitDefID,integer>?unitsCounts
Spring.GetGroupUnitsCount (function)
[source]Spring.GetGroupUnitsCount(GroupID) -> integer?Parameters
Returns
integer?groupSize
Spring.GetPlayerRoster (function)
[source]Spring.GetPlayerRoster(integer?, boolean?) -> Roster[]?Parameters
integer?sortType- return unsorted if unspecified. Disabled = 0, Allies = 1, TeamID = 2, PlayerName = 3, PlayerCPU = 4, PlayerPing = 5
boolean?showPathingPlayers- (Default:
false)
Returns
Spring.GetPlayerTraffic (function)
[source]Spring.GetPlayerTraffic(PlayerID, integer?) -> integerParameters
Returns
integertraffic
Spring.GetPlayerStatistics (function)
[source]Spring.GetPlayerStatistics(PlayerID) -> integer?, integer, integer, integer, integerParameters
Returns
integer?mousePixels- nil when invalid playerID
integermouseClicksintegerkeyPressesintegernumCommandsintegerunitCommands
Spring.GetConfigParams (function)
[source]Spring.GetConfigParams() -> Configuration[]Returns
Spring.GetConfigInt (function)
[source]Spring.GetConfigInt(string, integer) -> integerParameters
Returns
Spring.GetConfigFloat (function)
[source]Spring.GetConfigFloat(string, number) -> numberParameters
Returns
Spring.GetConfigString (function)
[source]Spring.GetConfigString(string, string) -> stringParameters
Returns
Spring.GetLogSections (function)
[source]Spring.GetLogSections() -> table<string,integer>Returns
table<string,integer>sections- where keys are names and loglevel are values. E.g.
{ “KeyBindings” = LOG.INFO, “Font” = LOG.INFO, “Sound” = LOG.WARNING, … }
Spring.GetAllGroundDecals (function)
[source]Spring.GetAllGroundDecals() -> DecalID[]Returns
Spring.GetGroundDecalMiddlePos (function)
[source]Spring.GetGroundDecalMiddlePos(DecalID) -> number?, numberParameters
Returns
Spring.GetGroundDecalQuadPos (function)
[source]Spring.GetGroundDecalQuadPos(DecalID) -> number?, number, number, number, number, number, number, numberParameters
Returns
number?posTL.xnumberposTL.znumberposTR.xnumberposTR.znumberposBR.xnumberposBR.znumberposBL.xnumberposBL.z
Spring.GetGroundDecalSizeAndHeight (function)
[source]Spring.GetGroundDecalSizeAndHeight(DecalID) -> number?, number, numberParameters
Returns
number?sizeXnumbersizeYnumberprojCubeHeight
Spring.GetGroundDecalRotation (function)
[source]Spring.GetGroundDecalRotation(DecalID) -> number?Parameters
Returns
number?rotation- Rotation in radians.
Spring.GetGroundDecalTexture (function)
[source]Spring.GetGroundDecalTexture(DecalID, boolean?) -> string?Parameters
Returns
string?texture
Spring.GetGroundDecalTextures (function)
[source]See Spring.GetGroundDecalTexture
Spring.GetGroundDecalTextures(boolean?, boolean?) -> string[]Parameters
boolean?isMainTex- (Default:
nil). Ifnil- no filtering is done, iffalse- return normal/glow textures, iftrue- return main color textures. boolean?addFilenames- (Default:
false). Iftrueadd the texture filenames in the second table
Returns
string[]textureNames- All textures on the atlas and available for use in
SetGroundDecalTexture.
Spring.GetGroundDecalTextureParams (function)
[source]Spring.GetGroundDecalTextureParams(DecalID) -> number?, numberParameters
Returns
number?texWrapDistance- If non-zero, sets the mode to repeat the texture along the left-right direction of the decal every texWrapFactor elmos.
numbertexTraveledDistance- 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.
Spring.GetGroundDecalAlpha (function)
[source]Spring.GetGroundDecalAlpha(DecalID) -> number?, numberParameters
Returns
number?alpha- Between 0 and 1
numberalphaFalloff- Between 0 and 1, per second
Spring.GetGroundDecalNormal (function)
[source]
If all three equal 0, the decal follows the normals of ground at midpoint
Spring.GetGroundDecalNormal(DecalID) -> number?, number, numberParameters
Returns
Spring.GetGroundDecalTint (function)
[source]
Gets the tint of the ground decal. A color of (0.5, 0.5, 0.5, 0.5) is effectively no tint
Spring.GetGroundDecalTint(DecalID) -> number?, number, number, numberParameters
Returns
Spring.GetGroundDecalMisc (function)
[source]
Returns less important parameters of a ground decal
Spring.GetGroundDecalMisc(DecalID) -> number?, number, number, number, numberParameters
Returns
number?dotElimExpnumberrefHeightnumberminHeightnumbermaxHeightnumberforceHeightMode
Spring.GetGroundDecalCreationFrame (function)
[source]
Min can be not equal to max for “gradient” style decals, e.g. unit tracks
Spring.GetGroundDecalCreationFrame(DecalID) -> number?, numberParameters
Returns
number?creationFrameMinnumbercreationFrameMax
Spring.GetGroundDecalOwner (function)
[source]Spring.GetGroundDecalOwner(DecalID) -> integer?Parameters
Returns
integer?value- If owner is a unit, then this is
unitID, if owner is a feature it isfeatureID + MAX_UNITS. If there is no owner, thennil.
Spring.GetGroundDecalGlowParams (function)
[source]
Gets the glow parameters of the ground decal.
Spring.GetGroundDecalGlowParams(DecalID) -> number?, numberParameters
Returns
number?glow- Between 0 and 1
numberglowFalloff- Between 0 and 1, per second
Spring.GetGroundDecalUserData (function)
[source]
Gets the user defined decal data.
Spring.GetGroundDecalUserData(DecalID, integer) -> number?, number, number, numberParameters
Returns
Spring.GetGroundDecalType (function)
[source]Spring.GetGroundDecalType(DecalID) -> ("explosion"|"plate"|"lua"|"track"|"unknown")?Parameters
Returns
("explosion"|"plate"|"lua"|"track"|"unknown")?type
Spring.GetSyncedGCInfo (function)
[source]Spring.GetSyncedGCInfo(boolean?) -> integer?Parameters
boolean?collectGC- (Default:
false) collect before returning metric
Returns
integer?GC- values are expressed in Kbytes: #bytes/2^10
Spring.SolveNURBSCurve (function)
[source]Spring.SolveNURBSCurve(integer, number[], number[], integer) -> number[]Parameters
integerdegree- Degree of the curve.
number[]controlPoints- Flat array of
x, y, z, weightquadruples; its length must be a multiple of 4. number[]knots- Knot vector.
integersegments- Number of segments to evaluate.
Returns
number[]points- Flat array of
x, y, ztriples along the curve.
Spring.SetShockFrontFactors (function)
[source]Spring.SetShockFrontFactors(number?, number?, number?) -> nilParameters
Spring.CallAsTeam (function)
Calls a function from given team’s PoV. In particular this makes callouts obey that team’s visibility rules.
[source]
Spring.CallAsTeam(TeamID, fun(...), [any, ]*) -> any ...Parameters
Returns
any ...The- return values of the function.
Spring.CallAsTeam (function overload 1)
[source]Spring.CallAsTeam(CallAsTeamOptions, fun(...), [any, ]*) -> any ...Parameters
CallAsTeamOptionsoptions- Options.
fun(...)func- The function to call.
any...- Arguments to pass to the function.
Returns
any ...The- return values of the function.
Fields
MoveCtrlMoveCtrl- [source]
UnitScriptTableUnitScript- [source]
integerALL_UNITS- [source]
integerMY_UNITS- [source]
integerALLY_UNITS- [source]
integerENEMY_UNITS- [source]
ObjectRenderingTableUnitRendering- [source]
ObjectRenderingTableFeatureRendering- [source]
Callins (class)
[source]Members
Callins:Initialize (function)
Called when the addon is (re)loaded.
[source]
Callins:Initialize() -> nilCallins:LoadCode (function)
Called when the game is (re)loaded.
[source]
Callins:LoadCode() -> nilCallins:Shutdown (function)
Called when the addon or the game is shutdown.
[source]
Callins:Shutdown() -> nilReturns
Callins:GotChatMsg (function)
Called when a player issues a UI command e.g. types /foo or /luarules foo.
[source]
Callins:GotChatMsg(string, PlayerID) -> nilParameters
Callins:Load (function)
Called after GamePreload and before GameStart. See Lua_SaveLoad.
[source]
Callins:Load(table) -> nilParameters
tablezipReader
Callins:GamePreload (function)
Called before the 0 gameframe.
Is not called when a saved game is loaded.
[source]
Callins:GamePreload() -> nilCallins:GameStart (function)
Called upon the start of the game.
[source]
Is not called when a saved game is loaded.
Callins:GameStart() -> nilCallins:GameOver (function)
Called when the game ends
[source]
Callins:GameOver(AllyTeamID[]) -> nilParameters
AllyTeamID[]winningAllyTeams- list of winning allyTeams, if empty the game result was undecided (like when dropping from an host).
Callins:GamePaused (function)
Called when the game is paused.
[source]
Callins:GamePaused(PlayerID, boolean) -> nilParameters
Callins:GameFrame (function)
Called for every game simulation frame (30 per second).
[source]
Callins:GameFrame(integer) -> nilParameters
integerframe- Starts at frame 1
Callins:GameFramePost (function)
Called at the end of every game simulation frame
[source]
Callins:GameFramePost(integer) -> nilParameters
integerframe- Starts at frame 1
Callins:GameID (function)
Called once to deliver the gameID
[source]
Callins:GameID(string) -> nilParameters
stringgameID- encoded in hex.
Callins:TeamDied (function)
Called when a team dies (see Spring.KillTeam).
[source]
Callins:TeamDied(TeamID) -> nilParameters
Callins:TeamChanged (function)
[source]Callins:TeamChanged(TeamID) -> nilParameters
Callins:PlayerChanged (function)
Called whenever a player’s status changes e.g. becoming a spectator.
[source]
Callins:PlayerChanged(PlayerID) -> nilParameters
Callins:PlayerAdded (function)
Called whenever a new player joins the game.
[source]
Callins:PlayerAdded(PlayerID) -> nilParameters
Callins:PlayerRemoved (function)
Called whenever a player is removed from the game.
[source]
Callins:PlayerRemoved(PlayerID, integer) -> nilParameters
Callins:UnitCreated (function)
Called at the moment the unit is created.
[source]
Callins:UnitCreated(UnitID, UnitDefID, TeamID, UnitID?) -> nilParameters
Callins:UnitFinished (function)
Called at the moment the unit is completed.
[source]
Callins:UnitFinished(UnitID, UnitDefID, TeamID) -> nilParameters
Callins:UnitFromFactory (function)
Called when a factory finishes construction of a unit.
[source]
Callins:UnitFromFactory(UnitID, UnitDefID, TeamID, UnitID, UnitDefID, boolean) -> nilParameters
Callins:UnitReverseBuilt (function)
Called when a living unit becomes a nanoframe again.
[source]
Callins:UnitReverseBuilt(UnitID, UnitDefID, TeamID) -> nilParameters
Callins:UnitConstructionDecayed (function)
Called when a unit being built starts decaying.
[source]
Callins:UnitConstructionDecayed(UnitID, UnitDefID, TeamID, number, number, number) -> nilParameters
Callins:UnitDestroyed (function)
Called when a unit is destroyed.
[source]
Callins:UnitDestroyed(UnitID, UnitDefID, TeamID, UnitID?, UnitDefID?, TeamID?, WeaponDefID) -> nilParameters
UnitIDunitIDUnitDefIDunitDefIDTeamIDunitTeamUnitID?attackerID- Subject to visibility rules
UnitDefID?attackerDefID- Subject to visibility rules
TeamID?attackerTeam- Subject to visibility rules
WeaponDefIDweaponDefID
Callins:UnitTaken (function)
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]
Callins:UnitTaken(UnitID, UnitDefID, TeamID, TeamID) -> nilParameters
Callins:UnitGiven (function)
Called when a unit is transferred between teams. This is called after UnitTaken and in that moment unit is assigned to the newTeam.
[source]
Callins:UnitGiven(UnitID, UnitDefID, TeamID, TeamID) -> nilParameters
Callins:UnitIdle (function)
Called when a unit is idle (empty command queue).
[source]
Callins:UnitIdle(UnitID, UnitDefID, TeamID) -> nilParameters
Callins:UnitCommand (function)
Called after when a unit accepts a command, after AllowCommand returns true.
[source]
Callins:UnitCommand(UnitID, UnitDefID, TeamID, integer, table, CommandOptions, integer) -> nilParameters
UnitIDunitIDUnitDefIDunitDefIDTeamIDunitTeamintegercmdIDtablecmdParamsCommandOptionsoptionsintegercmdTag
Callins:UnitCmdDone (function)
Called when a unit completes a command.
[source]
Callins:UnitCmdDone(UnitID, UnitDefID, TeamID, integer, table, CommandOptions, integer) -> nilParameters
UnitIDunitIDUnitDefIDunitDefIDTeamIDunitTeamintegercmdIDtablecmdParamsCommandOptionsoptionsintegercmdTag
Callins:UnitDamaged (function)
Called when a unit is damaged (after UnitPreDamaged).
[source]
Callins:UnitDamaged(UnitID, UnitDefID, TeamID, number, number, WeaponDefID, ProjectileID, UnitID, UnitDefID, TeamID) -> nilParameters
UnitIDunitIDUnitDefIDunitDefIDTeamIDunitTeamnumberdamagenumberparalyzerWeaponDefIDweaponDefIDProjectileIDprojectileIDUnitIDattackerIDUnitDefIDattackerDefIDTeamIDattackerTeam
Callins:UnitStunned (function)
Called when a unit changes its stun status.
[source]
Callins:UnitStunned(UnitID, UnitDefID, TeamID, boolean) -> nilParameters
Callins:UnitExperience (function)
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]
Callins:UnitExperience(UnitID, UnitDefID, TeamID, number, number) -> nilParameters
Callins:UnitHarvestStorageFull (function)
Called when a unit’s harvestStorage is full (according to its unitDef’s entry).
[source]
Callins:UnitHarvestStorageFull(UnitID, UnitDefID, TeamID) -> nilParameters
Callins:UnitSeismicPing (function)
Called when a unit emits a seismic ping.
[source]
See seismicSignature.
Callins:UnitSeismicPing(number, number, number, number, AllyTeamID, UnitID, UnitDefID) -> nilParameters
Callins:UnitEnteredRadar (function)
Called when a unit enters radar of an allyteam.
Also called when a unit enters LOS without any radar coverage.
[source]
Callins:UnitEnteredRadar(UnitID, TeamID, AllyTeamID, UnitDefID) -> nilParameters
Callins:UnitEnteredLos (function)
Called when a unit enters LOS of an allyteam.
Its called after the unit is in LOS, so you can query that unit.
[source]
Callins:UnitEnteredLos(UnitID, TeamID, AllyTeamID, UnitDefID) -> nilParameters
Callins:UnitLeftRadar (function)
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]
Callins:UnitLeftRadar(UnitID, TeamID, AllyTeamID, UnitDefID) -> nilParameters
Callins:UnitLeftLos (function)
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]
Callins:UnitLeftLos(UnitID, TeamID, AllyTeamID, UnitDefID) -> nilParameters
Callins:UnitLoaded (function)
Called when a unit is loaded by a transport.
[source]
Callins:UnitLoaded(UnitID, UnitDefID, TeamID, UnitID, TeamID) -> nilParameters
Callins:UnitUnloaded (function)
Called when a unit is unloaded by a transport.
[source]
Callins:UnitUnloaded(UnitID, UnitDefID, TeamID, UnitID, TeamID) -> nilParameters
Callins:UnitEnteredUnderwater (function)
[source]Callins:UnitEnteredUnderwater(UnitID, UnitDefID, TeamID) -> nilParameters
Callins:UnitEnteredWater (function)
[source]Callins:UnitEnteredWater(UnitID, UnitDefID, TeamID) -> nilParameters
Callins:UnitLeftAir (function)
[source]Callins:UnitLeftAir(UnitID, UnitDefID, TeamID) -> nilParameters
Callins:UnitLeftUnderwater (function)
[source]Callins:UnitLeftUnderwater(UnitID, UnitDefID, TeamID) -> nilParameters
Callins:UnitLeftWater (function)
[source]Callins:UnitLeftWater(UnitID, UnitDefID, TeamID) -> nilParameters
Callins:UnitEnteredAir (function)
[source]Callins:UnitEnteredAir(UnitID, UnitDefID, TeamID) -> nilParameters
Callins:UnitCloaked (function)
Called when a unit cloaks.
[source]
Callins:UnitCloaked(UnitID, UnitDefID, TeamID) -> nilParameters
Callins:UnitDecloaked (function)
Called when a unit decloaks.
[source]
Callins:UnitDecloaked(UnitID, UnitDefID, TeamID) -> nilParameters
Callins:UnitUnitCollision (function)
Called when two units collide.
Both units must be registered with Script.SetWatchUnit.
[source]
Callins:UnitUnitCollision(UnitID, UnitID) -> nilParameters
Callins:UnitFeatureCollision (function)
Called when a unit collides with a feature.
[source]
The unit must be registered with Script.SetWatchUnit and the feature registered with Script.SetWatchFeature.
Callins:UnitFeatureCollision(UnitID, UnitID) -> nilParameters
Callins:UnitMoveFailed (function)
[source]Callins:UnitMoveFailed(UnitID, UnitDefID, TeamID) -> nilParameters
Callins:UnitArrivedAtGoal (function)
[source]Callins:UnitArrivedAtGoal(UnitID, UnitDefID, TeamID) -> nilParameters
Callins:RenderUnitDestroyed (function)
Called just before a unit is invalid, after it finishes its death animation.
[source]
Callins:RenderUnitDestroyed(UnitID, UnitDefID, TeamID) -> nilParameters
Callins:FeatureCreated (function)
Called when a feature is created.
[source]
Callins:FeatureCreated(FeatureID, AllyTeamID) -> nilParameters
Callins:FeatureDestroyed (function)
Called when a feature is destroyed.
[source]
Callins:FeatureDestroyed(FeatureID, AllyTeamID) -> nilParameters
Callins:FeatureDamaged (function)
Called when a feature is damaged.
[source]
Callins:FeatureDamaged(FeatureID, FeatureDefID, TeamID, number, WeaponDefID, ProjectileID, UnitID, UnitDefID, TeamID) -> nilParameters
FeatureIDfeatureIDFeatureDefIDfeatureDefIDTeamIDfeatureTeamnumberdamageWeaponDefIDweaponDefIDProjectileIDprojectileIDUnitIDattackerIDUnitDefIDattackerDefIDTeamIDattackerTeam
Callins:ProjectileCreated (function)
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.
Callins:ProjectileCreated(ProjectileID, UnitID, WeaponDefID) -> nilParameters
Callins:ProjectileDestroyed (function)
Called when the projectile is destroyed.
[source]
Callins:ProjectileDestroyed(ProjectileID, UnitID, WeaponDefID) -> nilParameters
Callins:Explosion (function)
Called when an explosion occurs.
[source]
Only called for weaponDefIDs registered via Script.SetWatchExplosion or Script.SetWatchWeapon.
Callins:Explosion(WeaponDefID, number, number, number, UnitID, ProjectileID) -> booleanParameters
WeaponDefIDweaponDefIDnumberpxnumberpynumberpzUnitIDattackerIDProjectileIDprojectileID
Returns
booleannoGfx- if then no graphical effects are drawn by the engine for this explosion.
Callins:StockpileChanged (function)
Called when a units stockpile of weapons increases or decreases.
[source]
Callins:StockpileChanged(UnitID, UnitDefID, TeamID, integer, integer, integer) -> nilParameters
Callins:RecvLuaMsg (function)
Receives messages from unsynced sent via Spring.SendLuaRulesMsg or Spring.SendLuaUIMsg.
[source]
Callins:RecvLuaMsg(string, PlayerID) -> nilParameters
Callins:Save (function)
Called when a chat command ‘/save’ or ‘/savegame’ is received.
[source]
Callins:Save(table) -> nilParameters
tablezip- a userdatum representing the savegame zip file. See Lua_SaveLoad.
Callins:UnsyncedHeightMapUpdate (function)
Called when the unsynced copy of the height-map is altered.
[source]
Callins:UnsyncedHeightMapUpdate() -> integer, integer, integer, integerReturns
Callins:Update (function)
Called for every draw frame (including when the game is paused) and at least once per sim frame except when catching up.
[source]
Callins:Update(number) -> nilParameters
numberdt- the time since the last update.
Callins:ViewResize (function)
Called whenever the window is resized.
[source]
Callins:ViewResize(integer, integer) -> nilParameters
Callins:FontsChanged (function)
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]
Callins:FontsChanged() -> nilCallins:SunChanged (function)
[source]Callins:SunChanged() -> nilCallins:DefaultCommand (function)
Used to set the default command when a unit is selected.
[source]
Callins:DefaultCommand(("unit"|"feature"), ObjectID, integer) -> integerParameters
("unit"|"feature")type- The type of the object pointed at.
ObjectIDid- The
unitIDorfeatureID. integercmd- The current command ID.
Returns
integercmdID- The command ID to use as the default, or nil to keep the current ID.
Callins:DrawGenesis (function)
Use this callin to update textures, shaders, etc.
[source]
Doesn’t render to screen! Also available to LuaMenu.
Callins:DrawGenesis() -> nilCallins:DrawWorld (function)
Spring draws command queues, ‘map stuff’, and map marks.
[source]
Callins:DrawWorld() -> nilCallins:DrawWorldPreUnit (function)
Spring draws units, features, some water types, cloaked units, and the sun.
[source]
Callins:DrawWorldPreUnit() -> nilCallins:DrawPreDecals (function)
Called before decals are drawn
[source]
Callins:DrawPreDecals() -> nilCallins:DrawWaterPost (function)
[source]Callins:DrawWaterPost() -> nilCallins:DrawShadowPassTransparent (function)
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.
Callins:DrawShadowPassTransparent() -> nilCallins:DrawWorldShadow (function)
[source]Callins:DrawWorldShadow() -> nilCallins:DrawWorldReflection (function)
[source]Callins:DrawWorldReflection() -> nilCallins:DrawWorldRefraction (function)
[source]Callins:DrawWorldRefraction() -> nilCallins:DrawGroundPreForward (function)
Runs at the start of the forward pass when a custom map shader has been assigned via Spring.SetMapShader (convenient for setting uniforms).
[source]
Callins:DrawGroundPreForward() -> nilCallins:DrawGroundPostForward (function)
[source]Callins:DrawGroundPostForward() -> nilCallins:DrawGroundPreDeferred (function)
Runs at the start of the deferred pass when a custom map shader has been assigned via Spring.SetMapShader (convenient for setting uniforms).
[source]
Callins:DrawGroundPreDeferred() -> nilCallins:DrawGroundDeferred (function)
[source]Callins:DrawGroundDeferred() -> nilCallins:DrawGroundPostDeferred (function)
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.
Callins:DrawGroundPostDeferred() -> nilCallins:DrawUnitsPostDeferred (function)
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.
Callins:DrawUnitsPostDeferred() -> nilCallins:DrawFeaturesPostDeferred (function)
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]
Callins:DrawFeaturesPostDeferred() -> nilCallins:DrawShadowUnitsLua (function)
[source]Callins:DrawShadowUnitsLua() -> nilCallins:DrawShadowFeaturesLua (function)
[source]Callins:DrawShadowFeaturesLua() -> nilCallins:DrawBuildSquare (function)
[source]
Called when build square data is computed, before engine rendering. Grid dimensions can be inferred from UnitDefs[unitDefID].xsize and UnitDefs[unitDefID].zsize. Grid origin in square coords: x - xsize/2, z - zsize/2 (accounting for facing).
Callins:DrawBuildSquare(UnitDefID, integer, integer, number, table) -> nilParameters
UnitDefIDunitDefIDintegerx- build position x
integerz- build position z
numberfacing- build facing
tablestatuses- flat 1D row-major array of BuildSquareStatus values: BLOCKED=0, OCCUPIED=1, RECLAIMABLE=2, OPEN=3
Callins:DrawWorldPreParticles (function)
DrawWorldPreParticles is called multiples times per draw frame. Each call has a different permutation of values for drawAboveWater, drawBelowWater, drawReflection, and drawRefraction.
[source]
Callins:DrawWorldPreParticles(boolean, boolean, boolean, boolean) -> nilParameters
booleandrawAboveWaterbooleandrawBelowWaterbooleandrawReflectionbooleandrawRefraction
Callins:DrawScreen (function)
Also available to LuaMenu.
[source]
Callins:DrawScreen(integer, integer) -> nilParameters
Callins:DrawScreenEffects (function)
[source]Callins:DrawScreenEffects(integer, integer) -> nilParameters
Callins:DrawScreenPost (function)
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.
Callins:DrawScreenPost(integer, integer) -> nilParameters
Callins:DrawInMiniMap (function)
[source]Callins:DrawInMiniMap(integer, integer) -> nilParameters
integersx- relative to the minimap’s position and scale.
integersy- relative to the minimap’s position and scale.
Callins:DrawInMiniMapBackground (function)
[source]Callins:DrawInMiniMapBackground(integer, integer) -> nilParameters
integersx- relative to the minimap’s position and scale.
integersy- relative to the minimap’s position and scale.
Callins:GameProgress (function)
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]
Callins:GameProgress(integer) -> nilParameters
integerserverFrameNum
Callins:KeyMapChanged (function)
Called when the keymap changes
[source]
Can be caused due to a change in language or keyboard
Callins:KeyMapChanged() -> nilCallins:KeyPress (function)
Called repeatedly when a key is pressed down.
[source]
Return true if you don’t want other callins or the engine to also receive this keypress. A list of key codes can be seen at the SDL wiki.
Callins:KeyPress(integer, KeyModifiers, boolean, string, integer, integer, table?) -> booleanParameters
integerkeyCodeKeyModifiersmodsbooleanisRepeat- If you want an action to occur only once check for isRepeat == false.
stringlabel- the name of the key
integerutf32char- (deprecated) always 0
integerscanCodetable?actionList- the list of actions for this keypress, when available
Returns
booleanhalt- whether to halt the chain for consumers of the keypress
Callins:KeyRelease (function)
Called when the key is released.
[source]
Callins:KeyRelease(integer, KeyModifiers, string, integer, integer, table?) -> booleanParameters
integerkeyCodeKeyModifiersmodsstringlabel- the name of the key
integerutf32char- (deprecated) always 0
integerscanCodetable?actionList- the list of actions for this keyrelease, when available
Returns
Callins:TextInput (function)
Called whenever a key press results in text input.
[source]
Callins:TextInput(string) -> nilParameters
stringutf8char
Callins:TextEditing (function)
[source]Callins:TextEditing(string, integer, integer) -> nilParameters
Callins:MousePress (function)
Called when a mouse button is pressed.
The button parameter supports up to 7 buttons. Must return true for MouseRelease and other functions to be called.
[source]
Callins:MousePress(integer, integer, integer) -> booleanParameters
Returns
booleanbecomeMouseOwner
Callins:MouseRelease (function)
Called when a mouse button is released.
[source]
Please note that in order to have Spring call Spring.MouseRelease, you need to have a Spring.MousePress call-in in the same addon that returns true.
Callins:MouseRelease(integer, integer, integer) -> booleanParameters
Returns
booleanbecomeMouseOwner
Callins:MouseMove (function)
Called when the mouse is moved.
[source]
Callins:MouseMove(integer, integer, integer, integer, integer) -> nilParameters
integerx- final x position
integery- final y position
integerdx- distance travelled in x
integerdy- distance travelled in y
integerbutton
Callins:MouseWheel (function)
Called when the mouse wheel is moved.
[source]
Callins:MouseWheel(boolean, number) -> nilParameters
Callins:IsAbove (function)
Called every Update.
[source]
Must return true for Mouse* events and Spring.GetToolTip to be called.
Callins:IsAbove(integer, integer) -> booleanParameters
Returns
booleanisAbove
Callins:GetTooltip (function)
Called when Spring.IsAbove returns true.
[source]
Callins:GetTooltip(integer, integer) -> stringParameters
Returns
stringtooltip
Callins:ActiveCommandChanged (function)
Called when a command is issued.
[source]
Callins:ActiveCommandChanged(integer?, integer?) -> nilParameters
Callins:CameraRotationChanged (function)
Called whenever the camera rotation changes
[source]
Callins:CameraRotationChanged(number, number, number) -> nilParameters
numberrotX- Camera rotation around the x axis in radians.
numberrotY- Camera rotation around the y axis in radians.
numberrotZ- Camera rotation around the z axis in radians.
Callins:CameraPositionChanged (function)
Called whenever the camera position changes
[source]
Callins:CameraPositionChanged(number, number, number) -> nilParameters
numberposX- Camera position x in world coordinates
numberposY- Camera position y in world coordinates
numberposZ- Camera position z in world coordinates
Callins:MiniMapRotationChanged (function)
Called when the MiniMap rotation changes
[source]
Callins:MiniMapRotationChanged(number, number) -> nilParameters
Callins:MiniMapStateChanged (function)
Called when the MiniMap minimizes or maximizes changes
[source]
Callins:MiniMapStateChanged(boolean, boolean, boolean) -> nilParameters
booleanisMinimizedbooleanisMaximizedbooleanisSlaved
Callins:MiniMapGeometryChanged (function)
Called when the MiniMap Geometry changes
[source]
Callins:MiniMapGeometryChanged(integer, integer, integer, integer, integer, integer, integer, integer) -> nilParameters
integernewPosX- in pixels
integernewPosY- in pixels
integernewDimX- in pixels
integernewDimY- in pixels
integeroldPosX- in pixels
integeroldPosY- in pixels
integeroldDimX- in pixels
integeroldDimY- in pixels
Callins:CommandNotify (function)
Called when a command is issued.
[source]
Callins:CommandNotify(integer, table, CommandOptions) -> booleanParameters
integercmdIDtablecmdParamsCommandOptionsoptions
Returns
booleandelete- Returning true deletes the command and does not send it through the network.
Callins:AddConsoleLine (function)
Called when text is entered into the console (e.g. Spring.Echo).
[source]
Callins:AddConsoleLine(string, integer) -> nilParameters
Callins:GroupChanged (function)
Called when a unit is added to or removed from a control group.
[source]
Callins:GroupChanged(GroupID) -> nilParameters
Callins:WorldTooltip (function)
[source]Callins:WorldTooltip("unit", UnitID) -> stringParameters
Returns
stringtooltip
Callins:WorldTooltip (function overload 1)
[source]Callins:WorldTooltip("feature", FeatureID) -> stringParameters
Returns
stringtooltip
Callins:WorldTooltip (function overload 2)
[source]Callins:WorldTooltip("ground", number, number, number) -> stringParameters
Returns
stringtooltip
Callins:WorldTooltip (function overload 3)
[source]Callins:WorldTooltip("selection") -> stringParameters
"selection"type
Returns
stringtooltip
Callins:MapDrawCmd (function)
[source]Callins:MapDrawCmd(PlayerID, "point", number, number, number, string) -> nilParameters
Callins:MapDrawCmd (function overload 1)
[source]Callins:MapDrawCmd(PlayerID, "line", number, number, number, number, number, number) -> nilParameters
Callins:MapDrawCmd (function overload 2)
[source]Callins:MapDrawCmd(PlayerID, "erase", number, number, number, number) -> nilParameters
Callins:GameSetup (function)
Fired when the pregame stage is reached
Pregame is the stage where player readiness is managed before a game starts. Game only starts once all players are ready.
[source]
Callins:GameSetup(READY_MESSAGE, boolean, table<PlayerID,READY_STATE>) -> boolean?, boolean?Parameters
READY_MESSAGEstate- the current message the engine would display to the player
booleanready- whether the player is currently ready or not
table<PlayerID,READY_STATE>playerStates- indexed by playerID
Returns
boolean?gameHandled- disables the engine ui when true
boolean?newReady- whether the player is ready (ignored unless
gameHandled = true)
Callins:RecvSkirmishAIMessage (function)
[source]Callins:RecvSkirmishAIMessage(TeamID, string) -> nilParameters
Callins:DownloadQueued (function)
Called when a Pr-downloader download is queued
[source]
Callins:DownloadQueued(integer, string, string) -> nilParameters
Callins:DownloadStarted (function)
Called when a Pr-downloader download is started via VFS.DownloadArchive.
[source]
Callins:DownloadStarted(integer) -> nilParameters
integerid
Callins:DownloadFinished (function)
Called when a Pr-downloader download finishes successfully.
[source]
Callins:DownloadFinished(integer) -> nilParameters
integerid
Callins:DownloadFailed (function)
Called when a Pr-downloader download fails to complete.
[source]
Callins:DownloadFailed(integer, integer) -> nilParameters
Callins:DownloadProgress (function)
Called incrementally during a Pr-downloader download.
[source]
Callins:DownloadProgress(integer, integer, integer) -> nilParameters
integeridintegerdownloadedintegertotal
SyncedCallins (class)
[source]
Functions called by the Engine (Synced).
Members
SyncedCallins:CommandFallback (function)
Called when the unit reaches an unknown command in its queue (i.e. one not handled by the engine).
[source]
SyncedCallins:CommandFallback(UnitID, UnitDefID, TeamID, integer, number[], CommandOptions, integer) -> booleanParameters
UnitIDunitIDUnitDefIDunitDefIDTeamIDunitTeamintegercmdIDnumber[]cmdParamsCommandOptionscmdOptionsintegercmdTag
Returns
booleanremoveCmd- whether to remove the command from the queue
SyncedCallins:AllowCommand (function)
Called when the command is given, before the unit’s queue is altered.
[source]
The queue remains untouched when a command is blocked, whether it would be queued or replace the queue.
SyncedCallins:AllowCommand(UnitID, UnitDefID, TeamID, integer, number[], CommandOptions, integer, boolean, boolean) -> booleanParameters
UnitIDunitIDUnitDefIDunitDefIDTeamIDunitTeamintegercmdIDnumber[]cmdParamsCommandOptionscmdOptionsintegercmdTagbooleansyncedbooleanfromLua
Returns
booleanallowCmd- whether it should be let into the queue.
SyncedCallins:AllowUnitCreation (function)
Called just before unit is created.
[source]
SyncedCallins:AllowUnitCreation(UnitDefID, UnitID, TeamID, number, number, number, FacingInteger) -> boolean, booleanParameters
Returns
SyncedCallins:AllowUnitTransfer (function)
Called just before a unit is transferred to a different team.
[source]
SyncedCallins:AllowUnitTransfer(UnitID, UnitDefID, TeamID, TeamID, boolean) -> booleanParameters
Returns
booleanallow- whether or not the transfer is permitted.
SyncedCallins:AllowUnitBuildStep (function)
Called just before a unit progresses its build percentage.
[source]
SyncedCallins:AllowUnitBuildStep(UnitID, TeamID, UnitID, UnitDefID, number) -> booleanParameters
Returns
booleanallow- whether or not the build makes progress.
SyncedCallins:AllowUnitCaptureStep (function)
[source]SyncedCallins:AllowUnitCaptureStep(UnitID, TeamID, UnitID, UnitDefID, number) -> booleanParameters
Returns
booleanallow- whether or not the capture makes progress.
SyncedCallins:AllowUnitTransport (function)
[source]SyncedCallins:AllowUnitTransport(UnitID, UnitDefID, TeamID, UnitID, UnitDefID, TeamID) -> booleanParameters
UnitIDtransporterIDUnitDefIDtransporterUnitDefIDTeamIDtransporterTeamUnitIDtransporteeIDUnitDefIDtransporteeUnitDefIDTeamIDtransporteeTeam
Returns
booleanallow- whether or not the transport is allowed
SyncedCallins:AllowUnitTransportLoad (function)
[source]SyncedCallins:AllowUnitTransportLoad(UnitID, UnitDefID, TeamID, UnitID, UnitDefID, TeamID, number, number, number) -> booleanParameters
UnitIDtransporterIDUnitDefIDtransporterUnitDefIDTeamIDtransporterTeamUnitIDtransporteeIDUnitDefIDtransporteeUnitDefIDTeamIDtransporteeTeamnumberxnumberynumberz
Returns
booleanallow- whether or not the transport load is allowed
SyncedCallins:AllowUnitTransportUnload (function)
[source]SyncedCallins:AllowUnitTransportUnload(UnitID, UnitDefID, TeamID, UnitID, UnitDefID, TeamID, number, number, number) -> booleanParameters
UnitIDtransporterIDUnitDefIDtransporterUnitDefIDTeamIDtransporterTeamUnitIDtransporteeIDUnitDefIDtransporteeUnitDefIDTeamIDtransporteeTeamnumberxnumberynumberz
Returns
booleanallow- whether or not the transport unload is allowed
SyncedCallins:AllowUnitCloak (function)
[source]SyncedCallins:AllowUnitCloak(UnitID, UnitID?) -> booleanParameters
Returns
booleanallow- whether unit is allowed to cloak
SyncedCallins:AllowUnitDecloak (function)
[source]SyncedCallins:AllowUnitDecloak(UnitID, ObjectID?, integer?) -> booleanParameters
Returns
booleanallow- whether unit is allowed to decloak
SyncedCallins:AllowUnitKamikaze (function)
[source]SyncedCallins:AllowUnitKamikaze(UnitID, UnitID) -> booleanParameters
Returns
booleanallow- whether unit is allowed to selfd
SyncedCallins:AllowFeatureCreation (function)
Called just before feature is created.
[source]
SyncedCallins:AllowFeatureCreation(FeatureDefID, TeamID, number, number, number) -> booleanParameters
FeatureDefIDfeatureDefIDTeamIDteamIDnumberxnumberynumberz
Returns
booleanallow- whether or not the creation is permitted
SyncedCallins:AllowFeatureBuildStep (function)
Called just before a feature changes its build percentage.
[source]
Note that this is also called for resurrecting features, and for refilling features with resources before resurrection. On reclaim the part values are negative, and on refill and resurrect they are positive. Part is the percentage the feature be built or reclaimed per frame. Eg. for a 30 workertime builder, that’s a build power of 1 per frame. For a 50 buildtime feature reclaimed by this builder, part will be 100/-50(/1) = -2%, or -0.02 numerically.
SyncedCallins:AllowFeatureBuildStep(UnitID, TeamID, FeatureID, FeatureDefID, number) -> booleanParameters
Returns
booleanallow- whether or not the change is permitted
SyncedCallins:AllowResourceLevel (function)
Called when a team sets the sharing level of a resource.
[source]
SyncedCallins:AllowResourceLevel(TeamID, string, number) -> booleanParameters
Returns
booleanallow- whether or not the sharing level is permitted
SyncedCallins:AllowResourceTransfer (function)
Called just before resources are transferred between players.
[source]
SyncedCallins:AllowResourceTransfer(TeamID, TeamID, string, number) -> booleanParameters
Returns
booleanallow- whether or not the transfer is permitted.
SyncedCallins:ResourceExcess (function)
Called when excess resources are added. Accumulates all excesses within a single gameframe.
[source]
SyncedCallins:ResourceExcess(table) -> booleanParameters
tableexcesses
Returns
booleanhandled- whether or not Lua handled the event
SyncedCallins:AllowDirectUnitControl (function)
Determines if this unit can be controlled directly in FPS view.
[source]
SyncedCallins:AllowDirectUnitControl(UnitID, UnitDefID, TeamID, PlayerID) -> booleanParameters
Returns
booleanallow
SyncedCallins:AllowBuilderHoldFire (function)
Called when a construction unit wants to “use his nano beams”.
[source]
SyncedCallins:AllowBuilderHoldFire(UnitID, UnitDefID, unknown) -> booleanParameters
Returns
booleanactionAllowed
SyncedCallins:AllowStartPosition (function)
Whether a start position should be allowed
[source]
clamped{X,Y,Z} are the coordinates clamped into start-boxes, raw is where player tried to place their marker.
The readyState can be any one of:
0 - player picked a position, 1 - player clicked ready, 2 - player pressed ready OR the game was force-started (player did not click ready, but is now forcibly readied) or 3 - the player failed to load. The default ‘failed to choose’ start-position is the north-west point of their startbox, or (0,0,0) if they do not have a startbox.
SyncedCallins:AllowStartPosition(PlayerID, TeamID, integer, number, number, number, number, number, number) -> booleanParameters
PlayerIDplayerIDTeamIDteamIDintegerreadyStatenumberclampedXnumberclampedYnumberclampedZnumberrawXnumberrawYnumberrawZ
Returns
booleanallow
SyncedCallins:MoveCtrlNotify (function)
Enable both Spring.MoveCtrl.SetCollideStop and Spring.MoveCtrl.SetTrackGround to enable this call-in.
[source]
SyncedCallins:MoveCtrlNotify(UnitID, UnitDefID, TeamID, integer) -> booleanParameters
UnitIDunitIDUnitDefIDunitDefIDTeamIDunitTeamintegerdata- was supposed to indicate the type of notification but currently never has a value other than 1 (“unit hit the ground”).
Returns
booleanengineControl- whether or not the unit should remain script-controlled (false) or return to engine controlled movement (true).
SyncedCallins:TerraformComplete (function)
Called when pre-building terrain levelling terraforms are completed (c.f. levelGround)
[source]
SyncedCallins:TerraformComplete(UnitID, UnitDefID, TeamID, UnitID, UnitDefID, TeamID) -> booleanParameters
UnitIDunitIDUnitDefIDunitDefIDTeamIDunitTeamUnitIDbuildUnitIDUnitDefIDbuildUnitDefIDTeamIDbuildUnitTeam
Returns
booleanstop- if true the current build order is terminated
SyncedCallins:UnitPreDamaged (function)
Called before damage is applied to the unit, allows fine control over how much damage and impulse is applied.
[source]
Called after every damage modification (even HitByWeaponId) but before the damage is applied
expects two numbers returned by lua code: 1st is stored under *newDamage if newDamage != NULL 2nd is stored under *impulseMult if impulseMult != NULL
SyncedCallins:UnitPreDamaged(UnitID, UnitDefID, TeamID, number, boolean, WeaponDefID?, ProjectileID?, UnitID?, UnitDefID?, TeamID?) -> number, numberParameters
UnitIDunitIDUnitDefIDunitDefIDTeamIDunitTeamnumberdamagebooleanparalyzerWeaponDefID?weaponDefID- Synced Only
ProjectileID?projectileID- Synced Only
UnitID?attackerID- Synced Only
UnitDefID?attackerDefID- Synced Only
TeamID?attackerTeam- Synced Only
Returns
numbernewDamagenumberimpulseMult
SyncedCallins:FeaturePreDamaged (function)
Called before damage is applied to the feature.
[source]
Allows fine control over how much damage and impulse is applied.
SyncedCallins:FeaturePreDamaged(FeatureID, FeatureDefID, TeamID, number, WeaponDefID, ProjectileID, UnitID, UnitDefID, TeamID) -> number, numberParameters
FeatureIDfeatureIDFeatureDefIDfeatureDefIDTeamIDfeatureTeamnumberdamageWeaponDefIDweaponDefIDProjectileIDprojectileIDUnitIDattackerIDUnitDefIDattackerDefIDTeamIDattackerTeam
Returns
numbernewDamagenumberimpulseMult
SyncedCallins:ShieldPreDamaged (function)
Called before any engine shield-vs-projectile logic executes.
[source]
SyncedCallins:ShieldPreDamaged(ProjectileID, UnitID, integer, UnitID, boolean, integer?, UnitID?, number, number, number, number, number, number) -> booleanParameters
ProjectileIDprojectileID-1when the weapon type isBeamLaserorLightningCannonUnitIDprojectileOwnerID-1when the weapon type isBeamLaserorLightningCannonintegershieldWeaponNumUnitIDshieldCarrierIDbooleanbounceProjectileinteger?beamEmitterWeaponNum- present only when the weapon type is
BeamLaserorLightningCannon UnitID?beamEmitterUnitID- present only when the weapon type is
BeamLaserorLightningCannon numberstartXnumberstartYnumberstartZnumberhitXnumberhitYnumberhitZ
Returns
booleanhandle- if true the gadget handles the collision event and the engine does not remove the projectile
SyncedCallins:AllowWeaponTargetCheck (function)
Determines if this weapon can automatically generate targets itself. See also commandFire weaponDef tag.
[source]
Only called for weaponDefIDs registered via Script.SetWatchAllowTarget or Script.SetWatchWeapon.
SyncedCallins:AllowWeaponTargetCheck(UnitID, integer, WeaponDefID) -> boolean, booleanParameters
Returns
booleanallowCheckbooleanignoreCheck
SyncedCallins:AllowWeaponTarget (function)
Controls blocking of a specific target from being considered during a weapon’s periodic auto-targeting sweep.
[source]
Only called for weaponDefIDs registered via Script.SetWatchAllowTarget or Script.SetWatchWeapon.
SyncedCallins:AllowWeaponTarget(UnitID, UnitID, integer, WeaponDefID, number) -> boolean, numberParameters
UnitIDattackerIDUnitIDtargetIDintegerattackerWeaponNumWeaponDefIDattackerWeaponDefIDnumberdefPriority
Returns
booleanallowednumbernewPriority- The new priority for this target (if you don’t want to change it, return defPriority). Lower priority targets are targeted first.
SyncedCallins:AllowWeaponInterceptTarget (function)
Controls blocking of a specific intercept target from being considered during an interceptor weapon’s periodic auto-targeting sweep.
[source]
Only called for weaponDefIDs registered via Script.SetWatchAllowTarget or Script.SetWatchWeapon.
SyncedCallins:AllowWeaponInterceptTarget(UnitID, integer, ProjectileID) -> booleanParameters
Returns
booleanallowed
SyncedCallins.SendToUnsynced (function)
Invoke UnsyncedCallins:RecvFromSynced callin with the given arguments.
[source]
See UnsyncedCallins:RecvFromSynced
SyncedCallins.SendToUnsynced([(boolean|number|string|table)?, ]*) -> nilParameters
(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.
UnsyncedCallins (class)
[source]
Functions called by the Engine (Unsynced).
Members
UnsyncedCallins:RecvFromSynced (function)
Receives data sent via SendToUnsynced callout.
[source]
UnsyncedCallins:RecvFromSynced([any, ]*) -> nilParameters
any...
UnsyncedCallins:DrawUnit (function)
For custom rendering of units
[source]
Deprecated
UnsyncedCallins:DrawUnit(UnitID, integer) -> booleanParameters
Returns
booleansuppressEngineDraw
UnsyncedCallins:DrawFeature (function)
For custom rendering of features
[source]
Deprecated
UnsyncedCallins:DrawFeature(FeatureID, integer) -> booleanParameters
Returns
booleansuppressEngineDraw
UnsyncedCallins:DrawShield (function)
For custom rendering of shields.
[source]
Deprecated
UnsyncedCallins:DrawShield(UnitID, integer, integer) -> booleanParameters
Returns
booleansuppressEngineDraw
UnsyncedCallins:DrawProjectile (function)
For custom rendering of weapon (& other) projectiles
[source]
Deprecated
UnsyncedCallins:DrawProjectile(ProjectileID, integer) -> booleanParameters
Returns
booleansuppressEngineDraw
UnsyncedCallins:DrawMaterial (function)
[source]Deprecated
UnsyncedCallins:DrawMaterial(integer, integer) -> booleanParameters
Returns
booleansuppressEngineDraw
gl (table)
Callouts for OpenGL API
Only setters and getters for OpenGL usage in Recoil, see GL for constants.
[source]
See GL
Members
gl.GetVAO (function)
Example:
local myVAO = gl.GetVAO()
if myVAO == nil then Spring.Echo(“Failed to get VAO”) end
[source]
gl.GetVAO() -> VAO?Returns
gl.LoadFont (function)
Load a font from a file.
[source]
gl.LoadFont(string, integer?, integer?, number?) -> LuaFontParameters
stringfontFileinteger?sizeinteger?outlineWidthnumber?outlineWeight
Returns
gl.DeleteFont (function)
Delete a font object.
[source]
gl.DeleteFont(LuaFont) -> nilParameters
gl.AddFallbackFont (function)
Adds a fallback font for the font rendering engine.
Fonts added first will have higher priority. When a glyph isn’t found when rendering a font, the fallback fonts will be searched first, otherwise os fonts will be used.
The application should listen for the unsynced ‘FontsChanged’ callin so modules can clear any already reserved display lists or other relevant caches.
Note the callin won’t be executed at the time of calling this method, but later, on the Update cycle (before other Update and Draw callins).
[source]
gl.AddFallbackFont(string) -> booleanParameters
stringfilePath- VFS path to the file, for example “fonts/myfont.ttf”. Uses VFS.RAW_FIRST access mode.
Returns
booleansuccess
gl.ClearFallbackFonts (function)
Clears all fallback fonts.
See the note at ‘AddFallbackFont’ about the ‘FontsChanged’ callin, it also applies when calling this method.
[source]
gl.ClearFallbackFonts() -> nilReturns
gl.GetShaderLog (function)
Returns the shader compilation error log. This is empty if the shader linking failed, in that case, check your in/out blocks and ensure they match.
[source]
gl.GetShaderLog() -> stringReturns
stringinfoLog
gl.CreateShader (function)
Create a shader.
[source]
gl.CreateShader(ShaderParams) -> integerParameters
Returns
integershaderID
gl.DeleteShader (function)
Deletes a shader identified by shaderID
[source]
gl.DeleteShader(integer) -> boolean?Parameters
integershaderID
Returns
boolean?deletednilifshaderIDisnil.
gl.UseShader (function)
Binds a shader program identified by shaderID. Pass 0 to disable the shader. Returns whether the shader was successfully bound.
[source]
gl.UseShader(integer) -> booleanParameters
integershaderID
Returns
booleanlinked
gl.ActiveShader (function)
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]
gl.ActiveShader(integer, function, [any, ]*) -> nilParameters
gl.GetActiveUniforms (function)
Query the active (actually used) uniforms of a shader and identify their names, types (float, int, uint) and sizes (float, vec4, …).
[source]
gl.GetActiveUniforms(integer) -> ActiveUniform[]Parameters
integershaderID
Returns
gl.GetUniformLocation (function)
Returns the locationID of a shaders uniform. Needed for changing uniform values with function gl.Uniform.
[source]
gl.GetUniformLocation(integer, string) -> GLParameters
Returns
gl.GetSubroutineIndex (function)
Returns the subroutine index for a shader program.
[source]
gl.GetSubroutineIndex(integer, integer, string) -> integer?Parameters
integershaderIDintegershaderTypestringname
Returns
integer?index
gl.SetUnitBufferUniforms (function)
Writes user-defined model uniforms for a unit.
[source]
gl.SetUnitBufferUniforms(UnitID, number[], integer?) -> integerParameters
Returns
integercount
gl.SetFeatureBufferUniforms (function)
Writes user-defined model uniforms for a feature.
[source]
gl.SetFeatureBufferUniforms(FeatureID, number[], integer?) -> integer