Module SyncedCtrl
Synced Lua API
See also:
Teams
- Spring.SetAlly
- Changes the value of the (one-sided) alliance between: firstAllyTeamID -> secondAllyTeamID.
- Spring.SetAllyTeamStartBox
- Changes the start box position of an allyTeam.
- Spring.AssignPlayerToTeam
- Assigns a player to a team.
- Spring.SetGlobalLos
- Changes access to global line of sight for a team and its allies.
Game End
- Spring.KillTeam
- Will declare a team to be dead (no further orders can be assigned to such teams units).
- Spring.GameOver
- Will declare game over.
Resources
- Spring.SetTidal
- Set tidal strength
- Spring.SetWind
- Set wind strength
- Spring.AddTeamResource
- Adds metal or energy resources to the specified team.
- Spring.UseTeamResource
- Consumes metal and/or energy resources of the specified team.
- Spring.SetTeamResource
- Spring.SetTeamShareLevel
- Changes the resource amount for a team beyond which resources aren't stored but transferred to other allied teams if possible.
- Spring.ShareTeamResource
- Transfers resources between two teams.
Rules Params
- losAccess
- Parameters for los access
- Spring.SetGameRulesParam
- Spring.SetTeamRulesParam
- Spring.SetPlayerRulesParam
- Spring.SetUnitRulesParam
- Spring.SetFeatureRulesParam
Lua to COB
Unit Handling
Unit Control
Unit Resourcing
- Spring.SetUnitResourcing
- Spring.SetUnitResourcing
- Spring.SetUnitTooltip
- Spring.SetUnitHealth
- Spring.SetUnitMaxHealth
- Spring.SetUnitStockpile
- Spring.SetUnitUseWeapons
- states
- Parameter for weapon states
- Spring.SetUnitWeaponState
- Spring.SetUnitWeaponState
- damages
- Parameters for damage
- Spring.SetUnitWeaponDamages
- Spring.SetUnitWeaponDamages
- Spring.SetUnitMaxRange
- Spring.SetUnitExperience
- Spring.AddUnitExperience
- Spring.SetUnitArmored
Unit LOS
- Spring.SetUnitLosMask
- Spring.SetUnitLosState
- Spring.SetUnitCloak
- Spring.SetUnitStealth
- Spring.SetUnitSonarStealth
- Spring.SetUnitSeismicSignature
- Spring.SetUnitAlwaysVisible
- Spring.SetUnitUseAirLos
- Spring.SetUnitMetalExtraction
- Spring.SetUnitHarvestStorage
- See also harvestStorage UnitDef tag.
- Spring.SetUnitBuildParams
- Spring.SetUnitBuildSpeed
- Spring.SetUnitNanoPieces
- Spring.SetUnitBlocking
- Spring.SetUnitCrashing
- Spring.SetUnitShieldState
- Spring.SetUnitShieldRechargeDelay
- Spring.SetUnitFlanking
- Spring.SetUnitNeutral
- Spring.SetUnitTarget
- Defines a unit's target.
- Spring.SetUnitTarget
- Spring.SetUnitMidAndAimPos
- Spring.SetUnitRadiusAndHeight
- Spring.SetUnitPieceParent
- Changes the pieces hierarchy of a unit by attaching a piece to a new parent.
- Spring.SetUnitPieceMatrix
- Sets the local (i.e.
- Spring.SetUnitCollisionVolumeData
- Spring.SetUnitPieceCollisionVolumeData
- Spring.SetUnitPieceVisible
- Spring.SetUnitSensorRadius
- Spring.SetUnitPosErrorParams
- Spring.SetUnitMoveGoal
- Used by default commands to get in build-, attackrange etc.
- Spring.SetUnitLandGoal
- Used in conjunction with Spring.UnitAttach et al.
- Spring.ClearUnitGoal
- Spring.SetUnitPhysics
- Spring.SetUnitMass
- Spring.SetUnitPosition
- Spring.SetUnitRotation
- Spring.SetUnitDirection
- Spring.SetUnitHeadingAndUpDir
- Spring.SetUnitVelocity
- Spring.SetFactoryBuggerOff
- Spring.BuggerOff
- Spring.AddUnitDamage
- Spring.AddUnitImpulse
- Spring.AddUnitSeismicPing
- Spring.AddUnitResource
- Spring.UseUnitResource
- Spring.UseUnitResource
Decals
Grass
Feature Handling
- Spring.CreateFeature
- Spring.DestroyFeature
- Spring.TransferFeature
- Feature Control
- Spring.SetFeatureAlwaysVisible
- Spring.SetFeatureUseAirLos
- Spring.SetFeatureHealth
- Spring.SetFeatureMaxHealth
- Spring.SetFeatureReclaim
- Spring.SetFeatureResources
- Spring.SetFeatureResurrect
- Spring.SetFeatureMoveCtrl
- Spring.SetFeaturePhysics
- Spring.SetFeatureMass
- Spring.SetFeaturePosition
- Spring.SetFeatureRotation
- Spring.SetFeatureDirection
- Spring.SetFeatureHeadingAndUpDir
- Spring.SetFeatureVelocity
- Spring.SetFeatureBlocking
- Spring.SetFeatureNoSelect
- Spring.SetFeatureMidAndAimPos
- Spring.SetFeatureRadiusAndHeight
- Spring.SetFeatureCollisionVolumeData
- Spring.SetFeaturePieceCollisionVolumeData
- Spring.SetFeaturePieceVisible
Projectiles
- projectileParams
- Spring.SetProjectileAlwaysVisible
- Spring.SetProjectileUseAirLos
- Spring.SetProjectileMoveControl
- Disables engine movecontrol, so lua can fully control the physics.
- Spring.SetProjectilePosition
- Spring.SetProjectileVelocity
- Spring.SetProjectileCollision
- Spring.SetProjectileTarget
- Spring.SetProjectileIsIntercepted
- Spring.SetProjectileDamages
- Spring.SetProjectileIgnoreTrackingError
- Spring.SetProjectileGravity
- Spring.SetPieceProjectileParams
Give Order
- cmdOpts
- Command Options params
- cmdSpec
- Command spec
- Spring.UnitFinishCommand
- Spring.GiveOrderToUnit
- Spring.GiveOrderToUnitMap
- Spring.GiveOrderToUnitArray
- Spring.GiveOrderArrayToUnit
- Spring.GiveOrderArrayToUnitMap
- Spring.GiveOrderArrayToUnitArray
Heightmap
- Spring.LevelHeightMap
- Set a certain height to a point or rectangle area on the world
- Spring.AdjustHeightMap
- Add a certain height to a point or rectangle area on the world
- Spring.RevertHeightMap
- Restore original map height to a point or rectangle area on the world
- Spring.AddHeightMap
- Can only be called in Spring.SetHeightMapFunc
- Spring.SetHeightMap
- Spring.SetHeightMapFunc
Height Map/Smooth Mesh
- Spring.LevelOriginalHeightMap
- Set a height to a point or rectangle area to the original map height cache
- Spring.AdjustOriginalHeightMap
- Add height to a point or rectangle area to the original map height cache
- Spring.RevertOriginalHeightMap
- Restore original map height cache to a point or rectangle area on the world
- Spring.AddOriginalHeightMap
- Spring.SetOriginalHeightMap
- Spring.SetOriginalHeightMapFunc
- Spring.LevelSmoothMesh
- Spring.AdjustSmoothMesh
- Spring.RevertSmoothMesh
- Spring.AddSmoothMesh
- Can only be called in Spring.SetSmoothMeshFunc.
- Spring.SetSmoothMesh
- Can only be called in Spring.SetSmoothMeshFunc.
- Spring.SetSmoothMeshFunc
TerrainTypes
- Spring.SetMapSquareTerrainType
- Spring.SetTerrainTypeData
- Spring.SetSquareBuildingMask
- Spring.UnitWeaponFire
- Spring.UnitAttach
- Spring.UnitDetach
- Spring.UnitDetachFromAir
- Spring.SetUnitLoadingTransport
- Disables collisions between the two units to allow colvol intersection during the approach.
- Spring.SpawnProjectile
- Spring.DeleteProjectile
- Silently removes projectiles (no explosion).
- explosionParams
- Parameters for explosion
Please note the explosion defaults to 1 damage regardless of what it's defined in the weaponDef.
- Spring.SpawnExplosion
- Spring.SpawnCEG
- Spring.SpawnSFX
- Equal to the UnitScript versions of EmitSFX, but takes position and direction arguments (in either unit- or piece-space) instead of a piece index.
Other
- Spring.SetNoPause
- Spring.SetExperienceGrade
- Defines how often
Callins.UnitExperience
will be called. - Spring.SetRadarErrorParams
Command Descriptions
Teams
Spring.SetAlly(firstAllyTeamID, secondAllyTeamID, ally)
Changes the value of the (one-sided) alliance between: firstAllyTeamID -> secondAllyTeamID.
Parameters:
-
firstAllyTeamID
number -
secondAllyTeamID
number -
ally
bool
Returns:
- nil
Spring.SetAllyTeamStartBox(allyTeamID, xMin, zMin, xMax, zMax)
Changes the start box position of an allyTeam.
Parameters:
-
allyTeamID
number -
xMin
number left start box boundary (elmos) -
zMin
number top start box boundary (elmos) -
xMax
number right start box boundary (elmos) -
zMax
number bottom start box boundary (elmos)
Returns:
- nil
Spring.AssignPlayerToTeam(playerID, teamID)
Assigns a player to a team.
Parameters:
-
playerID
number -
teamID
number
Returns:
- nil
Spring.SetGlobalLos(allyTeamID, globallos)
Changes access to global line of sight for a team and its allies.
Parameters:
-
allyTeamID
number -
globallos
bool
Returns:
- nil
Game End
Spring.KillTeam(teamID)
Will declare a team to be dead (no further orders can be assigned to such teams units).
Gaia team cannot be killed.
Parameters:
-
teamID
number
Returns:
- nil
Spring.GameOver([allyTeamID1[, allyTeamID2[, allyTeamIDn]]])
Will declare game over.
A list of winning allyteams can be passed, if undecided (like when dropped from the host) it should be empty (no winner), in the case of a draw with multiple winners, all should be listed.
Parameters:
-
allyTeamID1
number (optional) -
allyTeamID2
number (optional) -
allyTeamIDn
number (optional)
Returns:
- nil
Resources
Spring.SetTidal(strength)
Set tidal strength
Parameters:
-
strength
number
Returns:
- nil
Spring.SetWind(minStrength, maxStrength)
Set wind strength
Parameters:
-
minStrength
number -
maxStrength
number
Returns:
- nil
Spring.AddTeamResource(teamID, type, amount)
Adds metal or energy resources to the specified team.
Spring.UseTeamResource(teamID, type, amount)
Consumes metal and/or energy resources of the specified team.
Parameters:
-
teamID
number -
type
string "metal" | "energy" -
amount
number or table{ metal = number amount, energy = number amount }
Returns:
- nil or bool hadEnough
Spring.SetTeamResource(teamID, res, amount)
Parameters:
-
teamID
number -
res
string "m" = metal "e" = energy "ms" = metal storage "es" = energy storage -
amount
number
Returns:
- nil
Spring.SetTeamShareLevel(teamID, type, amount)
Changes the resource amount for a team beyond which resources aren't stored but transferred to other allied teams if possible.
Spring.ShareTeamResource(teamID_src, teamID_recv, type, amount)
Transfers resources between two teams.
Parameters:
-
teamID_src
number -
teamID_recv
number -
type
string "metal" | "energy" -
amount
number
Returns:
- nil
Rules Params
losAccess
Parameters for los access
If one condition is fulfilled all beneath it are too (e.g. if an unit is in LOS it can read params with `inradar=true` even if the param has `inlos=false`) All GameRulesParam are public, TeamRulesParams can just be `private`,`allied` and/or `public` You can read RulesParams from any Lua enviroments! With those losAccess policies you can limit their access.
Fields:
-
private
bool only readable by the ally (default) (optional) -
allied
bool readable by ally + ingame allied (optional) -
inlos
bool readable if the unit is in LOS (optional) -
inradar
bool readable if the unit is in AirLOS (optional) -
public
bool readable by all (optional)
Spring.SetGameRulesParam(paramName, paramValue[, losAccess])
Parameters:
-
paramName
string -
paramValue
number or string numeric paramValues in quotes will be converted to number. -
losAccess
losAccess (optional)
Returns:
- nil
Spring.SetTeamRulesParam(teamID, paramName, paramValue[, losAccess])
Parameters:
-
teamID
number -
paramName
string -
paramValue
number or string numeric paramValues in quotes will be converted to number. -
losAccess
losAccess (optional)
Returns:
- nil
Spring.SetPlayerRulesParam(playerID, paramName, paramValue[, losAccess])
Parameters:
-
playerID
number -
paramName
string -
paramValue
number or string numeric paramValues in quotes will be converted to number. -
losAccess
losAccess (optional)
Returns:
- nil
Spring.SetUnitRulesParam(unitID, paramName, paramValue[, losAccess])
Parameters:
-
unitID
number -
paramName
string -
paramValue
number or string numeric paramValues in quotes will be converted to number. -
losAccess
losAccess (optional)
Returns:
- nil
Spring.SetFeatureRulesParam(featureID, paramName, paramValue[, losAccess])
Parameters:
-
featureID
number -
paramName
string -
paramValue
number or string numeric paramValues in quotes will be converted to number. -
losAccess
losAccess (optional)
Returns:
- nil
Lua to COB
Spring.CallCOBScript(unitID, funcName, retArgs[, COBArg1[, COBArg2[, COBArgn]]])
Parameters:
-
unitID
number -
funcName
number or string -
retArgs
number -
COBArg1
(optional) -
COBArg2
(optional) -
COBArgn
(optional)
Returns:
- nil or number returnValue
- nil or number returnArg1
- nil or number returnArg2
- nil or number returnArgn
Spring.GetCOBScriptID(unitID, funcName)
Unit Handling
Spring.CreateUnit(unitDefName, x, y, z, facing, teamID[, build=false[, flattenGround=true[, unitID[, builderID]]]])
Offmap positions are clamped! Use MoveCtrl to move to such positions.
Parameters:
-
unitDefName
string or number or unitDefID -
x
number -
y
number -
z
number -
facing
string or number possible values for facing are: "south" | "s" | 0, "east" | "e" | 1, "north" | "n" | 2, "west" | "w" | 3 -
teamID
number -
build
bool the unit is created in "being built" state with buildProgress = 0 (default false) -
flattenGround
bool the unit flattens ground, if it normally does so (default true) -
unitID
number requests specific unitID (optional) -
builderID
number (optional)
Returns:
- number or nil unitID meaning unit was created
See also:
Spring.DestroyUnit(unitID[, selfd=false[, reclaimed=false[, attackerID[, cleanupImmediately=false]]]])
Parameters:
-
unitID
number -
selfd
bool makes the unit act like it self-destructed. (default false) -
reclaimed
bool don't show any DeathSequences, don't leave a wreckage. This does not give back the resources to the team! (default false) -
attackerID
number (optional) -
cleanupImmediately
bool stronger version of reclaimed, removes the unit unconditionally and makes its ID available for immediate reuse (otherwise it takes a few frames) (default false)
Returns:
- nil
See also:
Spring.TransferUnit(unitID, newTeamID[, given=true])
Parameters:
-
unitID
number -
newTeamID
number -
given
bool if false, the unit is captured. (default true)
Returns:
- nil
Unit Control
Spring.SetUnitCosts(unitID, where)
Parameters:
-
unitID
number -
where
{[number]=number,...} keys and values are, respectively and in this order: buildTime=amount, metalCost=amount, energyCost=amount
Returns:
- nil
Unit Resourcing
Spring.SetUnitResourcing(unitID, res, amount)
Spring.SetUnitResourcing(unitID, res)
Parameters:
-
unitID
number -
res
{[string]=number,...} keys are: "[u|c][u|m][m|e]" unconditional | conditional, use | make, metal | energy. Values are amounts
Returns:
- nil
Spring.SetUnitTooltip(unitID, tooltip)
Spring.SetUnitHealth(unitID, health)
Parameters:
-
unitID
number -
health
number or {[string]=number,...} where keys can be one of health|capture|paralyze|build and values are amounts
Returns:
- nil
Spring.SetUnitMaxHealth(unitID, maxHealth)
Parameters:
-
unitID
number -
maxHealth
number
Returns:
- nil
Spring.SetUnitStockpile(unitID[, stockpile[, buildPercent]])
Parameters:
-
unitID
number -
stockpile
number (optional) -
buildPercent
number (optional)
Returns:
- nil
Spring.SetUnitUseWeapons(unitID[, forceUseWeapons[, allowUseWeapons]])
Parameters:
-
unitID
number -
forceUseWeapons
number (optional) -
allowUseWeapons
number (optional)
Returns:
- nil
states
Parameter for weapon states
Fields:
-
reloadState
number -
reloadFrame
number synonym for reloadState! -
reloadTime
number -
accuracy
number -
sprayAngle
number -
range
number if you change the range of a weapon with dynamic damage make sure you use SetUnitWeaponDamages to change dynDamageRange as well. -
projectileSpeed
number -
burst
number -
burstRate
number -
projectiles
number -
salvoLeft
number -
nextSalvo
number -
aimReady
number (<>0.0f := true)
Spring.SetUnitWeaponState(unitID, weaponNum, states)
Spring.SetUnitWeaponState(unitID, weaponNum, key, value)
damages
Parameters for damage
Fields:
-
paralyzeDamageTime
number -
impulseFactor
number -
impulseBoost
number -
craterMult
number -
craterBoost
number -
dynDamageExp
number -
dynDamageMin
number -
dynDamageRange
number -
dynDamageInverted
number (<>0.0f := true) -
craterAreaOfEffect
number -
damageAreaOfEffect
number -
edgeEffectiveness
number -
explosionSpeed
number -
armorType
number
Spring.SetUnitWeaponDamages(unitID, weaponNum, damages)
Parameters:
Returns:
- nil
Spring.SetUnitWeaponDamages(unitID, weaponNum, key, value)
Parameters:
Returns:
- nil
Spring.SetUnitMaxRange(unitID, maxRange)
Parameters:
-
unitID
number -
maxRange
number
Returns:
- nil
Spring.SetUnitExperience(unitID, experience)
Spring.AddUnitExperience(unitID, deltaExperience)
Parameters:
-
unitID
number -
deltaExperience
number Can be negative to subtract, but the unit will never have negative total afterwards
Returns:
- nil
See also:
Spring.SetUnitArmored(unitID[, armored[, armorMultiple]])
Parameters:
-
unitID
number -
armored
bool (optional) -
armorMultiple
number (optional)
Returns:
- nil
Unit LOS
Spring.SetUnitLosMask(unitID, allyTeam, losTypes)
The 3rd argument is either the bit-and combination of the following numbers: LOS_INLOS = 1 LOS_INRADAR = 2 LOS_PREVLOS = 4 LOS_CONTRADAR = 8 or a table of the following form: losTypes = { [los = boolean,] [radar = boolean,] [prevLos = boolean,] [contRadar = boolean] }
Parameters:
-
unitID
number -
allyTeam
number -
losTypes
number or table
Returns:
- nil
Spring.SetUnitLosState(unitID, allyTeam, los)
Spring.SetUnitCloak(unitID, cloak, cloakArg)
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:=ultimative 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.
Parameters:
-
unitID
number -
cloak
bool or number -
cloakArg
bool or number
Returns:
- nil
Spring.SetUnitStealth(unitID, stealth)
Parameters:
-
unitID
number -
stealth
bool
Returns:
- nil
Spring.SetUnitSonarStealth(unitID, sonarStealth)
Parameters:
-
unitID
number -
sonarStealth
bool
Returns:
- nil
Spring.SetUnitSeismicSignature(unitID, seismicSignature)
Parameters:
-
unitID
number -
seismicSignature
number
Returns:
- nil
Spring.SetUnitAlwaysVisible(unitID, alwaysVisible)
Parameters:
-
unitID
number -
alwaysVisible
bool
Returns:
- nil
Spring.SetUnitUseAirLos(unitID, useAirLos)
Parameters:
-
unitID
number -
useAirLos
bool
Returns:
- nil
Spring.SetUnitMetalExtraction(unitID, depth[, range])
Parameters:
-
unitID
number -
depth
number corresponds to metal extraction rate -
range
number similar to "extractsMetal" in unitDefs. (optional)
Returns:
- nil
Spring.SetUnitHarvestStorage(unitID, metal)
See also harvestStorage UnitDef tag.
Parameters:
-
unitID
number -
metal
number
Returns:
- nil
Spring.SetUnitBuildParams(unitID, paramName, bool)
Parameters:
-
unitID
number -
paramName
string one ofbuildRange
|buildDistance
|buildRange3D
-
bool
number value bool whenparamName
isbuildRange3D
, number otherwise
Returns:
- nil
Spring.SetUnitBuildSpeed(builderID, buildSpeed[, repairSpeed[, reclaimSpeed[, captureSpeed[, terraformSpeed]]]])
Parameters:
-
builderID
number -
buildSpeed
number -
repairSpeed
number (optional) -
reclaimSpeed
number (optional) -
captureSpeed
number (optional) -
terraformSpeed
number (optional)
Returns:
- nil
Spring.SetUnitNanoPieces(builderID, pieces)
This saves a lot of engine calls, by replacing: function script.QueryNanoPiece() return currentpiece end Use it!
Parameters:
-
builderID
number -
pieces
table
Returns:
- nil
Spring.SetUnitBlocking(unitID, isblocking, isSolidObjectCollidable, isProjectileCollidable, isRaySegmentCollidable, crushable, blockEnemyPushing, blockHeightChanges)
Parameters:
-
unitID
number -
isblocking
bool -
isSolidObjectCollidable
bool -
isProjectileCollidable
bool -
isRaySegmentCollidable
bool -
crushable
bool -
blockEnemyPushing
bool -
blockHeightChanges
bool
Returns:
- nil
Spring.SetUnitCrashing(unitID, crashing)
Parameters:
-
unitID
number -
crashing
bool
Returns:
- bool success
Spring.SetUnitShieldState(unitID[, weaponID=-1[, enabled[, power]]])
Parameters:
-
unitID
number -
weaponID
number (default -1) -
enabled
bool (optional) -
power
number (optional)
Returns:
- nil
Spring.SetUnitShieldRechargeDelay(unitID[, weaponID[, rechargeTime]])
Parameters:
-
unitID
number -
weaponID
number (optional if the unit only has one shield) (optional) -
rechargeTime
number (in seconds; emulates a regular hit if nil) (optional)
Returns:
- nil
Spring.SetUnitFlanking(unitID, type, arg1[, y[, z]])
Parameters:
-
unitID
number -
type
string "dir"|"minDamage"|"maxDamage"|"moveFactor"|"mode" -
arg1
number x|minDamage|maxDamage|moveFactor|mode -
y
number only when type is "dir" (optional) -
z
number only when type is "dir" (optional)
Returns:
- nil
Spring.SetUnitNeutral(unitID, neutral)
Parameters:
-
unitID
number -
neutral
bool
Returns:
- nil or bool setNeutral
Spring.SetUnitTarget(unitID[, enemyUnitID[, dgun=false[, userTarget=false[, weaponNum=-1]]]])
Defines a unit's target.
Parameters:
-
unitID
number -
enemyUnitID
number when nil drops the units current target. (optional) -
dgun
bool (default false) -
userTarget
bool (default false) -
weaponNum
number (default -1)
Returns:
- bool success
Spring.SetUnitTarget(unitID[, x[, y[, z[, dgun=false[, userTarget=false[, weaponNum=-1]]]]]])
Parameters:
-
unitID
number -
x
number when nil or not passed it will drop target and ignore other parameters (optional) -
y
number (optional) -
z
number (optional) -
dgun
bool (default false) -
userTarget
bool (default false) -
weaponNum
number (default -1)
Returns:
- bool success
Spring.SetUnitMidAndAimPos(unitID, mpX, mpY, mpZ, apX, apY, apZ[, relative=false])
Parameters:
-
unitID
number -
mpX
number new middle positionX of unit -
mpY
number new middle positionY of unit -
mpZ
number new middle positionZ of unit -
apX
number new positionX that enemies aim at on this unit -
apY
number new positionY that enemies aim at on this unit -
apZ
number new positionZ that enemies aim at on this unit -
relative
bool are the new coordinates relative to world (false) or unit (true) coordinates? Also, note that apy is inverted! (default false)
Returns:
- bool success
Spring.SetUnitRadiusAndHeight(unitID, radius, height)
Parameters:
-
unitID
number -
radius
number -
height
number
Returns:
- bool success
Spring.SetUnitPieceParent(unitID, AlteredPiece, ParentPiece)
Changes the pieces hierarchy of a unit by attaching a piece to a new parent.
Parameters:
-
unitID
number -
AlteredPiece
number -
ParentPiece
number
Returns:
- nil
Spring.SetUnitPieceMatrix(unitID, pieceNum, matrix)
Sets the local (i.e.
parent-relative) matrix of the given piece. 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.
Parameters:
-
unitID
number -
pieceNum
number -
matrix
{number,...} an array of 16 floats
Returns:
- nil
Spring.SetUnitCollisionVolumeData(unitID, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, vType, tType, Axis)
Parameters:
-
unitID
number -
scaleX
number -
scaleY
number -
scaleZ
number -
offsetX
number -
offsetY
number -
offsetZ
number -
vType
number -
tType
number -
Axis
number
Returns:
- nil
enum 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(unitID, pieceIndex, enable, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ[, volumeType[, primaryAxis]])
Parameters:
-
unitID
number -
pieceIndex
number -
enable
bool -
scaleX
number -
scaleY
number -
scaleZ
number -
offsetX
number -
offsetY
number -
offsetZ
number -
volumeType
number (optional) -
primaryAxis
number (optional)
Returns:
- nil
Spring.SetUnitPieceVisible(unitID, pieceIndex, visible)
Parameters:
-
unitID
number -
pieceIndex
number -
visible
bool
Returns:
- nil
Spring.SetUnitSensorRadius(unitID, type)
Parameters:
-
unitID
number -
type
string "los" | "airLos" | "radar" | "sonar" | "seismic" | "radarJammer" | "sonarJammer"
Returns:
- nil or number newRadius
Spring.SetUnitPosErrorParams(unitID, posErrorVectorX, posErrorVectorY, posErrorVectorZ, posErrorDeltaX, posErrorDeltaY, posErrorDeltaZ[, nextPosErrorUpdate])
Parameters:
-
unitID
number -
posErrorVectorX
number -
posErrorVectorY
number -
posErrorVectorZ
number -
posErrorDeltaX
number -
posErrorDeltaY
number -
posErrorDeltaZ
number -
nextPosErrorUpdate
number (optional)
Returns:
- nil
Spring.SetUnitMoveGoal(unitID, goalX, goalY, goalZ[, goalRadius[, moveSpeed[, moveRaw]]])
Used by default commands to get in build-, attackrange etc.
Parameters:
-
unitID
number -
goalX
number -
goalY
number -
goalZ
number -
goalRadius
number (optional) -
moveSpeed
number (optional) -
moveRaw
bool (optional)
Returns:
- nil
Spring.SetUnitLandGoal(unitID, goalX, goalY, goalZ[, goalRadius])
Used in conjunction with Spring.UnitAttach et al.
to re-implement old airbase & fuel system in Lua.
Parameters:
-
unitID
number -
goalX
number -
goalY
number -
goalZ
number -
goalRadius
number (optional)
Returns:
- nil
Spring.ClearUnitGoal(unitID)
Parameters:
-
unitID
number
Returns:
- nil
Spring.SetUnitPhysics(unitID, posX, posY, posZ, velX, velY, velZ, rotX, rotY, rotZ, dragX, dragY, dragZ)
Parameters:
-
unitID
number -
posX
number -
posY
number -
posZ
number -
velX
number -
velY
number -
velZ
number -
rotX
number -
rotY
number -
rotZ
number -
dragX
number -
dragY
number -
dragZ
number
Returns:
- nil
Spring.SetUnitMass(unitID, mass)
Parameters:
-
unitID
number -
mass
number
Returns:
- nil
Spring.SetUnitPosition(unitID, x, z[, alwaysAboveSea])
Parameters:
-
unitID
number -
x
number -
z
number -
alwaysAboveSea
bool (optional)
Returns:
- nil
Spring.SetUnitRotation(unitID, yaw, pitch, roll)
Parameters:
-
unitID
number -
yaw
number -
pitch
number -
roll
number
Returns:
- nil
Spring.SetUnitDirection(unitID, x, y, z)
Parameters:
-
unitID
number -
x
number -
y
number -
z
number
Returns:
- nil
Spring.SetUnitHeadingAndUpDir(unitID, heading, upx, upy, upz)
Use this call to set up unit direction in a robust way. Heading (-32768 to 32767) represents a 2D (xz plane) unit orientation 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.
Parameters:
-
unitID
number -
heading
number -
upx
number -
upy
number -
upz
number
Returns:
- nil
Spring.SetUnitVelocity(unitID, velX, velY, velZ)
Parameters:
-
unitID
number -
velX
number -
velY
number -
velZ
number
Returns:
- nil
Spring.SetFactoryBuggerOff(unitID[, buggerOff[, offset[, radius[, relHeading[, spherical[, forced]]]]]])
Parameters:
-
unitID
number -
buggerOff
bool (optional) -
offset
number (optional) -
radius
number (optional) -
relHeading
number (optional) -
spherical
bool (optional) -
forced
bool (optional)
Returns:
- nil or number buggerOff
Spring.BuggerOff(x, y[, z], radius, teamID[, spherical=true[, forced=true[, excludeUnitID[, excludeUnitDefIDs]]]])
Parameters:
-
x
number -
y
number -
z
number uses ground height when unspecified (optional) -
radius
number -
teamID
number -
spherical
bool (default true) -
forced
bool (default true) -
excludeUnitID
number (optional) -
excludeUnitDefIDs
{[number],...} (optional)
Returns:
- nil
Spring.AddUnitDamage(unitID, damage[, paralyze=0[, attackerID=-1[, weaponID=-1[, impulseX[, impulseY[, impulseZ]]]]]])
Parameters:
-
unitID
number -
damage
number -
paralyze
number equals to the paralyzetime in the WeaponDef. (default 0) -
attackerID
number (default -1) -
weaponID
number (default -1) -
impulseX
number (optional) -
impulseY
number (optional) -
impulseZ
number (optional)
Returns:
- nil
Spring.AddUnitImpulse(unitID, x, y, z[, decayRate])
Parameters:
-
unitID
number -
x
number -
y
number -
z
number -
decayRate
number (optional)
Returns:
- nil
Spring.AddUnitSeismicPing(unitID, pindSize)
Parameters:
-
unitID
number -
pindSize
number
Returns:
- nil
Spring.AddUnitResource(unitID, resource, amount)
Spring.UseUnitResource(unitID, resource, amount)
Spring.UseUnitResource(unitID, resources)
Parameters:
-
unitID
number -
resources
{[string]=number,...} where keys are one of "m"|"metal"|"e"|"energy" and values are amounts
Returns:
- nil or bool okay
Decals
Spring.AddObjectDecal(unitID)
Parameters:
-
unitID
number
Returns:
- nil
Spring.RemoveObjectDecal(unitID)
Parameters:
-
unitID
number
Returns:
- nil
Grass
Spring.AddGrass(x, z)
Parameters:
-
x
number -
z
number
Returns:
- nil
Spring.RemoveGrass(x, z)
Parameters:
-
x
number -
z
number
Returns:
- nil
Feature Handling
Spring.CreateFeature(featureDef, x, y, z[, heading[, AllyTeamID[, featureID]]])
Parameters:
-
featureDef
string or number name or id -
x
number -
y
number -
z
number -
heading
number (optional) -
AllyTeamID
number (optional) -
featureID
number (optional)
Returns:
- number featureID
Spring.DestroyFeature(featureDefID)
Parameters:
-
featureDefID
number
Returns:
- nil
Spring.TransferFeature(featureDefID, teamID)
Feature Control
Parameters:
-
featureDefID
number -
teamID
number
Returns:
- nil
Spring.SetFeatureAlwaysVisible(featureID, enable)
Parameters:
-
featureID
number -
enable
bool
Returns:
- nil
Spring.SetFeatureUseAirLos(featureID, useAirLos)
Parameters:
-
featureID
number -
useAirLos
bool
Returns:
- nil
Spring.SetFeatureHealth(featureID, health)
Parameters:
-
featureID
number -
health
number
Returns:
- nil
Spring.SetFeatureMaxHealth(featureID, maxHealth)
Parameters:
-
featureID
number -
maxHealth
number minimum 0.1
Returns:
- nil
Spring.SetFeatureReclaim(featureID, reclaimLeft)
Parameters:
-
featureID
number -
reclaimLeft
number
Returns:
- nil
Spring.SetFeatureResources(featureID, metal, energy[, reclaimTime[, reclaimLeft[, featureDefMetal[, featureDefEnergy]]]])
Parameters:
-
featureID
number -
metal
number -
energy
number -
reclaimTime
number (optional) -
reclaimLeft
number (optional) -
featureDefMetal
number (optional) -
featureDefEnergy
number (optional)
Returns:
- nil
Spring.SetFeatureResurrect(featureID, unitDef[, facing[, progress]])
Second param can now be a number id instead of a string name, this also allows cancelling ressurection by passing -1. The level of progress can now be set via the additional 4th param. Possible values for facing are: "south" | "s" | 0 "east" | "e" | 1 "north" | "n" | 2 "west" | "w" | 3
Parameters:
-
featureID
number -
unitDef
string or number id or name -
facing
string or number (optional) -
progress
number (optional)
Returns:
- nil
Spring.SetFeatureMoveCtrl(featureID[, enable[, arg1[, arg2[, argn]]]])
Use this callout to control feature movement. The arg* arguments are parsed as follows and all optional: If enable is true: [, velVector(x,y,z) * initial velocity for feature [, accVector(x,y,z) * acceleration added every frame]] If enable is false: [, velocityMask(x,y,z) * dimensions in which velocity is allowed to build when not using MoveCtrl [, impulseMask(x,y,z) * dimensions in which impulse is allowed to apply when not using MoveCtrl [, movementMask(x,y,z) * dimensions in which feature is allowed to move when not using MoveCtrl]]] It is necessary to unlock feature movement on x,z axis before changing feature physics. For example use `Spring.SetFeatureMoveCtrl(featureID,false,1,1,1,1,1,1,1,1,1)` to unlock all movement prior to making `Spring.SetFeatureVelocity` calls.
Parameters:
-
featureID
number -
enable
bool (optional) -
arg1
number (optional) -
arg2
number (optional) -
argn
number (optional)
Returns:
- nil
Spring.SetFeaturePhysics(featureID, posX, posY, posZ, velX, velY, velZ, rotX, rotY, rotZ, dragX, dragY, dragZ)
Parameters:
-
featureID
number -
posX
number -
posY
number -
posZ
number -
velX
number -
velY
number -
velZ
number -
rotX
number -
rotY
number -
rotZ
number -
dragX
number -
dragY
number -
dragZ
number
Returns:
- nil
Spring.SetFeatureMass(featureID, mass)
Parameters:
-
featureID
number -
mass
number
Returns:
- nil
Spring.SetFeaturePosition(featureID, x, y, z[, snapToGround])
Parameters:
-
featureID
number -
x
number -
y
number -
z
number -
snapToGround
bool (optional)
Returns:
- nil
Spring.SetFeatureRotation(featureID, rotX, rotY, rotZ)
Parameters:
-
featureID
number -
rotX
number -
rotY
number -
rotZ
number
Returns:
- nil
Spring.SetFeatureDirection(featureID, dirX, dirY, dirZ)
Parameters:
-
featureID
number -
dirX
number -
dirY
number -
dirZ
number
Returns:
- nil
Spring.SetFeatureHeadingAndUpDir(featureID, heading, upx, upy, upz)
Use this call to set up feature direction in a robust way. Heading (-32768 to 32767) represents a 2D (xz plane) feature orientation 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.
Parameters:
-
featureID
number -
heading
number -
upx
number -
upy
number -
upz
number
Returns:
- nil
Spring.SetFeatureVelocity(featureID, velX, velY, velZ)
Parameters:
-
featureID
number -
velX
number -
velY
number -
velZ
number
Returns:
- nil
Spring.SetFeatureBlocking(featureID, isBlocking, isSolidObjectCollidable, isProjectileCollidable, isRaySegmentCollidable, crushable, blockEnemyPushing, blockHeightChanges)
Parameters:
-
featureID
number -
isBlocking
bool -
isSolidObjectCollidable
bool -
isProjectileCollidable
bool -
isRaySegmentCollidable
bool -
crushable
bool -
blockEnemyPushing
bool -
blockHeightChanges
bool
Returns:
- nil
Spring.SetFeatureNoSelect(featureID, noSelect)
Parameters:
-
featureID
number -
noSelect
bool
Returns:
- nil
Spring.SetFeatureMidAndAimPos(featureID, mpX, mpY, mpZ, apX, apY, apZ[, relative])
Check `Spring.SetUnitMidAndAimPos` for further explanation of the arguments.
Parameters:
-
featureID
number -
mpX
number -
mpY
number -
mpZ
number -
apX
number -
apY
number -
apZ
number -
relative
bool (optional)
Returns:
- bool success
Spring.SetFeatureRadiusAndHeight(featureID, radius, height)
Parameters:
-
featureID
number -
radius
number -
height
number
Returns:
- bool success
Spring.SetFeatureCollisionVolumeData(featureID, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, vType, tType, Axis)
Check `Spring.SetUnitCollisionVolumeData` for further explanation of the arguments.
Parameters:
-
featureID
number -
scaleX
number -
scaleY
number -
scaleZ
number -
offsetX
number -
offsetY
number -
offsetZ
number -
vType
number -
tType
number -
Axis
number
Returns:
- nil
Spring.SetFeaturePieceCollisionVolumeData(featureID, pieceIndex, enable, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, Axis, volumeType[, primaryAxis])
Parameters:
-
featureID
number -
pieceIndex
number -
enable
bool -
scaleX
number -
scaleY
number -
scaleZ
number -
offsetX
number -
offsetY
number -
offsetZ
number -
Axis
number -
volumeType
number -
primaryAxis
number (optional)
Returns:
- nil
Spring.SetFeaturePieceVisible(featureID, pieceIndex, visible)
Parameters:
-
featureID
number -
pieceIndex
number -
visible
bool
Returns:
- nil
Projectiles
projectileParams
Fields:
- pos
-
x
number -
y
number -
z
number
-
- end
-
x
number -
y
number -
z
number
-
- speed
-
x
number -
y
number -
z
number
-
- spread
-
x
number -
y
number -
z
number
-
- error
-
x
number -
y
number -
z
number
-
-
owner
number -
team
number -
ttl
number -
gravity
number -
tracking
number -
maxRange
number -
startAlpha
number -
endAlpha
number -
model
string -
cegTag
string
Spring.SetProjectileAlwaysVisible(projectileID, alwaysVisible)
Parameters:
-
projectileID
number -
alwaysVisible
bool
Returns:
- nil
Spring.SetProjectileUseAirLos(projectileID, useAirLos)
Parameters:
-
projectileID
number -
useAirLos
bool
Returns:
- nil
Spring.SetProjectileMoveControl(projectileID, enable)
Disables engine movecontrol, so lua can fully control the physics.
Parameters:
-
projectileID
number -
enable
bool
Returns:
- nil
Spring.SetProjectilePosition(projectileID[, posX=0[, posY=0[, posZ=0]]])
Parameters:
-
projectileID
number -
posX
number (default 0) -
posY
number (default 0) -
posZ
number (default 0)
Returns:
- nil
Spring.SetProjectileVelocity(projectileID[, velX=0[, velY=0[, velZ=0]]])
Parameters:
-
projectileID
number -
velX
number (default 0) -
velY
number (default 0) -
velZ
number (default 0)
Returns:
- nil
Spring.SetProjectileCollision(projectileID)
Parameters:
-
projectileID
number
Returns:
- nil
Spring.SetProjectileTarget(projectileID[, arg1=0[, arg2=0[, posZ=0]]])
targetTypeStr can be one of: 'u' - unit 'f' - feature 'p' - projectile while targetTypeInt is one of: string.byte('g') := GROUND string.byte('u') := UNIT string.byte('f') := FEATURE string.byte('p') := PROJECTILE
Parameters:
-
projectileID
number -
arg1
number targetID or posX (default 0) -
arg2
number targetType or posY (default 0) -
posZ
number (default 0)
Returns:
- nil or bool validTarget
Spring.SetProjectileIsIntercepted(projectileID)
Parameters:
-
projectileID
number
Returns:
- nil
Spring.SetProjectileDamages(unitID, weaponNum, key, value)
Spring.SetProjectileIgnoreTrackingError(projectileID, ignore)
Parameters:
-
projectileID
number -
ignore
bool
Returns:
- nil
Spring.SetProjectileGravity(projectileID[, grav=0])
Parameters:
-
projectileID
number -
grav
number (default 0)
Returns:
- nil
Spring.SetPieceProjectileParams(projectileID[, explosionFlags[, spinAngle[, spinSpeed[, spinVectorX[, spinVectorY[, spinVectorZ]]]]]])
Parameters:
-
projectileID
number -
explosionFlags
number (optional) -
spinAngle
number (optional) -
spinSpeed
number (optional) -
spinVectorX
number (optional) -
spinVectorY
number (optional) -
spinVectorZ
number (optional)
Returns:
- nil
Give Order
Options can also be a bitmask; e.g. 0 instead of an empty table (can avoid performance hit on table creation) See Constants.CMD
for relevant constants.
cmdOpts
Command Options params
Fields:
-
right
bool Right mouse key pressed -
alt
bool Alt key pressed -
ctrl
bool Ctrl key pressed -
shift
bool Shift key pressed
cmdSpec
Command spec
Used when assigning multiple commands at once
Fields:
-
cmdID
number -
params
{number,...} -
options
cmdOpts
Spring.UnitFinishCommand(unitID)
Parameters:
-
unitID
number
Returns:
- nil
Spring.GiveOrderToUnit(unitID, cmdID, params, cmdOpts)
Parameters:
-
unitID
number -
cmdID
number -
params
{number,...} -
cmdOpts
cmdOpts
Returns:
- bool unitOrdered
Spring.GiveOrderToUnitMap(unitMap, cmdID, params, cmdOpts)
Parameters:
-
unitMap
{[number]=table,...} table with unitIDs as keys -
cmdID
number -
params
{number,...} -
cmdOpts
cmdOpts
Returns:
- number unitsOrdered
Spring.GiveOrderToUnitArray(unitIDs, cmdID, params, cmdOpts)
Parameters:
-
unitIDs
{number,...} -
cmdID
number -
params
{number,...} -
cmdOpts
cmdOpts
Returns:
- number unitsOrdered
Spring.GiveOrderArrayToUnit(unitID, cmdArray)
Spring.GiveOrderArrayToUnitMap(unitMap, orderArray)
Parameters:
-
unitMap
{[number]=table} table with unitIDs as keys -
orderArray
{cmdSpec,...}
Returns:
- number unitsOrdered
Spring.GiveOrderArrayToUnitArray(unitArray, orderArray)
Heightmap
Note that x & z coords are in worldspace (Game.mapSizeX/Z), still the heightmap resolution is Game.squareSize.
Spring.LevelHeightMap(x1, z1, x2_height[, z2[, height]])
Set a certain height to a point or rectangle area on the world
Parameters:
-
x1
number -
z1
number -
x2_height
number if y2 and height are nil then this parameter is the height -
z2
number (optional) -
height
number (optional)
Returns:
- nil
Spring.AdjustHeightMap(x1, y1, x2_height[, y2[, height]])
Add a certain height to a point or rectangle area on the world
Parameters:
-
x1
number -
y1
number -
x2_height
number if y2 and height are nil then this parameter is the height -
y2
number (optional) -
height
number (optional)
Returns:
- nil
Spring.RevertHeightMap(x1, y1, x2_factor[, y2[, factor]])
Restore original map height to a point or rectangle area on the world
Parameters:
-
x1
number -
y1
number -
x2_factor
number if y2 and factor are nil then this parameter is the factor -
y2
number (optional) -
factor
number (optional)
Returns:
- nil
Spring.AddHeightMap(x, z, height)
Can only be called in `Spring.SetHeightMapFunc`
Parameters:
-
x
number -
z
number -
height
number
Returns:
- nil or number newHeight
Spring.SetHeightMap(x, z, height[, terraform=1])
Can only be called in `Spring.SetHeightMapFunc`. The terraform argument is
Parameters:
-
x
number -
z
number -
height
number -
terraform
number a scaling factor. (default 1)
Returns:
- nil or number absHeightDiff =0 nothing will be changed (the terraform starts) and if =1 the terraform will be finished.
Spring.SetHeightMapFunc(lua_function[, arg1[, arg2[, argn]]])
Example code: function Spring.SetHeightMapFunc(function() for z=0,Game.mapSizeZ, Game.squareSize do for x=0,Game.mapSizeX, Game.squareSize do Spring.SetHeightMap( x, z, 200 + 20 * math.cos((x + z) / 90) ) end end end)
Parameters:
-
lua_function
func -
arg1
(optional) -
arg2
(optional) -
argn
(optional)
Returns:
- nil or number absTotalHeightMapAmountChanged
Height Map/Smooth Mesh
Spring.LevelOriginalHeightMap(x1, y1, x2_height[, y2[, height]])
Set a height to a point or rectangle area to the original map height cache
Parameters:
-
x1
number -
y1
number -
x2_height
number if y2 and height are nil then this parameter is the height -
y2
number (optional) -
height
number (optional)
Returns:
- nil
Spring.AdjustOriginalHeightMap(x1, y1, x2_height[, y2[, height]])
Add height to a point or rectangle area to the original map height cache
Parameters:
-
x1
number -
y1
number -
x2_height
number if y2 and height are nil then this parameter is the height -
y2
number (optional) -
height
number (optional)
Returns:
- nil
Spring.RevertOriginalHeightMap(x1, y1, x2_factor[, y2[, factor]])
Restore original map height cache to a point or rectangle area on the world
Parameters:
-
x1
number -
y1
number -
x2_factor
number if y2 and factor are nil then this parameter is the factor -
y2
number (optional) -
factor
number (optional)
Returns:
- nil
Spring.AddOriginalHeightMap(x, y, height)
Can only be called in `Spring.SetOriginalHeightMapFunc`
Parameters:
-
x
number -
y
number -
height
number
Returns:
- nil
Spring.SetOriginalHeightMap(x, y, height[, factor])
Can only be called in `Spring.SetOriginalHeightMapFunc`
Parameters:
-
x
number -
y
number -
height
number -
factor
number (optional)
Returns:
- nil
Spring.SetOriginalHeightMapFunc(heightMapFunc)
Cannot recurse on itself
Parameters:
-
heightMapFunc
func
Returns:
- nil
Spring.LevelSmoothMesh(x1, z1[, x2][, z2], height)
Parameters:
-
x1
number -
z1
number -
x2
number (optional) -
z2
number (optional) -
height
number
Returns:
- nil
Spring.AdjustSmoothMesh(x1, z1[, x2][, z2], height)
Parameters:
-
x1
number -
z1
number -
x2
number (optional) -
z2
number (optional) -
height
number
Returns:
- nil
Spring.RevertSmoothMesh(x1, z1[, x2][, z2], origFactor)
Parameters:
-
x1
number -
z1
number -
x2
number (optional) -
z2
number (optional) -
origFactor
number
Returns:
- nil
Spring.AddSmoothMesh(x, z, height)
Can only be called in `Spring.SetSmoothMeshFunc`.
Parameters:
-
x
number -
z
number -
height
number
Returns:
- nil or number newHeight
Spring.SetSmoothMesh(x, z, height[, terraform=1])
Can only be called in `Spring.SetSmoothMeshFunc`.
Parameters:
-
x
number -
z
number -
height
number -
terraform
number (default 1)
Returns:
- nil or number absHeightDiff
Spring.SetSmoothMeshFunc(lua_function, arg1, arg2, argn)
Parameters:
-
lua_function
func -
arg1
[opt] -
arg2
[opt] -
argn
[opt]
Returns:
- nil or number absTotalHeightMapAmountChanged
TerrainTypes
Spring.SetMapSquareTerrainType(x, z, newType)
Parameters:
-
x
number -
z
number -
newType
number
Returns:
- nil or number oldType
Spring.SetTerrainTypeData(typeIndex[, speedTanks=nil[, speedKBOts=nil[, speedHovers=nil[, speedShips=nil]]]])
Parameters:
-
typeIndex
number -
speedTanks
number (default nil) -
speedKBOts
number (default nil) -
speedHovers
number (default nil) -
speedShips
number (default nil)
Returns:
- nil or bool true
Spring.SetSquareBuildingMask(x, z, mask)
Parameters:
-
x
number -
z
number -
mask
number
Returns:
- nil See also buildingMask unitdef tag.
Spring.UnitWeaponFire(unitID, weaponID)
Parameters:
-
unitID
number -
weaponID
number
Returns:
- nil
Spring.UnitAttach(transporterID, passengerID, pieceNum)
Parameters:
-
transporterID
number -
passengerID
number -
pieceNum
number
Returns:
- nil
Spring.UnitDetach(passengerID)
Parameters:
-
passengerID
number
Returns:
- nil
Spring.UnitDetachFromAir(passengerID)
Parameters:
-
passengerID
number
Returns:
- nil
Spring.SetUnitLoadingTransport(passengerID, transportID)
Disables collisions between the two units to allow colvol intersection during the approach.
Parameters:
-
passengerID
number -
transportID
number
Returns:
- nil
Spring.SpawnProjectile(weaponDefID, projectileParams)
Parameters:
-
weaponDefID
number -
projectileParams
projectileParams
Returns:
- nil or number projectileID
Spring.DeleteProjectile(projectileID)
Silently removes projectiles (no explosion).
Parameters:
-
projectileID
number
Returns:
- nil
explosionParams
Parameters for explosion Please note the explosion defaults to 1 damage regardless of what it's defined in the weaponDef.
The weapondefID is only used for visuals and for passing into callins like UnitDamaged.
Fields:
-
weaponDef
number -
owner
number -
hitUnit
number -
hitFeature
number -
craterAreaOfEffect
number -
damageAreaOfEffect
number -
edgeEffectiveness
number -
explosionSpeed
number -
gfxMod
number -
impactOnly
bool -
ignoreOwner
bool -
damageGround
bool
Spring.SpawnExplosion([posX=0][, posY=0][, posZ=0][, dirX=0][, dirY=0][, dirZ=0], explosionParams)
Parameters:
-
posX
number (default 0) -
posY
number (default 0) -
posZ
number (default 0) -
dirX
number (default 0) -
dirY
number (default 0) -
dirZ
number (default 0) -
explosionParams
explosionParams
Returns:
- nil
Spring.SpawnCEG(cegname[, posX=0[, posY=0[, posZ=0[, dirX=0[, dirY=0[, dirZ=0[, radius=0[, damage=0]]]]]]]])
Parameters:
-
cegname
string -
posX
number (default 0) -
posY
number (default 0) -
posZ
number (default 0) -
dirX
number (default 0) -
dirY
number (default 0) -
dirZ
number (default 0) -
radius
number (default 0) -
damage
number (default 0)
Returns:
- nil or bool success
- number cegID
Spring.SpawnSFX([unitID=0[, sfxID=0[, posX=0[, posY=0[, posZ=0[, dirX=0[, dirY=0[, dirZ=0[, radius=0[, damage=0[, absolute]]]]]]]]]]])
Equal to the UnitScript versions of EmitSFX, but takes position and direction arguments (in either unit- or piece-space) instead of a piece index.
Parameters:
-
unitID
number (default 0) -
sfxID
number (default 0) -
posX
number (default 0) -
posY
number (default 0) -
posZ
number (default 0) -
dirX
number (default 0) -
dirY
number (default 0) -
dirZ
number (default 0) -
radius
number (default 0) -
damage
number (default 0) -
absolute
bool (optional)
Returns:
- nil or bool success
Other
Spring.SetNoPause(noPause)
Parameters:
-
noPause
bool
Returns:
- nil
Spring.SetExperienceGrade(expGrade[, ExpPowerScale[, ExpHealthScale[, ExpReloadScale]]])
Defines how often `Callins.UnitExperience` will be called.
Parameters:
-
expGrade
number -
ExpPowerScale
number (optional) -
ExpHealthScale
number (optional) -
ExpReloadScale
number (optional)
Returns:
- nil
Spring.SetRadarErrorParams(allyTeamID, allyteamErrorSize[, baseErrorSize[, baseErrorMult]])
Parameters:
-
allyTeamID
number -
allyteamErrorSize
number -
baseErrorSize
number (optional) -
baseErrorMult
number (optional)
Returns:
- nil
Command Descriptions
Doesn't work in unsynced code!
Spring.EditUnitCmdDesc(unitID, cmdDescID, cmdArray)
Parameters:
-
unitID
number -
cmdDescID
number -
cmdArray
tablestructure of cmdArray:
{ [ id = int ], [ type = int ], [ name = string ], [ action = string ], [ tooltip = string ], [ texture = string ], [ cursor = string ], [ queueing = boolean ], [ hidden = boolean ], [ disabled = boolean ], [ showUnique = boolean ], [ onlyTexture = boolean ], [ params = { string = string, ... } ] }
Returns:
- nil
Spring.InsertUnitCmdDesc(unitID[, cmdDescID], cmdArray)
Spring.RemoveUnitCmdDesc(unitID[, cmdDescID])
Parameters:
-
unitID
number -
cmdDescID
number (optional)
Returns:
- nil