Module SyncedRead
Synced Read
See also:
Teams
- Spring.GetGaiaTeamID
- Spring.GetAllyTeamStartBox
- Spring.GetTeamStartPosition
- xyz
- Cartesian triple (XYZ)
- Spring.GetMapStartPositions
- Spring.GetAllyTeamList
- Spring.GetTeamList
- Spring.GetPlayerList
- Spring.GetTeamInfo
- Spring.GetTeamAllyTeamID
- Spring.GetTeamResources
- Spring.GetTeamUnitStats
- Spring.GetTeamResourceStats
- Spring.GetTeamDamageStats
- Gets team damage dealt/received totals
- teamStats
- Spring.GetTeamStatsHistory
- Spring.GetTeamLuaAI
- Spring.GetTeamMaxUnits
- Returns a team's unit cap.
- Spring.GetPlayerInfo
- Spring.GetPlayerControlledUnit
- Returns unit controlled by player on FPS mode
- Spring.GetAIInfo
- Spring.GetAllyTeamInfo
- Spring.AreTeamsAllied
- Spring.ArePlayersAllied
Misc
- Spring.GetUnitEstimatedPath
- Spring.GetUnitLastAttacker
- Spring.GetUnitLastAttackedPiece
- Spring.GetUnitCollisionVolumeData
- Spring.GetUnitSeparation
- Spring.GetUnitFeatureSeparation
- Spring.GetUnitDefDimensions
- Spring.GetCEGID
- Spring.GetUnitBlocking
- Spring.GetUnitMoveTypeData
- Spring.GetUnitCurrentCommand
- cmdOpts
- Parameters for command options
- cmd
- Command
- Spring.GetUnitCommands
- Get the number or list of commands for a unit
- Spring.GetFactoryCommands
- Get the number or list of commands for a factory
- Spring.GetFactoryBuggerOff
- Spring.GetFactoryCounts
- Gets the build queue of a factory
- Spring.GetCommandQueue
- Get the number or list of commands for a unit
- Spring.GetFullBuildQueue
- Returns the build queue
- Spring.GetRealBuildQueue
- Returns the build queue cleaned of things the unit can't build itself
- Spring.GetUnitCmdDescs
- Spring.FindUnitCmdDesc
- Spring.ValidFeatureID
- Spring.GetAllFeatures
- Spring.GetFeatureDefID
- Spring.GetFeatureTeam
- Spring.GetFeatureAllyTeam
- Spring.GetFeatureHealth
- Spring.GetFeatureHeight
- Spring.GetFeatureRadius
- Spring.GetFeatureMass
- Spring.GetFeaturePosition
- Spring.GetFeatureSeparation
- Spring.GetFeatureRotation
- Spring.GetFeatureDirection
- Spring.GetFeatureVelocity
- Spring.GetFeatureHeading
- Spring.GetFeatureResources
- Spring.GetFeatureBlocking
- Spring.GetFeatureNoSelect
- Spring.GetFeatureResurrect
- Spring.GetFeatureLastAttackedPiece
- Spring.GetFeatureCollisionVolumeData
- Spring.GetFeaturePieceCollisionVolumeData
- Spring.GetRadarErrorParams
Game States
- Spring.IsCheatingEnabled
- Spring.IsGodModeEnabled
- Spring.IsDevLuaEnabled
- Spring.IsEditDefsEnabled
- Spring.IsNoCostEnabled
- Spring.GetGlobalLos
- Spring.AreHelperAIsEnabled
- Spring.FixedAllies
- Spring.IsGameOver
Speed/Time
Environment
Rules/Params
- Spring.GetGameRulesParams
- Spring.GetTeamRulesParams
- Spring.GetPlayerRulesParams
- Spring.GetUnitRulesParams
- Spring.GetFeatureRulesParams
- Spring.GetGameRulesParam
- Spring.GetTeamRulesParam
- Spring.GetPlayerRulesParam
- Spring.GetUnitRulesParam
- Spring.GetFeatureRulesParam
Mod and Map options
Vectors
- Spring.GetHeadingFromVector
- Spring.GetVectorFromHeading
- Spring.GetFacingFromHeading
- Spring.GetHeadingFromFacing
Sides and Factions
Unit queries
- Spring.GetAllUnits
- Get a list of all unitIDs
- Spring.GetTeamUnits
- Spring.GetTeamUnitsSorted
- Spring.GetTeamUnitsCounts
- Spring.GetTeamUnitsByDefs
- Spring.GetTeamUnitDefCount
- Spring.GetTeamUnitCount
Spatial unit queries
- Spring.GetUnitsInRectangle
- Spring.GetUnitsInBox
- Spring.GetUnitsInCylinder
- Spring.GetUnitsInSphere
- planeSpec
- Spring.GetUnitsInPlanes
- Spring.GetUnitArrayCentroid
- Returns the centroid of an array of units
- Spring.GetUnitMapCentroid
- Returns the centroid of a map of units
- Spring.GetUnitNearestAlly
- Spring.GetUnitNearestEnemy
Spatial feature queries
- Spring.GetFeaturesInRectangle
- Spring.GetFeaturesInSphere
- Spring.GetFeaturesInCylinder
- Spring.GetProjectilesInRectangle
Unit state
- Spring.ValidUnitID
- unitState
- Spring.GetUnitStates
- Spring.GetUnitArmored
- Spring.GetUnitIsActive
- Spring.GetUnitIsCloaked
- Spring.GetUnitSeismicSignature
- Spring.GetUnitSelfDTime
- Spring.GetUnitStockpile
- Spring.GetUnitSensorRadius
- Spring.GetUnitPosErrorParams
- Spring.GetUnitTooltip
- Spring.GetUnitDefID
- Spring.GetUnitTeam
- Spring.GetUnitAllyTeam
- Spring.GetUnitNeutral
- Checks if a unit is neutral (NOT Gaia!)
- Spring.GetUnitHealth
- Spring.GetUnitIsDead
- Spring.GetUnitIsStunned
- 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.
- Spring.GetUnitIsBeingBuilt
- Spring.GetUnitResources
- Spring.GetUnitCosts
- Spring.GetUnitCostTable
- Spring.GetUnitMetalExtraction
- Spring.GetUnitExperience
- Spring.GetUnitHeight
- Spring.GetUnitRadius
- Spring.GetUnitBuildeeRadius
- Spring.GetUnitMass
- Spring.GetUnitPosition
- Spring.GetUnitBasePosition
- Spring.GetUnitVectors
- Spring.GetUnitRotation
- Spring.GetUnitDirection
- Spring.GetUnitHeading
- Spring.GetUnitVelocity
- Spring.GetUnitBuildFacing
- Spring.GetUnitIsBuilding
- Checks whether a unit is currently building another (NOT for checking if it's a structure)
- Spring.GetUnitWorkerTask
- Checks a builder's current task
- Spring.GetUnitEffectiveBuildRange
- Spring.GetUnitCurrentBuildPower
- Spring.GetUnitHarvestStorage
- Get a unit's carried resources
- Spring.GetUnitBuildParams
- Spring.GetUnitInBuildStance
- Is builder in build stance
- Spring.GetUnitNanoPieces
- Get construction FX attachment points
- Spring.GetUnitTransporter
- Get the transport carrying the unit
- Spring.GetUnitIsTransporting
- Get units being transported
- Spring.GetUnitShieldState
- Spring.GetUnitFlanking
- Spring.GetUnitMaxRange
- Get a unit's engagement range
Unit weapon state
- Spring.GetUnitWeaponState
- Check the state of a unit's weapon
- Spring.GetUnitWeaponDamages
- Spring.GetUnitWeaponVectors
- Spring.GetUnitWeaponTryTarget
- Spring.GetUnitWeaponTestTarget
- Spring.GetUnitWeaponTestRange
- Spring.GetUnitWeaponHaveFreeLineOfFire
- Spring.GetUnitWeaponCanFire
- Spring.GetUnitWeaponTarget
- Checks a weapon's target
Projectile state
- Spring.GetProjectilePosition
- Spring.GetProjectileDirection
- Spring.GetProjectileVelocity
- Spring.GetProjectileGravity
- Spring.GetPieceProjectileParams
- Spring.GetProjectileTarget
- Spring.GetProjectileIsIntercepted
- Spring.GetProjectileTimeToLive
- Spring.GetProjectileOwnerID
- Spring.GetProjectileTeamID
- Spring.GetProjectileAllyTeamID
- Spring.GetProjectileType
- Spring.GetProjectileDefID
- Spring.GetProjectileDamages
Ground
- Spring.IsPosInMap
- Spring.GetGroundHeight
- Get ground height
- Spring.GetWaterPlaneLevel
- Get water plane height
Water may at some point become shaped (rivers etc) but for now it is always a flat plane.
- Spring.GetWaterLevel
- Get water level in a specific position
Water is currently a flat plane, so this returns the same value regardless of XZ.
- Spring.GetGroundOrigHeight
- Get ground height as it was at game start
- Spring.GetGroundNormal
- Spring.GetGroundInfo
- Spring.GetGroundBlocked
- Spring.GetGroundExtremes
- Spring.GetTerrainTypeData
- Spring.GetGrass
- Spring.GetSmoothMeshHeight
Tests
- Spring.TestMoveOrder
- Spring.TestBuildOrder
- Spring.Pos2BuildPos
- Snaps a position to the building grid
- Spring.ClosestBuildPos
Visibility
- Spring.GetPositionLosState
- Spring.IsPosInLos
- Spring.IsPosInRadar
- Spring.IsPosInAirLos
- Spring.GetUnitLosState
- Spring.IsUnitInLos
- Spring.IsUnitInAirLos
- Spring.IsUnitInRadar
- Spring.IsUnitInJammer
Piece/Script
- pieceSpec
- Piece spec
- Spring.GetModelRootPiece
- Spring.GetModelPieceMap
- Spring.GetModelPieceList
- Spring.GetUnitRootPiece
- Spring.GetUnitPieceMap
- Spring.GetUnitPieceList
- Spring.GetUnitPieceInfo
- Spring.GetUnitPiecePosDir
- Spring.GetUnitPiecePosition
- Spring.GetUnitPieceDirection
- Spring.GetUnitPieceMatrix
- Spring.GetFeatureRootPiece
- Spring.GetFeaturePieceMap
- Spring.GetFeaturePieceList
- Spring.GetFeaturePieceInfo
- Spring.GetFeaturePiecePosDir
- Spring.GetFeaturePiecePosition
- Spring.GetFeaturePieceDirection
- Spring.GetFeaturePieceMatrix
- Spring.GetUnitScriptPiece
- Spring.GetUnitScriptNames
Teams
Spring.GetGaiaTeamID()
Returns:
- number teamID
Spring.GetAllyTeamStartBox(allyID)
Parameters:
-
allyID
number
Returns:
- number xMin
- number zMin
- number xMax
- number zMax
Spring.GetTeamStartPosition(teamID)
Parameters:
-
teamID
number
Returns:
- number x
- number y
- number x
xyz
Cartesian triple (XYZ)
Fields:
-
x
number -
y
number -
z
number
Spring.GetMapStartPositions()
Returns:
- {xyz,...} array of positions indexed by teamID
Spring.GetAllyTeamList()
Returns:
- {number,...} list of allyTeamIDs
Spring.GetTeamList([allyTeamID=-1])
Parameters:
-
allyTeamID
number to filter teams belonging to when >= 0 (default -1)
Returns:
- nil or {number,...} list of teamIDs
Spring.GetPlayerList([teamID=-1[, active=false]])
Parameters:
-
teamID
number to filter by when >= 0 (default -1) -
active
bool whether to filter only active teams (default false)
Returns:
- nil or {number,...} list of playerIDs
Spring.GetTeamInfo(teamID[, getTeamKeys=true])
Parameters:
-
teamID
number -
getTeamKeys
bool whether to return the customTeamKeys table (default true)
Returns:
- nil or number teamID
- number leader
- number isDead
- number hasAI
- string side
- number allyTeam
- number incomeMultiplier
- {[string]=string,...} customTeamKeys when getTeamKeys is true, otherwise nil
Spring.GetTeamAllyTeamID(teamID)
Parameters:
-
teamID
number
Returns:
- nil or allyTeamID
Spring.GetTeamResources(teamID, resource)
Parameters:
-
teamID
number -
resource
string one of "m(etal)?|e(nergy)?"
Returns:
- nil or number currentLevel
- number storage
- number pull
- number income
- number expense
- number share
- number sent
- number received
Spring.GetTeamUnitStats(teamID)
Parameters:
-
teamID
number
Returns:
- nil or number killed
- number died
- number capturedBy
- number capturedFrom
- number received
- number sent
Spring.GetTeamResourceStats(teamID, resource)
Parameters:
-
teamID
number -
resource
string one of "m(etal)?|e(nergy)?"
Returns:
- nil or number used
- number produced
- number excessed
- number received
- number sent
Spring.GetTeamDamageStats(teamID)
Gets team damage dealt/received totals
Returns a team's damage stats. Note that all damage is counted, including self-inflicted and unconfirmed out-of-sight.
Parameters:
-
teamID
number
Returns:
- number damageDealt
- number damageReceived
teamStats
Fields:
-
time
number -
frame
number -
metalUsed
number -
metalProduced
number -
metalExcess
number -
metalReceived
number -
metalSent
number -
energyUsed
number -
energyProduced
number -
energyExcess
number -
energyReceived
number -
energySent
number -
damageDealt
number -
damageReceived
number -
unitsProduced
number -
unitsDied
number -
unitsReceived
number -
unitsSent
number -
unitsCaptured
number -
unitsOutCaptured
number
Spring.GetTeamStatsHistory(teamID[, startIndex[, endIndex=startIndex]])
Parameters:
-
teamID
number -
startIndex
number when not specified return the number of history entries (optional) -
endIndex
number (default startIndex)
Returns:
- nil, number or {teamStats,...}
Spring.GetTeamLuaAI(teamID)
Spring.GetTeamMaxUnits(teamID)
Returns a team's unit cap.
Also returns the current unit count for readable teams as the 2nd value.
Parameters:
-
teamID
number
Returns:
- number maxUnits
- nil or number currentUnits
Spring.GetPlayerInfo(playerID[, getPlayerOpts=true])
Parameters:
-
playerID
number -
getPlayerOpts
bool whether to return custom player options (default true)
Returns:
- nil or string name
- bool active
- bool spectator
- number teamID
- number allyTeamID
- number pingTime
- number cpuUsage
- string country
- number rank
- bool hasSkirmishAIsInTeam
- {[string]=string} playerOpts when playerOpts is true
- bool desynced
Spring.GetPlayerControlledUnit(playerID)
Returns unit controlled by player on FPS mode
Parameters:
-
playerID
number
Returns:
- nil or number
Spring.GetAIInfo(teamID)
Parameters:
-
teamID
number
Returns:
- number skirmishAIID
- string name
- number hostingPlayerID
- string shortName when synced "SYNCED_NOSHORTNAME", otherwise the AI shortname or "UNKNOWN"
- string version when synced "SYNCED_NOVERSION", otherwise the AI version or "UNKNOWN"
- {[string]=string,...} options
Spring.GetAllyTeamInfo(allyTeamID)
Spring.AreTeamsAllied(teamID1, teamID2)
Parameters:
-
teamID1
number -
teamID2
number
Returns:
- nil or bool
Spring.ArePlayersAllied(playerID1, playerID2)
Parameters:
-
playerID1
number -
playerID2
number
Returns:
- nil or bool
Misc
Spring.GetUnitEstimatedPath(unitID)
Parameters:
-
unitID
number
Spring.GetUnitLastAttacker(unitID)
Parameters:
-
unitID
number
Spring.GetUnitLastAttackedPiece(unitID)
Parameters:
-
unitID
number
Spring.GetUnitCollisionVolumeData(unitID)
Parameters:
-
unitID
number
Spring.GetUnitSeparation(unitID1, unitID2[, direction=false[, subtractRadii=false]])
Parameters:
-
unitID1
number -
unitID2
number -
direction
bool to subtract from, default unitID1 - unitID2 (default false) -
subtractRadii
bool whether units radii should be subtracted from the total (default false)
Returns:
- nil or number
Spring.GetUnitFeatureSeparation(unitID)
Parameters:
-
unitID
number
Spring.GetUnitDefDimensions(unitDefID)
Parameters:
-
unitDefID
number
Spring.GetCEGID()
Spring.GetUnitBlocking(unitID)
Parameters:
-
unitID
number
Returns:
- nil or bool isBlocking
- bool isSolidObjectCollidable
- bool isProjectileCollidable
- bool isRaySegmentCollidable
- bool crushable
- bool blockEnemyPushing
- bool blockHeightChanges
Spring.GetUnitMoveTypeData(unitID)
Parameters:
-
unitID
number
Spring.GetUnitCurrentCommand()
cmdOpts
Parameters for command options
Fields:
-
coded
number -
alt
bool -
ctrl
bool -
shift
bool -
right
bool -
meta
bool -
internal
bool
cmd
Command
Fields:
-
id
number -
params
{number,...} -
options
cmdOpts -
tag
number
Spring.GetUnitCommands(unitID, count)
Get the number or list of commands for a unit
Same as Spring.GetCommandQueue
Parameters:
-
unitID
number -
count
number when 0 returns the number of commands in the units queue, when -1 returns all commands, number of commands to return otherwise
Returns:
- number or {cmd,...} commands
Spring.GetFactoryCommands(unitID, count)
Get the number or list of commands for a factory
Parameters:
-
unitID
number -
count
number when 0 returns the number of commands in the units queue, when -1 returns all commands, number of commands to return otherwise
Returns:
- number or {cmd,...} commands
Spring.GetFactoryBuggerOff(unitID)
Parameters:
-
unitID
number
Spring.GetFactoryCounts(unitID[, count=-1[, addCmds=false]])
Gets the build queue of a factory
Parameters:
-
unitID
number -
count
number then number of commands to retrieve, when -1 all (default -1) -
addCmds
bool if commands other than buildunit are retrieved (default false)
Returns:
- nil or {{[number]=number,...}} counts indexed by unitDefID or -cmdID
Spring.GetCommandQueue(unitID, count)
Get the number or list of commands for a unit
Same as Spring.GetUnitCommands
Parameters:
-
unitID
number -
count
number when 0 returns the number of commands in the units queue, when -1 returns all commands, number of commands to return otherwise
Returns:
- number or {cmd,...} commands
Spring.GetFullBuildQueue(unitID)
Returns the build queue
Parameters:
-
unitID
number
Returns:
- nil or {[number]=number,...} buildqueue indexed by unitDefID with count values
Spring.GetRealBuildQueue(unitID)
Returns the build queue cleaned of things the unit can't build itself
Parameters:
-
unitID
number
Returns:
- nil or {[number]=number,...} buildqueue indexed by unitDefID with count values
Spring.GetUnitCmdDescs(unitID)
Parameters:
-
unitID
number
Spring.FindUnitCmdDesc(unitID)
Parameters:
-
unitID
number
Spring.ValidFeatureID(featureID)
Parameters:
-
featureID
number
Returns:
- bool
Spring.GetAllFeatures()
Spring.GetFeatureDefID(featureID)
Parameters:
-
featureID
number
Returns:
- nil or number
Spring.GetFeatureTeam(featureID)
Parameters:
-
featureID
number
Returns:
- nil or number
Spring.GetFeatureAllyTeam(featureID)
Parameters:
-
featureID
number
Returns:
- nil or number
Spring.GetFeatureHealth(featureID)
Parameters:
-
featureID
number
Returns:
- nil or number health
- number defHealth
- number resurrectProgress
Spring.GetFeatureHeight(featureID)
Parameters:
-
featureID
number
Returns:
- nil or number
Spring.GetFeatureRadius(featureID)
Parameters:
-
featureID
number
Returns:
- nil or number
Spring.GetFeatureMass(featureID)
Parameters:
-
featureID
number
Returns:
- nil or number
Spring.GetFeaturePosition(featureID)
Parameters:
-
featureID
number
Spring.GetFeatureSeparation(featureID1, featureID2[, direction=false])
Parameters:
-
featureID1
number -
featureID2
number -
direction
bool to subtract from, default featureID1 - featureID2 (default false)
Returns:
- nil or number
Spring.GetFeatureRotation(featureID)
Parameters:
-
featureID
number
Returns:
- nil or number pitch, rotation in X axis
- number yaw, rotation in Y axis
- number roll, rotation in Z axis
Spring.GetFeatureDirection(featureID)
Parameters:
-
featureID
number
Returns:
- nil or dirX
- dirY
- dirZ
Spring.GetFeatureVelocity(featureID)
Parameters:
-
featureID
number
Spring.GetFeatureHeading(featureID)
Parameters:
-
featureID
number
Spring.GetFeatureResources(featureID)
Parameters:
-
featureID
number
Returns:
- nil or number metal
- number defMetal
- number energy
- number defEnergy
- number reclaimLeft
- number reclaimTime
Spring.GetFeatureBlocking(featureID)
Parameters:
-
featureID
number
Returns:
- nil or bool isBlocking
- bool isSolidObjectCollidable
- bool isProjectileCollidable
- bool isRaySegmentCollidable
- bool crushable
- bool blockEnemyPushing
- bool blockHeightChanges
Spring.GetFeatureNoSelect(featureID)
Parameters:
-
featureID
number
Returns:
- nil or bool
Spring.GetFeatureResurrect(featureID)
Parameters:
-
featureID
number
Spring.GetFeatureLastAttackedPiece(featureID)
Parameters:
-
featureID
number
Spring.GetFeatureCollisionVolumeData(featureID)
Parameters:
-
featureID
number
Spring.GetFeaturePieceCollisionVolumeData(featureID)
Parameters:
-
featureID
number
Spring.GetRadarErrorParams(allyTeamID)
Parameters:
-
allyTeamID
number
Returns:
- nil or number radarErrorSize actual radar error size (when allyTeamID is allied to current team) or base radar error size
- number baseRadarErrorSize
- number baseRadarErrorMult
Game States
Spring.IsCheatingEnabled()
Returns:
- bool enabled
Spring.IsGodModeEnabled()
Returns:
- bool enabled
Spring.IsDevLuaEnabled()
Returns:
- bool enabled
Spring.IsEditDefsEnabled()
Returns:
- bool enabled
Spring.IsNoCostEnabled()
Returns:
- bool enabled
Spring.GetGlobalLos([teamID])
Parameters:
-
teamID
number (optional)
Returns:
- bool enabled
Spring.AreHelperAIsEnabled()
Returns:
- bool enabled
Spring.FixedAllies()
Returns:
- bool or nil enabled
Spring.IsGameOver()
Returns:
- bool isGameOver
Speed/Time
Spring.GetGameFrame()
Returns:
- number t1 frameNum % dayFrames
- number t2 frameNum / dayFrames
Spring.GetGameSeconds()
Returns:
- number seconds
Environment
Spring.GetTidal()
Returns:
- number tidalStrength
Spring.GetWind()
Returns:
- number windStrength
Rules/Params
The following functions allow to save data per game, team and unit. The advantage of it is that it can be read from anywhere (even from LuaUI and AIs!)
Spring.GetGameRulesParams()
Returns:
- {[string] = number,...} rulesParams map with rules names as key and values as values
Spring.GetTeamRulesParams(teamID)
Parameters:
-
teamID
number
Returns:
- {[string] = number,...} rulesParams map with rules names as key and values as values
Spring.GetPlayerRulesParams(playerID)
Parameters:
-
playerID
number
Returns:
- {[string] = number,...} rulesParams map with rules names as key and values as values
Spring.GetUnitRulesParams(unitID)
Parameters:
-
unitID
number
Returns:
- {[string] = number,...} rulesParams map with rules names as key and values as values
Spring.GetFeatureRulesParams(featureID)
Parameters:
-
featureID
number
Returns:
- {[string] = number,...} rulesParams map with rules names as key and values as values
Spring.GetGameRulesParam(ruleRef)
Spring.GetTeamRulesParam(teamID, ruleRef)
Parameters:
-
teamID
number -
ruleRef
number or string the rule index or name
Returns:
- nil, number or string value
Spring.GetPlayerRulesParam(playerID, ruleRef)
Parameters:
-
playerID
number -
ruleRef
number or string the rule index or name
Returns:
- nil, number or string value
Spring.GetUnitRulesParam(unitID, ruleRef)
Parameters:
-
unitID
number -
ruleRef
number or string the rule index or name
Returns:
- nil, number or string value
Spring.GetFeatureRulesParam(featureID, ruleRef)
Parameters:
-
featureID
number -
ruleRef
number or string the rule index or name
Returns:
- nil, number or string value
Mod and Map options
Warning: boolean values are not transfered from C to Lua correctly. For this reason the respective option has to be converted to a number and checked accordingly via an IF statement as shown below:
if (tonumber(Spring.GetModOptions.exampleOption) == 1) then...end
The following check therefore is insufficient!
if (Spring.GetModOptions.exampleOption) then...end
Spring.GetMapOption(mapOption)
Spring.GetMapOptions()
Returns:
- {[string] = string,...} options map with options names as keys and values as values
Spring.GetModOption(modOption)
Spring.GetModOptions()
Returns:
- {[string] = string,...} options map with options names as keys and values as values
Vectors
Spring.GetHeadingFromVector(x, z)
Parameters:
-
x
number -
z
number
Returns:
- number heading
Spring.GetVectorFromHeading(heading)
Parameters:
-
heading
number
Returns:
- number x
- number z
Spring.GetFacingFromHeading(heading)
Parameters:
-
heading
number
Returns:
- number facing
Spring.GetHeadingFromFacing(facing)
Parameters:
-
facing
number
Returns:
- number heading
Sides and Factions
sideSpec
Side spec
Used when returning arrays of side specifications, is itself an array with positional values as below:
Fields:
Spring.GetSideData(sideName)
Spring.GetSideData(sideID)
Parameters:
-
sideID
number
Returns:
Spring.GetSideData()
Returns:
- {[sideSpec],...} sideArray
Unit queries
Spring.GetAllUnits()
Get a list of all unitIDs
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.
Returns:
- {number,...} unitIDs
See also:
Spring.GetTeamUnits(teamID)
Parameters:
-
teamID
number
Returns:
- nil or {number,...} unitIDs
Spring.GetTeamUnitsSorted(teamID)
Parameters:
-
teamID
number
Returns:
- nil or {[number]={number,...}} where keys are unitDefIDs and values are unitIDs
Spring.GetTeamUnitsCounts(teamID)
Parameters:
-
teamID
number
Returns:
- nil or {[number]=number} where keys are unitDefIDs and values are counts
Spring.GetTeamUnitsByDefs(teamID, unitDefIDs)
Parameters:
-
teamID
number -
unitDefIDs
number or {number,...}
Returns:
- nil or {number,...} unitIDs
Spring.GetTeamUnitDefCount(teamID, unitDefID)
Parameters:
-
teamID
number -
unitDefID
number
Returns:
- nil or number count
Spring.GetTeamUnitCount(teamID)
Parameters:
-
teamID
number
Returns:
- nil or number count
Spatial unit queries
For the allegiance parameters: AllUnits = -1, MyUnits = -2, AllyUnits = -3, EnemyUnits = -4
Spring.GetUnitsInRectangle(xmin, zmin, xmax, zmax[, allegiance])
Parameters:
-
xmin
number -
zmin
number -
xmax
number -
zmax
number -
allegiance
number (optional)
Returns:
- {number,...} unitIDs
Spring.GetUnitsInBox(xmin, ymin, zmin, xmax, ymax, zmax[, allegiance])
Parameters:
-
xmin
number -
ymin
number -
zmin
number -
xmax
number -
ymax
number -
zmax
number -
allegiance
number (optional)
Returns:
- {number,...} unitIDs
Spring.GetUnitsInCylinder(x, z, radius)
Parameters:
-
x
number -
z
number -
radius
number
Returns:
- {number,...} unitIDs
Spring.GetUnitsInSphere(x, y, z, radius)
Parameters:
-
x
number -
y
number -
z
number -
radius
number
Returns:
- {number,...} unitIDs
planeSpec
Fields:
-
normalVecX
number -
normalVecY
number -
normalVecZ
number -
d
number
Spring.GetUnitsInPlanes(planes[, allegiance])
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
Parameters:
-
planes
{planeSpec,...} -
allegiance
number (optional)
Returns:
- nil or {number,...} unitIDs
Spring.GetUnitArrayCentroid(units)
Returns the centroid of an array of units
Returns nil for an empty array
Parameters:
-
units
table { unitID, unitID, ... }
Returns:
- number centerX
- number centerY
- number centerZ
Spring.GetUnitMapCentroid(units)
Returns the centroid of a map of units
Returns nil for an empty map
Parameters:
-
units
table { [unitID] = true, [unitID] = true, ... }
Returns:
- number centerX
- number centerY
- number centerZ
Spring.GetUnitNearestAlly(unitID[, range=1.0e9f])
Parameters:
-
unitID
number -
range
number (default 1.0e9f)
Returns:
- nil or number unitID
Spring.GetUnitNearestEnemy(unitID[, range=1.0e9f[, useLOS=true]])
Parameters:
-
unitID
number -
range
number (default 1.0e9f) -
useLOS
bool (default true)
Returns:
- nil or number unitID
Spatial feature queries
Spring.GetFeaturesInRectangle(xmin, zmin, xmax, zmax)
Parameters:
-
xmin
number -
zmin
number -
xmax
number -
zmax
number
Returns:
- {number,...} featureIDs
Spring.GetFeaturesInSphere(x, y, z, radius)
Parameters:
-
x
number -
y
number -
z
number -
radius
number
Returns:
- {number,...} featureIDs
Spring.GetFeaturesInCylinder(x, z, radius[, allegiance])
Parameters:
-
x
number -
z
number -
radius
number -
allegiance
number (optional)
Returns:
- {number,...} featureIDs
Spring.GetProjectilesInRectangle(xmin, zmin, xmax, zmax[, excludeWeaponProjectiles=false[, excludePieceProjectiles=false]])
Parameters:
-
xmin
number -
zmin
number -
xmax
number -
zmax
number -
excludeWeaponProjectiles
bool (default false) -
excludePieceProjectiles
bool (default false)
Returns:
- {number,...} projectileIDs
Unit state
Spring.ValidUnitID(unitID)
Parameters:
-
unitID
number
Returns:
- bool
unitState
Fields:
-
firestate
number -
movestate
number -
repeat
bool -
cloak
bool -
active
bool -
trajectory
bool -
autoland
bool optional -
autorepairlevel
number optional -
loopbackattack
bool optional
Spring.GetUnitStates(unitID)
Spring.GetUnitArmored(unitID)
Parameters:
-
unitID
number
Returns:
- nil or bool armored
- number armorMultiple
Spring.GetUnitIsActive(unitID)
Parameters:
-
unitID
number
Returns:
- nil or bool
Spring.GetUnitIsCloaked(unitID)
Parameters:
-
unitID
number
Returns:
- nil or bool
Spring.GetUnitSeismicSignature(unitID)
Parameters:
-
unitID
number
Returns:
- nil or number
Spring.GetUnitSelfDTime(unitID)
Parameters:
-
unitID
number
Returns:
- nil or number
Spring.GetUnitStockpile(unitID)
Parameters:
-
unitID
number
Returns:
- nil or number numStockpiled
- number numStockpileQued
- number buildPercent
Spring.GetUnitSensorRadius(unitID, type)
Parameters:
-
unitID
number -
type
string one of los, airLos, radar, sonar, seismic, radarJammer, sonarJammer
Returns:
- nil or number radius
Spring.GetUnitPosErrorParams(unitID[, allyTeamID])
Parameters:
-
unitID
number -
allyTeamID
number (optional)
Returns:
- nil or number posErrorVectorX
- number posErrorVectorY
- number posErrorVectorZ
- number posErrorDeltaX
- number posErrorDeltaY
- number posErrorDeltaZ
- number nextPosErrorUpdatebaseErrorMult
- bool posErrorBit
Spring.GetUnitTooltip(unitID)
Spring.GetUnitDefID(unitID)
Parameters:
-
unitID
number
Returns:
- nil or number
Spring.GetUnitTeam(unitID)
Parameters:
-
unitID
number
Returns:
- nil or number
Spring.GetUnitAllyTeam(unitID)
Parameters:
-
unitID
number
Returns:
- nil or number
Spring.GetUnitNeutral(unitID)
Checks if a unit is neutral (NOT Gaia!)
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.
Parameters:
-
unitID
number
Returns:
- nil or bool
Spring.GetUnitHealth(unitID)
Parameters:
-
unitID
number
Returns:
- nil or number health
- number maxHealth
- number paralyzeDamage
- number captureProgress
- number buildProgress between 0.0-1.0
Spring.GetUnitIsDead(unitID)
Parameters:
-
unitID
number
Returns:
- nil or bool
Spring.GetUnitIsStunned(unitID)
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.
Parameters:
-
unitID
number
Returns:
- nil or bool stunnedOrBuilt unit is disabled
- bool stunned unit is either stunned via EMP or being transported by a non-fireplatform
- bool beingBuilt unit is under construction
Spring.GetUnitIsBeingBuilt(unitID)
Parameters:
-
unitID
number
Returns:
- bool beingBuilt
- number buildProgress
Spring.GetUnitResources(unitID)
Parameters:
-
unitID
number
Returns:
- nil or number metalMake
- number metalUse
- number energyMake
- number energyUse
Spring.GetUnitCosts(unitID)
Parameters:
-
unitID
number
Returns:
- nil or number buildTime
- number metalCost
- number energyCost
Spring.GetUnitCostTable(unitID)
Parameters:
-
unitID
number
Returns:
- nil or { metal = number, energy = number }
- number buildTime
Spring.GetUnitMetalExtraction(unitID)
Parameters:
-
unitID
number
Returns:
- nil or number
Spring.GetUnitExperience(unitID)
Parameters:
-
unitID
number
Returns:
- number XP [0.0; +∞)
- number limXP [0.0; 1.0) as experience approaches infinity
Spring.GetUnitHeight(unitID)
Parameters:
-
unitID
number
Returns:
- nil or number
Spring.GetUnitRadius(unitID)
Parameters:
-
unitID
number
Returns:
- nil or number
Spring.GetUnitBuildeeRadius(unitID)
Gets the unit's radius for when targeted by build, repair, reclaim-type commands.
Parameters:
-
unitID
number
Returns:
- nil or number
Spring.GetUnitMass(unitID)
Parameters:
-
unitID
number
Returns:
- nil or number
Spring.GetUnitPosition(unitID[, midPos=false[, aimPos=false]])
Parameters:
-
unitID
number -
midPos
bool return midpoint as well (default false) -
aimPos
bool return aimpoint as well (default false)
Returns:
- nil or number basePointX
- number basePointY
- number basePointZ
- nil or number midPointX
- number midPointY
- number midPointZ
- nil or number aimPointX
- number aimPointY
- number aimPointZ
Spring.GetUnitBasePosition(unitID)
Parameters:
-
unitID
number
Returns:
- nil or number posX
- number posY
- number posZ
Spring.GetUnitVectors(unitID)
Spring.GetUnitRotation(unitID)
Parameters:
-
unitID
number
Returns:
- nil or number pitch, rotation in X axis
- number yaw, rotation in Y axis
- number roll, rotation in Z axis
Spring.GetUnitDirection(unitID)
Parameters:
-
unitID
number
Returns:
- nil or dirX
- dirY
- dirZ
Spring.GetUnitHeading(unitID[, convertToRadians=false])
Parameters:
-
unitID
number -
convertToRadians
bool (default false)
Returns:
- heading
Spring.GetUnitVelocity(unitID)
Parameters:
-
unitID
number
Spring.GetUnitBuildFacing(unitID)
Parameters:
-
unitID
number
Spring.GetUnitIsBuilding(unitID)
Checks whether a unit is currently building another (NOT for checking if it's a structure)
Works for both mobile builders and factories.
Parameters:
-
unitID
number
Returns:
- number buildeeUnitID or nil
Spring.GetUnitWorkerTask(unitID)
Checks a builder's current task
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).
Parameters:
-
unitID
number
Returns:
- number cmdID of the relevant command
- number targetID if applicable (all except RESTORE)
Spring.GetUnitEffectiveBuildRange(unitID, buildeeDefID)
Useful for setting move goals manually.
Parameters:
-
unitID
number -
buildeeDefID
number or nil
Returns:
- number effectiveBuildRange counted to the center of prospective buildee; buildRange if buildee nil
Spring.GetUnitCurrentBuildPower(unitID)
Parameters:
-
unitID
number
Spring.GetUnitHarvestStorage(unitID)
Get a unit's carried resources
Checks resources being carried internally by the unit.
Parameters:
-
unitID
number
Returns:
- number storedMetal
- number maxStoredMetal
- number storedEnergy
- number maxStoredEnergy
Spring.GetUnitBuildParams(unitID)
Parameters:
-
unitID
number
Spring.GetUnitInBuildStance(unitID)
Is builder in build stance
Checks if a builder is in build stance, i.e. can create nanoframes. Returns nil for non-builders.
Parameters:
-
unitID
number
Returns:
- bool inBuildStance
Spring.GetUnitNanoPieces(unitID)
Get construction FX attachment points
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.
Parameters:
-
unitID
number
Returns:
- pieceArray {pieceID, pieceID, ...}
Spring.GetUnitTransporter(unitID)
Get the transport carrying the unit
Returns the unit ID of the transport, if any. Returns nil if the unit is not being transported.
Parameters:
-
unitID
number
Returns:
- number or nil transportUnitID
Spring.GetUnitIsTransporting(unitID)
Get units being transported
Returns an array of unitIDs being transported by this unit. Returns nil (NOT an empty array) for units that are not transports.
Parameters:
-
unitID
number
Returns:
- transporteeArray {unitID, unitID, ...}
Spring.GetUnitShieldState(unitID[, weaponNum])
Parameters:
-
unitID
number -
weaponNum
number Optional if the unit has just one shield (optional)
Returns:
- number isEnabled Warning, number not bool. 0 or 1
- number currentPower
Spring.GetUnitFlanking(unitID)
Parameters:
-
unitID
number
Spring.GetUnitMaxRange(unitID)
Get a unit's engagement range
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.
Parameters:
-
unitID
number
Returns:
- number maxRange
Unit weapon state
Spring.GetUnitWeaponState(unitID, weaponNum, stateName)
Check the state of a unit's weapon
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), "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.
Parameters:
-
unitID
number -
weaponNum
number -
stateName
string
Returns:
- number stateValue
Spring.GetUnitWeaponDamages(unitID)
Parameters:
-
unitID
number
Spring.GetUnitWeaponVectors(unitID)
Parameters:
-
unitID
number
Spring.GetUnitWeaponTryTarget(unitID)
Parameters:
-
unitID
number
Spring.GetUnitWeaponTestTarget(unitID)
Parameters:
-
unitID
number
Spring.GetUnitWeaponTestRange(unitID)
Parameters:
-
unitID
number
Spring.GetUnitWeaponHaveFreeLineOfFire(unitID)
Parameters:
-
unitID
number
Spring.GetUnitWeaponCanFire(unitID)
Parameters:
-
unitID
number
Spring.GetUnitWeaponTarget(unitID, weaponNum)
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.
Parameters:
-
unitID
number -
weaponNum
number
Returns:
- number targetType (0: none, 1: unit, 2: position, 3: projectile)
- boolean isUserTarget
- target (depending on type, 0: nil, 1: unitID, 2: table {x, y, z}, 3: projectileID)
Projectile state
Spring.GetProjectilePosition(projectileID)
Parameters:
-
projectileID
number
Returns:
- nil or number posX
- number posY
- number posZ
Spring.GetProjectileDirection(projectileID)
Parameters:
-
projectileID
number
Returns:
- nil or number dirX
- number dirY
- number dirZ
Spring.GetProjectileVelocity(projectileID)
Parameters:
-
projectileID
number
Returns:
- nil or number velX
- number velY
- number velZ
- number velW
Spring.GetProjectileGravity(projectileID)
Parameters:
-
projectileID
number
Returns:
- nil or number
Spring.GetPieceProjectileParams(projectileID)
Parameters:
-
projectileID
number
Returns:
- nil or number explosionFlags encoded bitwise with SHATTER = 1, EXPLODE = 2, EXPLODEONHIT = 2, FALL = 4, SMOKE = 8, FIRE = 16, NONE = 32, NOCEGTRAIL = 64, NO_HEATCLOUD = 128
- number spinAngle
- number spinSpeed
- number spinVectorX
- number spinVectorY
- number spinVectorZ
Spring.GetProjectileTarget(projectileID)
Parameters:
-
projectileID
number
Returns:
- nil or number targetTypeInt where string.byte('g') := GROUND string.byte('u') := UNIT string.byte('f') := FEATURE string.byte('p') := PROJECTILE
- number or xyz target targetID or targetPos when targetTypeInt == string.byte('g')
Spring.GetProjectileIsIntercepted(projectileID)
Parameters:
-
projectileID
number
Returns:
- nil or bool
Spring.GetProjectileTimeToLive(projectileID)
Parameters:
-
projectileID
number
Returns:
- nil or number
Spring.GetProjectileOwnerID(projectileID)
Parameters:
-
projectileID
number
Returns:
- nil or number
Spring.GetProjectileTeamID(projectileID)
Parameters:
-
projectileID
number
Returns:
- nil or number
Spring.GetProjectileAllyTeamID(projectileID)
Parameters:
-
projectileID
number
Returns:
- nil or number
Spring.GetProjectileType(projectileID)
Parameters:
-
projectileID
number
Returns:
- nil or bool weapon
- bool piece
Spring.GetProjectileDefID(projectileID)
Using this to get a weaponDefID is HIGHLY preferred to indexing WeaponDefNames via GetProjectileName
Parameters:
-
projectileID
number
Returns:
- nil or number
Spring.GetProjectileDamages(projectileID, tag)
Parameters:
-
projectileID
number -
tag
stringone 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:
- nil or number
Ground
Spring.IsPosInMap(x, z)
Parameters:
-
x
number -
z
number
Returns:
- boolean inPlayArea whether the position is in the active play area
- boolean inMap whether the position is in the full map area (currently this is the same as above)
Spring.GetGroundHeight(x, z)
Get ground height
On sea, this returns the negative depth of the seafloor
Parameters:
-
x
number -
z
number
Returns:
- number
Spring.GetWaterPlaneLevel()
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.
Returns:
- number waterPlaneLevel
See also:
Spring.GetWaterLevel(x, z)
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.
Parameters:
-
x
number -
z
number
Returns:
- number waterLevel
Spring.GetGroundOrigHeight(x, z)
Get ground height as it was at game start
Returns the original height before the ground got deformed
Parameters:
-
x
number -
z
number
Returns:
- number
Spring.GetGroundNormal(x, z[, smoothed=false])
Parameters:
-
x
number -
z
number -
smoothed
bool raw or smoothed center normal (default false)
Returns:
- number normalX
- number normalY
- number normalZ
- number slope
Spring.GetGroundInfo(x, z)
Parameters:
-
x
number -
z
number
Returns:
- number ix
- number iz
- number terrainTypeIndex
- string name
- number metalExtraction
- number hardness
- number tankSpeed
- number kbotSpeed
- number hoverSpeed
- number shipSpeed
- bool receiveTracks
Spring.GetGroundBlocked()
Spring.GetGroundExtremes()
Returns:
- number initMinHeight
- number initMaxHeight
- number currMinHeight
- number currMaxHeight
Spring.GetTerrainTypeData(terrainTypeInfo)
Parameters:
-
terrainTypeInfo
number
Returns:
- number index
- string name
- number hardness
- number tankSpeed
- number kbotSpeed
- number hoverSpeed
- number shipSpeed
- bool receiveTracks
Spring.GetGrass(x, z)
Parameters:
-
x
number -
z
number
Returns:
- number
Spring.GetSmoothMeshHeight(x, z)
Parameters:
-
x
number -
z
number
Returns:
- number height
Tests
Spring.TestMoveOrder(unitDefID, testTerrain, testObjects, centerOnly)
Parameters:
-
unitDefID
number -
testTerrain
bool (default true) -
testObjects
bool (default true) -
centerOnly
bool (default false)
Returns:
- bool
Spring.TestBuildOrder(unitDefID, x, y, z, facing)
Parameters:
-
unitDefID
number -
x
number -
y
number -
z
number -
facing
number or string one of: 0-s,1-e,2-n,3-w
Returns:
- number blocking one of: 0 = blocked, 1 = mobile unit on the way, 2 = reclaimable, 3 = open
- nil or featureID when there's a reclaimable feature on the way
Spring.Pos2BuildPos(unitDefID, posX, posY, posZ[, buildFacing=0])
Snaps a position to the building grid
Parameters:
-
unitDefID
number -
posX
number -
posY
number -
posZ
number -
buildFacing
number one of SOUTH = 0, EAST = 1, NORTH = 2, WEST = 3 (default 0)
Returns:
- number buildPosX
- number buildPosY
- number buildPosZ
Spring.ClosestBuildPos(teamID, unitDefID, posX, posY, posZ, searchRadius, minDistance, buildFacing)
Parameters:
-
teamID
number -
unitDefID
number -
posX
number -
posY
number -
posZ
number -
searchRadius
number -
minDistance
number -
buildFacing
number one of SOUTH = 0, EAST = 1, NORTH = 2, WEST = 3
Returns:
- number buildPosX
- number buildPosY
- number buildPosZ
Visibility
Spring.GetPositionLosState(posX, posY, posZ[, allyTeamID])
Parameters:
-
posX
number -
posY
number -
posZ
number -
allyTeamID
number (optional)
Returns:
- bool inLosOrRadar
- inLos
- inRadar
- inJammer
Spring.IsPosInLos(posX, posY, posZ[, allyTeamID])
Parameters:
-
posX
number -
posY
number -
posZ
number -
allyTeamID
number (optional)
Returns:
- bool
Spring.IsPosInRadar(posX, posY, posZ[, allyTeamID])
Parameters:
-
posX
number -
posY
number -
posZ
number -
allyTeamID
number (optional)
Returns:
- bool
Spring.IsPosInAirLos(posX, posY, posZ[, allyTeamID])
Parameters:
-
posX
number -
posY
number -
posZ
number -
allyTeamID
number (optional)
Returns:
- bool
Spring.GetUnitLosState(unitID[, allyTeamID[, raw=false]])
Parameters:
-
unitID
number -
allyTeamID
number (optional) -
raw
bool (default false)
Returns:
- nil, number or {los=bool,radar=bool,typed=bool} los
Raw is only available in gadgets and when raw parameter is true.
RAW returns an bitmask integer, where the bits are: 1: LOSINLOS, the unit is currently in the los of the allyteam, 2: LOSINRADAR the unit is currently in radar from the allyteam, 4: LOSPREVLOS the unit has previously been in los from the allyteam, 8: LOSCONTRADAR the unit has continuously been in radar since it was last inlos by the allyteam
Spring.IsUnitInLos(unitID, allyTeamID)
Parameters:
-
unitID
number -
allyTeamID
number
Returns:
- bool inLos
Spring.IsUnitInAirLos(unitID, allyTeamID)
Parameters:
-
unitID
number -
allyTeamID
number
Returns:
- bool inAirLos
Spring.IsUnitInRadar(unitID, allyTeamID)
Parameters:
-
unitID
number -
allyTeamID
number
Returns:
- bool inRadar
Spring.IsUnitInJammer(unitID, allyTeamID)
Parameters:
-
unitID
number -
allyTeamID
number
Returns:
- bool inJammer
Piece/Script
pieceSpec
Piece spec
Fields:
-
name
string -
parent
string -
children
{[string],...} names -
empty
bool -
min
{number,number,number} (x,y,z) -
max
{number,number,number} (x,y,z) -
offset
{number,number,number} (x,y,z)
Spring.GetModelRootPiece(modelName)
Spring.GetModelPieceMap(modelName)
Parameters:
-
modelName
string
Returns:
- nil or {[string]=number,...} pieceInfos where keys are piece names and values are indices
Spring.GetModelPieceList(modelName)
Spring.GetUnitRootPiece(unitID)
Parameters:
-
unitID
number
Returns:
- number index of the root piece
Spring.GetUnitPieceMap(unitID)
Parameters:
-
unitID
number
Returns:
- nil or {[string]=number,...} pieceInfos where keys are piece names and values are indices
Spring.GetUnitPieceList(unitID)
Spring.GetUnitPieceInfo(unitID, pieceIndex)
Spring.GetUnitPiecePosDir(unitID, pieceIndex)
Parameters:
-
unitID
number -
pieceIndex
number
Returns:
- number or nil posX
- number posY
- number posZ
- number dirX
- number dirY
- number dirZ
Spring.GetUnitPiecePosition(unitID, pieceIndex)
Parameters:
-
unitID
number -
pieceIndex
number
Returns:
- number or nil posX
- number posY
- number posZ
Spring.GetUnitPieceDirection(unitID, pieceIndex)
Parameters:
-
unitID
number -
pieceIndex
number
Returns:
- number or nil dirX
- number dirY
- number dirZ
Spring.GetUnitPieceMatrix(unitID)
Parameters:
-
unitID
number
Returns:
- number or nil m11
- number m12
- number m13
- number m14
- number m21
- number m22
- number m23
- number m24
- number m31
- number m32
- number m33
- number m34
- number m41
- number m42
- number m43
- number m44
Spring.GetFeatureRootPiece(featureID)
Parameters:
-
featureID
number
Returns:
- number index of the root piece
Spring.GetFeaturePieceMap(featureID)
Parameters:
-
featureID
number
Returns:
- {[string]=number,...} pieceInfos where keys are piece names and values are indices
Spring.GetFeaturePieceList(featureID)
Spring.GetFeaturePieceInfo(featureID, pieceIndex)
Spring.GetFeaturePiecePosDir(featureID, pieceIndex)
Parameters:
-
featureID
number -
pieceIndex
number
Returns:
- number or nil posX
- number posY
- number posZ
- number dirX
- number dirY
- number dirZ
Spring.GetFeaturePiecePosition(featureID, pieceIndex)
Parameters:
-
featureID
number -
pieceIndex
number
Returns:
- number or nil posX
- number posY
- number posZ
Spring.GetFeaturePieceDirection(featureID, pieceIndex)
Parameters:
-
featureID
number -
pieceIndex
number
Returns:
- number or nil dirX
- number dirY
- number dirZ
Spring.GetFeaturePieceMatrix(featureID)
Parameters:
-
featureID
number
Returns:
- number or nil m11
- number m12
- number m13
- number m14
- number m21
- number m22
- number m23
- number m24
- number m31
- number m32
- number m33
- number m34
- number m41
- number m42
- number m43
- number m44
Spring.GetUnitScriptPiece(unitID[, scriptPiece])
Parameters:
-
unitID
number -
scriptPiece
number (optional)
Returns:
- {number,...} or number pieceIndices when scriptPiece is not specified, pieceIndex otherwise
Spring.GetUnitScriptNames(unitID)
Parameters:
-
unitID
number
Returns:
- {[string]=number,...} where keys are piece names and values are piece indices