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

Spring.CallCOBScript
Spring.GetCOBScriptID

Unit Handling

Spring.CreateUnit
Spring.DestroyUnit
Spring.TransferUnit

Unit Control

Spring.SetUnitCosts

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.SetUnitPhysicalStateBit
Spring.GetUnitPhysicalState
Spring.SetUnitNeutral
Spring.SetUnitTarget
Defines a unit's target.
Spring.SetUnitTarget
Spring.SetUnitMidAndAimPos
Spring.SetUnitRadiusAndHeight
Spring.SetUnitBuildeeRadius
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
Set unit position (2D)
Spring.SetUnitPosition
Set unit position (3D)
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

Spring.AddObjectDecal
Spring.RemoveObjectDecal

Grass

Spring.AddGrass
Spring.RemoveGrass

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.RebuildSmoothMesh
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

Spring.EditUnitCmdDesc
Spring.InsertUnitCmdDesc
Spring.RemoveUnitCmdDesc

Teams


Spring.SetAlly(firstAllyTeamID, secondAllyTeamID, ally)

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

Parameters:

  1. firstAllyTeamID number
  2. secondAllyTeamID number
  3. ally bool

Returns:

  1. nil

Spring.SetAllyTeamStartBox(allyTeamID, xMin, zMin, xMax, zMax)

Changes the start box position of an allyTeam.

Parameters:

  1. allyTeamID number
  2. xMin number left start box boundary (elmos)
  3. zMin number top start box boundary (elmos)
  4. xMax number right start box boundary (elmos)
  5. zMax number bottom start box boundary (elmos)

Returns:

  1. nil

Spring.AssignPlayerToTeam(playerID, teamID)

Assigns a player to a team.

Parameters:

  1. playerID number
  2. teamID number

Returns:

  1. nil

Spring.SetGlobalLos(allyTeamID, globallos)

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

Parameters:

  1. allyTeamID number
  2. globallos bool

Returns:

  1. 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:

  1. teamID number

Returns:

  1. 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:

  1. allyTeamID1 number (optional)
  2. allyTeamID2 number (optional)
  3. allyTeamIDn number (optional)

Returns:

  1. nil

Resources

Spring.SetTidal(strength)

Set tidal strength

Parameters:

  1. strength number

Returns:

  1. nil

Spring.SetWind(minStrength, maxStrength)

Set wind strength

Parameters:

  1. minStrength number
  2. maxStrength number

Returns:

  1. nil

Spring.AddTeamResource(teamID, type, amount)

Adds metal or energy resources to the specified team.

Parameters:

  1. teamID number
  2. type string "metal" | "energy"
  3. amount number

Returns:

  1. nil

Spring.UseTeamResource(teamID, type, amount)

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

Parameters:

  1. teamID number
  2. type string "metal" | "energy"
  3. amount number or table { metal = number amount, energy = number amount }

Returns:

  1. nil or bool hadEnough

Spring.SetTeamResource(teamID, res, amount)

Parameters:

  1. teamID number
  2. res string "m" = metal "e" = energy "ms" = metal storage "es" = energy storage
  3. amount number

Returns:

  1. 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.

Parameters:

  1. teamID number
  2. type string "metal" | "energy"
  3. amount number

Returns:

  1. nil

Spring.ShareTeamResource(teamID_src, teamID_recv, type, amount)

Transfers resources between two teams.

Parameters:

  1. teamID_src number
  2. teamID_recv number
  3. type string "metal" | "energy"
  4. amount number

Returns:

  1. 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:

  1. private bool only readable by the ally (default) (optional)
  2. allied bool readable by ally + ingame allied (optional)
  3. inlos bool readable if the unit is in LOS (optional)
  4. inradar bool readable if the unit is in AirLOS (optional)
  5. public bool readable by all (optional)

Spring.SetGameRulesParam(paramName, paramValue[, losAccess])

Parameters:

  1. paramName string
  2. paramValue number or string numeric paramValues in quotes will be converted to number.
  3. losAccess losAccess (optional)

Returns:

  1. nil

Spring.SetTeamRulesParam(teamID, paramName, paramValue[, losAccess])

Parameters:

  1. teamID number
  2. paramName string
  3. paramValue number or string numeric paramValues in quotes will be converted to number.
  4. losAccess losAccess (optional)

Returns:

  1. nil

Spring.SetPlayerRulesParam(playerID, paramName, paramValue[, losAccess])

Parameters:

  1. playerID number
  2. paramName string
  3. paramValue number or string numeric paramValues in quotes will be converted to number.
  4. losAccess losAccess (optional)

Returns:

  1. nil

Spring.SetUnitRulesParam(unitID, paramName, paramValue[, losAccess])

Parameters:

  1. unitID number
  2. paramName string
  3. paramValue number or string numeric paramValues in quotes will be converted to number.
  4. losAccess losAccess (optional)

Returns:

  1. nil

Spring.SetFeatureRulesParam(featureID, paramName, paramValue[, losAccess])

Parameters:

  1. featureID number
  2. paramName string
  3. paramValue number or string numeric paramValues in quotes will be converted to number.
  4. losAccess losAccess (optional)

Returns:

  1. nil

Lua to COB


Spring.CallCOBScript(unitID, funcName, retArgs[, COBArg1[, COBArg2[, COBArgn]]])

Parameters:

  1. unitID number
  2. funcName number or string
  3. retArgs number
  4. COBArg1 (optional)
  5. COBArg2 (optional)
  6. COBArgn (optional)

Returns:

  1. nil or number returnValue
  2. nil or number returnArg1
  3. nil or number returnArg2
  4. nil or number returnArgn

Spring.GetCOBScriptID(unitID, funcName)

Parameters:

  1. unitID number
  2. funcName string

Returns:

  1. nil or number funcID

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:

  1. unitDefName string or number or unitDefID
  2. x number
  3. y number
  4. z number
  5. facing string or number possible values for facing are: "south" | "s" | 0, "east" | "e" | 1, "north" | "n" | 2, "west" | "w" | 3
  6. teamID number
  7. build bool the unit is created in "being built" state with buildProgress = 0 (default false)
  8. flattenGround bool the unit flattens ground, if it normally does so (default true)
  9. unitID number requests specific unitID (optional)
  10. builderID number (optional)

Returns:

  1. number or nil unitID meaning unit was created

See also:

    Spring.DestroyUnit(unitID[, selfd=false[, reclaimed=false[, attackerID[, cleanupImmediately=false]]]])

    Parameters:

    1. unitID number
    2. selfd bool makes the unit act like it self-destructed. (default false)
    3. reclaimed bool don't show any DeathSequences, don't leave a wreckage. This does not give back the resources to the team! (default false)
    4. attackerID number (optional)
    5. 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:

    1. nil

    See also:

    Spring.TransferUnit(unitID, newTeamID[, given=true])

    Parameters:

    1. unitID number
    2. newTeamID number
    3. given bool if false, the unit is captured. (default true)

    Returns:

    1. nil

    Unit Control


    Spring.SetUnitCosts(unitID, where)

    Parameters:

    1. unitID number
    2. where {[number]=number,...} keys and values are, respectively and in this order: buildTime=amount, metalCost=amount, energyCost=amount

    Returns:

    1. nil

    Unit Resourcing

    Spring.SetUnitResourcing(unitID, res, amount)

    Parameters:

    1. unitID number
    2. res string
    3. amount number

    Returns:

    1. nil

    Spring.SetUnitResourcing(unitID, res)

    Parameters:

    1. unitID number
    2. res {[string]=number,...} keys are: "[u|c][u|m][m|e]" unconditional | conditional, use | make, metal | energy. Values are amounts

    Returns:

    1. nil

    Spring.SetUnitTooltip(unitID, tooltip)

    Parameters:

    1. unitID number
    2. tooltip string

    Returns:

    1. nil

    Spring.SetUnitHealth(unitID, health)

    Parameters:

    1. unitID number
    2. health number or {[string]=number,...} where keys can be one of health|capture|paralyze|build and values are amounts

    Returns:

    1. nil

    Spring.SetUnitMaxHealth(unitID, maxHealth)

    Parameters:

    1. unitID number
    2. maxHealth number

    Returns:

    1. nil

    Spring.SetUnitStockpile(unitID[, stockpile[, buildPercent]])

    Parameters:

    1. unitID number
    2. stockpile number (optional)
    3. buildPercent number (optional)

    Returns:

    1. nil

    Spring.SetUnitUseWeapons(unitID[, forceUseWeapons[, allowUseWeapons]])

    Parameters:

    1. unitID number
    2. forceUseWeapons number (optional)
    3. allowUseWeapons number (optional)

    Returns:

    1. nil

    states

    Parameter for weapon states

    Fields:

    1. reloadState number
    2. reloadFrame number synonym for reloadState!
    3. reloadTime number
    4. accuracy number
    5. sprayAngle number
    6. range number if you change the range of a weapon with dynamic damage make sure you use SetUnitWeaponDamages to change dynDamageRange as well.
    7. projectileSpeed number
    8. burst number
    9. burstRate number
    10. projectiles number
    11. salvoLeft number
    12. nextSalvo number
    13. aimReady number (<>0.0f := true)

    Spring.SetUnitWeaponState(unitID, weaponNum, states)

    Parameters:

    1. unitID number
    2. weaponNum number
    3. states states

    Returns:

    1. nil

    Spring.SetUnitWeaponState(unitID, weaponNum, key, value)

    Parameters:

    1. unitID number
    2. weaponNum number
    3. key string
    4. value number

    Returns:

    1. nil

    damages

    Parameters for damage

    Fields:

    1. paralyzeDamageTime number
    2. impulseFactor number
    3. impulseBoost number
    4. craterMult number
    5. craterBoost number
    6. dynDamageExp number
    7. dynDamageMin number
    8. dynDamageRange number
    9. dynDamageInverted number (<>0.0f := true)
    10. craterAreaOfEffect number
    11. damageAreaOfEffect number
    12. edgeEffectiveness number
    13. explosionSpeed number
    14. armorType number

    Spring.SetUnitWeaponDamages(unitID, weaponNum, damages)

    Parameters:

    1. unitID number
    2. weaponNum number or string "selfDestruct" | "explode"
    3. damages damages

    Returns:

    1. nil

    Spring.SetUnitWeaponDamages(unitID, weaponNum, key, value)

    Parameters:

    1. unitID number
    2. weaponNum number or string "selfDestruct" | "explode"
    3. key string
    4. value number

    Returns:

    1. nil

    Spring.SetUnitMaxRange(unitID, maxRange)

    Parameters:

    1. unitID number
    2. maxRange number

    Returns:

    1. nil

    Spring.SetUnitExperience(unitID, experience)

    Parameters:

    1. unitID number
    2. experience number

    Returns:

    1. nil

    See also:

    Spring.AddUnitExperience(unitID, deltaExperience)

    Parameters:

    1. unitID number
    2. deltaExperience number Can be negative to subtract, but the unit will never have negative total afterwards

    Returns:

    1. nil

    See also:

    Spring.SetUnitArmored(unitID[, armored[, armorMultiple]])

    Parameters:

    1. unitID number
    2. armored bool (optional)
    3. armorMultiple number (optional)

    Returns:

    1. 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:

    1. unitID number
    2. allyTeam number
    3. losTypes number or table

    Returns:

    1. nil

    Spring.SetUnitLosState(unitID, allyTeam, los)

    Parameters:

    1. unitID number
    2. allyTeam number
    3. los number or table

    Returns:

    1. nil

    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:

    1. unitID number
    2. cloak bool or number
    3. cloakArg bool or number

    Returns:

    1. nil

    Spring.SetUnitStealth(unitID, stealth)

    Parameters:

    1. unitID number
    2. stealth bool

    Returns:

    1. nil

    Spring.SetUnitSonarStealth(unitID, sonarStealth)

    Parameters:

    1. unitID number
    2. sonarStealth bool

    Returns:

    1. nil

    Spring.SetUnitSeismicSignature(unitID, seismicSignature)

    Parameters:

    1. unitID number
    2. seismicSignature number

    Returns:

    1. nil

    Spring.SetUnitAlwaysVisible(unitID, alwaysVisible)

    Parameters:

    1. unitID number
    2. alwaysVisible bool

    Returns:

    1. nil

    Spring.SetUnitUseAirLos(unitID, useAirLos)

    Parameters:

    1. unitID number
    2. useAirLos bool

    Returns:

    1. nil

    Spring.SetUnitMetalExtraction(unitID, depth[, range])

    Parameters:

    1. unitID number
    2. depth number corresponds to metal extraction rate
    3. range number similar to "extractsMetal" in unitDefs. (optional)

    Returns:

    1. nil

    Spring.SetUnitHarvestStorage(unitID, metal)

    See also harvestStorage UnitDef tag.

    Parameters:

    1. unitID number
    2. metal number

    Returns:

    1. nil

    Spring.SetUnitBuildParams(unitID, paramName, bool)

    Parameters:

    1. unitID number
    2. paramName string one of buildRange|buildDistance|buildRange3D
    3. bool number value bool when paramName is buildRange3D, number otherwise

    Returns:

    1. nil

    Spring.SetUnitBuildSpeed(builderID, buildSpeed[, repairSpeed[, reclaimSpeed[, captureSpeed[, terraformSpeed]]]])

    Parameters:

    1. builderID number
    2. buildSpeed number
    3. repairSpeed number (optional)
    4. reclaimSpeed number (optional)
    5. captureSpeed number (optional)
    6. terraformSpeed number (optional)

    Returns:

    1. nil

    Spring.SetUnitNanoPieces(builderID, pieces)

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

    Parameters:

    1. builderID number
    2. pieces table

    Returns:

    1. nil

    Spring.SetUnitBlocking(unitID, isblocking, isSolidObjectCollidable, isProjectileCollidable, isRaySegmentCollidable, crushable, blockEnemyPushing, blockHeightChanges)

    Parameters:

    1. unitID number
    2. isblocking bool
    3. isSolidObjectCollidable bool
    4. isProjectileCollidable bool
    5. isRaySegmentCollidable bool
    6. crushable bool
    7. blockEnemyPushing bool
    8. blockHeightChanges bool

    Returns:

    1. nil

    Spring.SetUnitCrashing(unitID, crashing)

    Parameters:

    1. unitID number
    2. crashing bool

    Returns:

    1. bool success

    Spring.SetUnitShieldState(unitID[, weaponID=-1[, enabled[, power]]])

    Parameters:

    1. unitID number
    2. weaponID number (default -1)
    3. enabled bool (optional)
    4. power number (optional)

    Returns:

    1. nil

    Spring.SetUnitShieldRechargeDelay(unitID[, weaponID[, rechargeTime]])

    Parameters:

    1. unitID number
    2. weaponID number (optional if the unit only has one shield) (optional)
    3. rechargeTime number (in seconds; emulates a regular hit if nil) (optional)

    Returns:

    1. nil

    Spring.SetUnitFlanking(unitID, type, arg1[, y[, z]])

    Parameters:

    1. unitID number
    2. type string "dir"|"minDamage"|"maxDamage"|"moveFactor"|"mode"
    3. arg1 number x|minDamage|maxDamage|moveFactor|mode
    4. y number only when type is "dir" (optional)
    5. z number only when type is "dir" (optional)

    Returns:

    1. nil

    Spring.SetUnitPhysicalStateBit(unitID, Physical)

    Parameters:

    1. unitID number
    2. Physical number state bit

    Returns:

    1. nil

    Spring.GetUnitPhysicalState(unitID)

    Parameters:

    1. unitID number

    Returns:

    1. number Unit's PhysicalState bitmask

    Spring.SetUnitNeutral(unitID, neutral)

    Parameters:

    1. unitID number
    2. neutral bool

    Returns:

    1. nil or bool setNeutral

    Spring.SetUnitTarget(unitID[, enemyUnitID[, dgun=false[, userTarget=false[, weaponNum=-1]]]])

    Defines a unit's target.

    Parameters:

    1. unitID number
    2. enemyUnitID number when nil drops the units current target. (optional)
    3. dgun bool (default false)
    4. userTarget bool (default false)
    5. weaponNum number (default -1)

    Returns:

    1. bool success

    Spring.SetUnitTarget(unitID[, x[, y[, z[, dgun=false[, userTarget=false[, weaponNum=-1]]]]]])

    Parameters:

    1. unitID number
    2. x number when nil or not passed it will drop target and ignore other parameters (optional)
    3. y number (optional)
    4. z number (optional)
    5. dgun bool (default false)
    6. userTarget bool (default false)
    7. weaponNum number (default -1)

    Returns:

    1. bool success

    Spring.SetUnitMidAndAimPos(unitID, mpX, mpY, mpZ, apX, apY, apZ[, relative=false])

    Parameters:

    1. unitID number
    2. mpX number new middle positionX of unit
    3. mpY number new middle positionY of unit
    4. mpZ number new middle positionZ of unit
    5. apX number new positionX that enemies aim at on this unit
    6. apY number new positionY that enemies aim at on this unit
    7. apZ number new positionZ that enemies aim at on this unit
    8. relative bool are the new coordinates relative to world (false) or unit (true) coordinates? Also, note that apy is inverted! (default false)

    Returns:

    1. bool success

    Spring.SetUnitRadiusAndHeight(unitID, radius, height)

    Parameters:

    1. unitID number
    2. radius number
    3. height number

    Returns:

    1. bool success

    Spring.SetUnitBuildeeRadius(unitID, build)

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

    Parameters:

    1. unitID number
    2. build number radius for when targeted by build, repair, reclaim-type commands.

    Returns:

    1. nil

    Spring.SetUnitPieceParent(unitID, AlteredPiece, ParentPiece)

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

    Parameters:

    1. unitID number
    2. AlteredPiece number
    3. ParentPiece number

    Returns:

    1. 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:

    1. unitID number
    2. pieceNum number
    3. matrix {number,...} an array of 16 floats

    Returns:

    1. nil

    Spring.SetUnitCollisionVolumeData(unitID, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, vType, tType, Axis)

    Parameters:

    1. unitID number
    2. scaleX number
    3. scaleY number
    4. scaleZ number
    5. offsetX number
    6. offsetY number
    7. offsetZ number
    8. vType number
    9. tType number
    10. Axis number

    Returns:

    1. 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:

    1. unitID number
    2. pieceIndex number
    3. enable bool
    4. scaleX number
    5. scaleY number
    6. scaleZ number
    7. offsetX number
    8. offsetY number
    9. offsetZ number
    10. volumeType number (optional)
    11. primaryAxis number (optional)

    Returns:

    1. nil

    Spring.SetUnitPieceVisible(unitID, pieceIndex, visible)

    Parameters:

    1. unitID number
    2. pieceIndex number
    3. visible bool

    Returns:

    1. nil

    Spring.SetUnitSensorRadius(unitID, type, radius)

    Parameters:

    1. unitID number
    2. type string "los" | "airLos" | "radar" | "sonar" | "seismic" | "radarJammer" | "sonarJammer"
    3. radius number

    Returns:

    1. nil or number newRadius

    Spring.SetUnitPosErrorParams(unitID, posErrorVectorX, posErrorVectorY, posErrorVectorZ, posErrorDeltaX, posErrorDeltaY, posErrorDeltaZ[, nextPosErrorUpdate])

    Parameters:

    1. unitID number
    2. posErrorVectorX number
    3. posErrorVectorY number
    4. posErrorVectorZ number
    5. posErrorDeltaX number
    6. posErrorDeltaY number
    7. posErrorDeltaZ number
    8. nextPosErrorUpdate number (optional)

    Returns:

    1. nil

    Spring.SetUnitMoveGoal(unitID, goalX, goalY, goalZ[, goalRadius[, moveSpeed[, moveRaw]]])

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

    Parameters:

    1. unitID number
    2. goalX number
    3. goalY number
    4. goalZ number
    5. goalRadius number (optional)
    6. moveSpeed number (optional)
    7. moveRaw bool (optional)

    Returns:

    1. 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:

    1. unitID number
    2. goalX number
    3. goalY number
    4. goalZ number
    5. goalRadius number (optional)

    Returns:

    1. nil

    Spring.ClearUnitGoal(unitID)

    Parameters:

    1. unitID number

    Returns:

    1. nil

    Spring.SetUnitPhysics(unitID, posX, posY, posZ, velX, velY, velZ, rotX, rotY, rotZ, dragX, dragY, dragZ)

    Parameters:

    1. unitID number
    2. posX number
    3. posY number
    4. posZ number
    5. velX number
    6. velY number
    7. velZ number
    8. rotX number
    9. rotY number
    10. rotZ number
    11. dragX number
    12. dragY number
    13. dragZ number

    Returns:

    1. nil

    Spring.SetUnitMass(unitID, mass)

    Parameters:

    1. unitID number
    2. mass number

    Returns:

    1. nil

    Spring.SetUnitPosition(unitID, x, z[, floating=false])

    Set unit position (2D)

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

    Parameters:

    1. unitID number
    2. x number
    3. z number
    4. floating bool If true, over water the position is on surface. If false, on seafloor. (default false)

    Returns:

    1. nil

    Spring.SetUnitPosition(unitID, x, y, z)

    Set unit position (3D)

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

    Parameters:

    1. unitID number
    2. x number
    3. y number
    4. z number

    Returns:

    1. nil

    Spring.SetUnitRotation(unitID, yaw, pitch, roll)

    Parameters:

    1. unitID number
    2. yaw number
    3. pitch number
    4. roll number

    Returns:

    1. nil

    Spring.SetUnitDirection(unitID, x, y, z)

    Parameters:

    1. unitID number
    2. x number
    3. y number
    4. z number

    Returns:

    1. 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:

    1. unitID number
    2. heading number
    3. upx number
    4. upy number
    5. upz number

    Returns:

    1. nil

    Spring.SetUnitVelocity(unitID, velX, velY, velZ)

    Parameters:

    1. unitID number
    2. velX number
    3. velY number
    4. velZ number

    Returns:

    1. nil

    Spring.SetFactoryBuggerOff(unitID[, buggerOff[, offset[, radius[, relHeading[, spherical[, forced]]]]]])

    Parameters:

    1. unitID number
    2. buggerOff bool (optional)
    3. offset number (optional)
    4. radius number (optional)
    5. relHeading number (optional)
    6. spherical bool (optional)
    7. forced bool (optional)

    Returns:

    1. nil or number buggerOff

    Spring.BuggerOff(x, y[, z], radius, teamID[, spherical=true[, forced=true[, excludeUnitID[, excludeUnitDefIDs]]]])

    Parameters:

    1. x number
    2. y number
    3. z number uses ground height when unspecified (optional)
    4. radius number
    5. teamID number
    6. spherical bool (default true)
    7. forced bool (default true)
    8. excludeUnitID number (optional)
    9. excludeUnitDefIDs {[number],...} (optional)

    Returns:

    1. nil

    Spring.AddUnitDamage(unitID, damage[, paralyze=0[, attackerID=-1[, weaponID=-1[, impulseX[, impulseY[, impulseZ]]]]]])

    Parameters:

    1. unitID number
    2. damage number
    3. paralyze number equals to the paralyzetime in the WeaponDef. (default 0)
    4. attackerID number (default -1)
    5. weaponID number (default -1)
    6. impulseX number (optional)
    7. impulseY number (optional)
    8. impulseZ number (optional)

    Returns:

    1. nil

    Spring.AddUnitImpulse(unitID, x, y, z[, decayRate])

    Parameters:

    1. unitID number
    2. x number
    3. y number
    4. z number
    5. decayRate number (optional)

    Returns:

    1. nil

    Spring.AddUnitSeismicPing(unitID, pindSize)

    Parameters:

    1. unitID number
    2. pindSize number

    Returns:

    1. nil

    Spring.AddUnitResource(unitID, resource, amount)

    Parameters:

    1. unitID number
    2. resource string "m" | "e"
    3. amount number

    Returns:

    1. nil

    Spring.UseUnitResource(unitID, resource, amount)

    Parameters:

    1. unitID number
    2. resource string "m" | "e"
    3. amount number

    Returns:

    1. nil or bool okay

    Spring.UseUnitResource(unitID, resources)

    Parameters:

    1. unitID number
    2. resources {[string]=number,...} where keys are one of "m"|"metal"|"e"|"energy" and values are amounts

    Returns:

    1. nil or bool okay

    Decals


    Spring.AddObjectDecal(unitID)

    Parameters:

    1. unitID number

    Returns:

    1. nil

    Spring.RemoveObjectDecal(unitID)

    Parameters:

    1. unitID number

    Returns:

    1. nil

    Grass


    Spring.AddGrass(x, z)

    Parameters:

    1. x number
    2. z number

    Returns:

    1. nil

    Spring.RemoveGrass(x, z)

    Parameters:

    1. x number
    2. z number

    Returns:

    1. nil

    Feature Handling


    Spring.CreateFeature(featureDef, x, y, z[, heading[, AllyTeamID[, featureID]]])

    Parameters:

    1. featureDef string or number name or id
    2. x number
    3. y number
    4. z number
    5. heading number (optional)
    6. AllyTeamID number (optional)
    7. featureID number (optional)

    Returns:

    1. number featureID

    Spring.DestroyFeature(featureDefID)

    Parameters:

    1. featureDefID number

    Returns:

    1. nil

    Spring.TransferFeature(featureDefID, teamID)

    Feature Control

    Parameters:

    1. featureDefID number
    2. teamID number

    Returns:

    1. nil

    Spring.SetFeatureAlwaysVisible(featureID, enable)

    Parameters:

    1. featureID number
    2. enable bool

    Returns:

    1. nil

    Spring.SetFeatureUseAirLos(featureID, useAirLos)

    Parameters:

    1. featureID number
    2. useAirLos bool

    Returns:

    1. nil

    Spring.SetFeatureHealth(featureID, health)

    Parameters:

    1. featureID number
    2. health number

    Returns:

    1. nil

    Spring.SetFeatureMaxHealth(featureID, maxHealth)

    Parameters:

    1. featureID number
    2. maxHealth number minimum 0.1

    Returns:

    1. nil

    Spring.SetFeatureReclaim(featureID, reclaimLeft)

    Parameters:

    1. featureID number
    2. reclaimLeft number

    Returns:

    1. nil

    Spring.SetFeatureResources(featureID, metal, energy[, reclaimTime[, reclaimLeft[, featureDefMetal[, featureDefEnergy]]]])

    Parameters:

    1. featureID number
    2. metal number
    3. energy number
    4. reclaimTime number (optional)
    5. reclaimLeft number (optional)
    6. featureDefMetal number (optional)
    7. featureDefEnergy number (optional)

    Returns:

    1. 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:

    1. featureID number
    2. unitDef string or number id or name
    3. facing string or number (optional)
    4. progress number (optional)

    Returns:

    1. 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:

    1. featureID number
    2. enable bool (optional)
    3. arg1 number (optional)
    4. arg2 number (optional)
    5. argn number (optional)

    Returns:

    1. nil

    Spring.SetFeaturePhysics(featureID, posX, posY, posZ, velX, velY, velZ, rotX, rotY, rotZ, dragX, dragY, dragZ)

    Parameters:

    1. featureID number
    2. posX number
    3. posY number
    4. posZ number
    5. velX number
    6. velY number
    7. velZ number
    8. rotX number
    9. rotY number
    10. rotZ number
    11. dragX number
    12. dragY number
    13. dragZ number

    Returns:

    1. nil

    Spring.SetFeatureMass(featureID, mass)

    Parameters:

    1. featureID number
    2. mass number

    Returns:

    1. nil

    Spring.SetFeaturePosition(featureID, x, y, z[, snapToGround])

    Parameters:

    1. featureID number
    2. x number
    3. y number
    4. z number
    5. snapToGround bool (optional)

    Returns:

    1. nil

    Spring.SetFeatureRotation(featureID, rotX, rotY, rotZ)

    Parameters:

    1. featureID number
    2. rotX number
    3. rotY number
    4. rotZ number

    Returns:

    1. nil

    Spring.SetFeatureDirection(featureID, dirX, dirY, dirZ)

    Parameters:

    1. featureID number
    2. dirX number
    3. dirY number
    4. dirZ number

    Returns:

    1. 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:

    1. featureID number
    2. heading number
    3. upx number
    4. upy number
    5. upz number

    Returns:

    1. nil

    Spring.SetFeatureVelocity(featureID, velX, velY, velZ)

    Parameters:

    1. featureID number
    2. velX number
    3. velY number
    4. velZ number

    Returns:

    1. nil

    Spring.SetFeatureBlocking(featureID, isBlocking, isSolidObjectCollidable, isProjectileCollidable, isRaySegmentCollidable, crushable, blockEnemyPushing, blockHeightChanges)

    Parameters:

    1. featureID number
    2. isBlocking bool
    3. isSolidObjectCollidable bool
    4. isProjectileCollidable bool
    5. isRaySegmentCollidable bool
    6. crushable bool
    7. blockEnemyPushing bool
    8. blockHeightChanges bool

    Returns:

    1. nil

    Spring.SetFeatureNoSelect(featureID, noSelect)

    Parameters:

    1. featureID number
    2. noSelect bool

    Returns:

    1. nil

    Spring.SetFeatureMidAndAimPos(featureID, mpX, mpY, mpZ, apX, apY, apZ[, relative])

    Check `Spring.SetUnitMidAndAimPos` for further explanation of the arguments.

    Parameters:

    1. featureID number
    2. mpX number
    3. mpY number
    4. mpZ number
    5. apX number
    6. apY number
    7. apZ number
    8. relative bool (optional)

    Returns:

    1. bool success

    Spring.SetFeatureRadiusAndHeight(featureID, radius, height)

    Parameters:

    1. featureID number
    2. radius number
    3. height number

    Returns:

    1. bool success

    Spring.SetFeatureCollisionVolumeData(featureID, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, vType, tType, Axis)

    Check `Spring.SetUnitCollisionVolumeData` for further explanation of the arguments.

    Parameters:

    1. featureID number
    2. scaleX number
    3. scaleY number
    4. scaleZ number
    5. offsetX number
    6. offsetY number
    7. offsetZ number
    8. vType number
    9. tType number
    10. Axis number

    Returns:

    1. nil

    Spring.SetFeaturePieceCollisionVolumeData(featureID, pieceIndex, enable, scaleX, scaleY, scaleZ, offsetX, offsetY, offsetZ, Axis, volumeType[, primaryAxis])

    Parameters:

    1. featureID number
    2. pieceIndex number
    3. enable bool
    4. scaleX number
    5. scaleY number
    6. scaleZ number
    7. offsetX number
    8. offsetY number
    9. offsetZ number
    10. Axis number
    11. volumeType number
    12. primaryAxis number (optional)

    Returns:

    1. nil

    Spring.SetFeaturePieceVisible(featureID, pieceIndex, visible)

    Parameters:

    1. featureID number
    2. pieceIndex number
    3. visible bool

    Returns:

    1. nil

    Projectiles


    projectileParams

    Fields:

    1. pos
      • x number
      • y number
      • z number
    2. end
      • x number
      • y number
      • z number
    3. speed
      • x number
      • y number
      • z number
    4. spread
      • x number
      • y number
      • z number
    5. error
      • x number
      • y number
      • z number
    6. owner number
    7. team number
    8. ttl number
    9. gravity number
    10. tracking number
    11. maxRange number
    12. startAlpha number
    13. endAlpha number
    14. model string
    15. cegTag string

    Spring.SetProjectileAlwaysVisible(projectileID, alwaysVisible)

    Parameters:

    1. projectileID number
    2. alwaysVisible bool

    Returns:

    1. nil

    Spring.SetProjectileUseAirLos(projectileID, useAirLos)

    Parameters:

    1. projectileID number
    2. useAirLos bool

    Returns:

    1. nil

    Spring.SetProjectileMoveControl(projectileID, enable)

    Disables engine movecontrol, so lua can fully control the physics.

    Parameters:

    1. projectileID number
    2. enable bool

    Returns:

    1. nil

    Spring.SetProjectilePosition(projectileID[, posX=0[, posY=0[, posZ=0]]])

    Parameters:

    1. projectileID number
    2. posX number (default 0)
    3. posY number (default 0)
    4. posZ number (default 0)

    Returns:

    1. nil

    Spring.SetProjectileVelocity(projectileID[, velX=0[, velY=0[, velZ=0]]])

    Parameters:

    1. projectileID number
    2. velX number (default 0)
    3. velY number (default 0)
    4. velZ number (default 0)

    Returns:

    1. nil

    Spring.SetProjectileCollision(projectileID)

    Parameters:

    1. projectileID number

    Returns:

    1. 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:

    1. projectileID number
    2. arg1 number targetID or posX (default 0)
    3. arg2 number targetType or posY (default 0)
    4. posZ number (default 0)

    Returns:

    1. nil or bool validTarget

    Spring.SetProjectileIsIntercepted(projectileID)

    Parameters:

    1. projectileID number

    Returns:

    1. nil

    Spring.SetProjectileDamages(unitID, weaponNum, key, value)

    Parameters:

    1. unitID number
    2. weaponNum number
    3. key string
    4. value number

    Returns:

    1. nil

    Spring.SetProjectileIgnoreTrackingError(projectileID, ignore)

    Parameters:

    1. projectileID number
    2. ignore bool

    Returns:

    1. nil

    Spring.SetProjectileGravity(projectileID[, grav=0])

    Parameters:

    1. projectileID number
    2. grav number (default 0)

    Returns:

    1. nil

    Spring.SetPieceProjectileParams(projectileID[, explosionFlags[, spinAngle[, spinSpeed[, spinVectorX[, spinVectorY[, spinVectorZ]]]]]])

    Parameters:

    1. projectileID number
    2. explosionFlags number (optional)
    3. spinAngle number (optional)
    4. spinSpeed number (optional)
    5. spinVectorX number (optional)
    6. spinVectorY number (optional)
    7. spinVectorZ number (optional)

    Returns:

    1. 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:

    1. right bool Right mouse key pressed
    2. alt bool Alt key pressed
    3. ctrl bool Ctrl key pressed
    4. shift bool Shift key pressed

    cmdSpec

    Command spec

    Used when assigning multiple commands at once

    Fields:

    1. cmdID number
    2. params {number,...}
    3. options cmdOpts

    Spring.UnitFinishCommand(unitID)

    Parameters:

    1. unitID number

    Returns:

    1. nil

    Spring.GiveOrderToUnit(unitID, cmdID, params, options)

    Parameters:

    1. unitID number
    2. cmdID number
    3. params {number,...}
    4. options cmdOpts

    Returns:

    1. bool unitOrdered

    Spring.GiveOrderToUnitMap(unitMap, cmdID, params, options)

    Parameters:

    1. unitMap {[number]=table,...} table with unitIDs as keys
    2. cmdID number
    3. params {number,...}
    4. options cmdOpts

    Returns:

    1. number unitsOrdered

    Spring.GiveOrderToUnitArray(unitIDs, cmdID, params, options)

    Parameters:

    1. unitIDs {number,...}
    2. cmdID number
    3. params {number,...}
    4. options cmdOpts

    Returns:

    1. number unitsOrdered

    Spring.GiveOrderArrayToUnit(unitID, cmdArray)

    Parameters:

    1. unitID number
    2. cmdArray {cmdSpec,...}

    Returns:

    1. bool ordersGiven

    Spring.GiveOrderArrayToUnitMap(unitMap, orderArray)

    Parameters:

    1. unitMap {[number]=table} table with unitIDs as keys
    2. orderArray {cmdSpec,...}

    Returns:

    1. number unitsOrdered

    Spring.GiveOrderArrayToUnitArray(unitArray, orderArray)

    Parameters:

    1. unitArray {number,...} containing unitIDs
    2. orderArray {cmdSpec,...}

    Returns:

    1. nil

    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:

    1. x1 number
    2. z1 number
    3. x2_height number if y2 and height are nil then this parameter is the height
    4. z2 number (optional)
    5. height number (optional)

    Returns:

    1. nil

    Spring.AdjustHeightMap(x1, y1, x2_height[, y2[, height]])

    Add a certain height to a point or rectangle area on the world

    Parameters:

    1. x1 number
    2. y1 number
    3. x2_height number if y2 and height are nil then this parameter is the height
    4. y2 number (optional)
    5. height number (optional)

    Returns:

    1. nil

    Spring.RevertHeightMap(x1, y1, x2_factor[, y2[, factor]])

    Restore original map height to a point or rectangle area on the world

    Parameters:

    1. x1 number
    2. y1 number
    3. x2_factor number if y2 and factor are nil then this parameter is the factor
    4. y2 number (optional)
    5. factor number (optional)

    Returns:

    1. nil

    Spring.AddHeightMap(x, z, height)

    Can only be called in `Spring.SetHeightMapFunc`

    Parameters:

    1. x number
    2. z number
    3. height number

    Returns:

    1. nil or number newHeight

    Spring.SetHeightMap(x, z, height[, terraform=1])

    Can only be called in `Spring.SetHeightMapFunc`. The terraform argument is

    Parameters:

    1. x number
    2. z number
    3. height number
    4. terraform number a scaling factor. (default 1)

    Returns:

    1. 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:

    1. lua_function func
    2. arg1 (optional)
    3. arg2 (optional)
    4. argn (optional)

    Returns:

    1. 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:

    1. x1 number
    2. y1 number
    3. x2_height number if y2 and height are nil then this parameter is the height
    4. y2 number (optional)
    5. height number (optional)

    Returns:

    1. nil

    Spring.AdjustOriginalHeightMap(x1, y1, x2_height[, y2[, height]])

    Add height to a point or rectangle area to the original map height cache

    Parameters:

    1. x1 number
    2. y1 number
    3. x2_height number if y2 and height are nil then this parameter is the height
    4. y2 number (optional)
    5. height number (optional)

    Returns:

    1. nil

    Spring.RevertOriginalHeightMap(x1, y1, x2_factor[, y2[, factor]])

    Restore original map height cache to a point or rectangle area on the world

    Parameters:

    1. x1 number
    2. y1 number
    3. x2_factor number if y2 and factor are nil then this parameter is the factor
    4. y2 number (optional)
    5. factor number (optional)

    Returns:

    1. nil

    Spring.AddOriginalHeightMap(x, y, height)

    Can only be called in `Spring.SetOriginalHeightMapFunc`

    Parameters:

    1. x number
    2. y number
    3. height number

    Returns:

    1. nil

    Spring.SetOriginalHeightMap(x, y, height[, factor])

    Can only be called in `Spring.SetOriginalHeightMapFunc`

    Parameters:

    1. x number
    2. y number
    3. height number
    4. factor number (optional)

    Returns:

    1. nil

    Spring.SetOriginalHeightMapFunc(heightMapFunc)

    Cannot recurse on itself

    Parameters:

    1. heightMapFunc func

    Returns:

    1. nil

    Spring.RebuildSmoothMesh()

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

    Returns:

    1. nil

    Spring.LevelSmoothMesh(x1, z1[, x2][, z2], height)

    Parameters:

    1. x1 number
    2. z1 number
    3. x2 number (optional)
    4. z2 number (optional)
    5. height number

    Returns:

    1. nil

    Spring.AdjustSmoothMesh(x1, z1[, x2][, z2], height)

    Parameters:

    1. x1 number
    2. z1 number
    3. x2 number (optional)
    4. z2 number (optional)
    5. height number

    Returns:

    1. nil

    Spring.RevertSmoothMesh(x1, z1[, x2][, z2], origFactor)

    Parameters:

    1. x1 number
    2. z1 number
    3. x2 number (optional)
    4. z2 number (optional)
    5. origFactor number

    Returns:

    1. nil

    Spring.AddSmoothMesh(x, z, height)

    Can only be called in `Spring.SetSmoothMeshFunc`.

    Parameters:

    1. x number
    2. z number
    3. height number

    Returns:

    1. nil or number newHeight

    Spring.SetSmoothMesh(x, z, height[, terraform=1])

    Can only be called in `Spring.SetSmoothMeshFunc`.

    Parameters:

    1. x number
    2. z number
    3. height number
    4. terraform number (default 1)

    Returns:

    1. nil or number absHeightDiff

    Spring.SetSmoothMeshFunc(lua_function, arg1, arg2, argn)

    Parameters:

    1. lua_function func
    2. arg1 [opt]
    3. arg2 [opt]
    4. argn [opt]

    Returns:

    1. nil or number absTotalHeightMapAmountChanged

    TerrainTypes


    Spring.SetMapSquareTerrainType(x, z, newType)

    Parameters:

    1. x number
    2. z number
    3. newType number

    Returns:

    1. nil or number oldType

    Spring.SetTerrainTypeData(typeIndex[, speedTanks=nil[, speedKBOts=nil[, speedHovers=nil[, speedShips=nil]]]])

    Parameters:

    1. typeIndex number
    2. speedTanks number (default nil)
    3. speedKBOts number (default nil)
    4. speedHovers number (default nil)
    5. speedShips number (default nil)

    Returns:

    1. nil or bool true

    Spring.SetSquareBuildingMask(x, z, mask)

    Parameters:

    1. x number
    2. z number
    3. mask number

    Returns:

    1. nil See also buildingMask unitdef tag.

    Spring.UnitWeaponFire(unitID, weaponID)

    Parameters:

    1. unitID number
    2. weaponID number

    Returns:

    1. nil

    Spring.UnitAttach(transporterID, passengerID, pieceNum)

    Parameters:

    1. transporterID number
    2. passengerID number
    3. pieceNum number

    Returns:

    1. nil

    Spring.UnitDetach(passengerID)

    Parameters:

    1. passengerID number

    Returns:

    1. nil

    Spring.UnitDetachFromAir(passengerID)

    Parameters:

    1. passengerID number

    Returns:

    1. nil

    Spring.SetUnitLoadingTransport(passengerID, transportID)

    Disables collisions between the two units to allow colvol intersection during the approach.

    Parameters:

    1. passengerID number
    2. transportID number

    Returns:

    1. nil

    Spring.SpawnProjectile(weaponDefID, projectileParams)

    Parameters:

    1. weaponDefID number
    2. projectileParams projectileParams

    Returns:

    1. nil or number projectileID

    Spring.DeleteProjectile(projectileID)

    Silently removes projectiles (no explosion).

    Parameters:

    1. projectileID number

    Returns:

    1. 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:

    1. weaponDef number
    2. owner number
    3. hitUnit number
    4. hitFeature number
    5. craterAreaOfEffect number
    6. damageAreaOfEffect number
    7. edgeEffectiveness number
    8. explosionSpeed number
    9. gfxMod number
    10. impactOnly bool
    11. ignoreOwner bool
    12. damageGround bool

    Spring.SpawnExplosion([posX=0][, posY=0][, posZ=0][, dirX=0][, dirY=0][, dirZ=0], explosionParams)

    Parameters:

    1. posX number (default 0)
    2. posY number (default 0)
    3. posZ number (default 0)
    4. dirX number (default 0)
    5. dirY number (default 0)
    6. dirZ number (default 0)
    7. explosionParams explosionParams

    Returns:

    1. nil

    Spring.SpawnCEG(cegname[, posX=0[, posY=0[, posZ=0[, dirX=0[, dirY=0[, dirZ=0[, radius=0[, damage=0]]]]]]]])

    Parameters:

    1. cegname string
    2. posX number (default 0)
    3. posY number (default 0)
    4. posZ number (default 0)
    5. dirX number (default 0)
    6. dirY number (default 0)
    7. dirZ number (default 0)
    8. radius number (default 0)
    9. damage number (default 0)

    Returns:

    1. nil or bool success
    2. 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:

    1. unitID number (default 0)
    2. sfxID number (default 0)
    3. posX number (default 0)
    4. posY number (default 0)
    5. posZ number (default 0)
    6. dirX number (default 0)
    7. dirY number (default 0)
    8. dirZ number (default 0)
    9. radius number (default 0)
    10. damage number (default 0)
    11. absolute bool (optional)

    Returns:

    1. nil or bool success

    Other


    Spring.SetNoPause(noPause)

    Parameters:

    1. noPause bool

    Returns:

    1. nil

    Spring.SetExperienceGrade(expGrade[, ExpPowerScale[, ExpHealthScale[, ExpReloadScale]]])

    Defines how often `Callins.UnitExperience` will be called.

    Parameters:

    1. expGrade number
    2. ExpPowerScale number (optional)
    3. ExpHealthScale number (optional)
    4. ExpReloadScale number (optional)

    Returns:

    1. nil

    Spring.SetRadarErrorParams(allyTeamID, allyteamErrorSize[, baseErrorSize[, baseErrorMult]])

    Parameters:

    1. allyTeamID number
    2. allyteamErrorSize number
    3. baseErrorSize number (optional)
    4. baseErrorMult number (optional)

    Returns:

    1. nil

    Command Descriptions

    Doesn't work in unsynced code!


    Spring.EditUnitCmdDesc(unitID, cmdDescID, cmdArray)

    Parameters:

    1. unitID number
    2. cmdDescID number
    3. cmdArray table

      structure 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:

    1. nil

    Spring.InsertUnitCmdDesc(unitID[, cmdDescID], cmdArray)

    Parameters:

    1. unitID number
    2. cmdDescID number (optional)
    3. cmdArray table

    Returns:

    1. nil

    Spring.RemoveUnitCmdDesc(unitID[, cmdDescID])

    Parameters:

    1. unitID number
    2. cmdDescID number (optional)

    Returns:

    1. nil