User:Master-athmos: Difference between revisions

From Spring
Jump to navigationJump to search
No edit summary
Replaced content with "Development < Lua Scripting < {{FULLPAGENAME}} <span class="warning">These functions are ONLY available if the graphic board supp..."
 
(47 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Engine_Development|Development]] < [[Lua_Scripting|Lua Scripting]] < {{FULLPAGENAME}}
[[Engine_Development|Development]] < [[Lua_Scripting|Lua Scripting]] < {{FULLPAGENAME}}


<span class="warning">These functions are ONLY available if the graphic board supports GLSL.<br><br> Please test in your scripts if one of them exists before you use them!</span>


{{LuaCallout
|prefix = Spring.
|name = SetUnitBlocking
|arg1 = {{type|number}} unitID
|arg2 = {{type|boolean}} isBlocking
|arg3 = {{type|boolean}} isSolidObjectCollidable
|arg4 = {{type|boolean}} isProjectileCollidable
|arg5 = {{type|boolean}} isRaySegmentCollidable
|arg6 = {{type|boolean}} crushable
|arg7 = {{type|boolean}} blockEnemyPushing
|arg8 = {{type|boolean}} blockHeightChanges
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}


'''gl.CreateShader'''
  ({[ vertex  = "glsl code" ,]
    [ tcs      = "glsl code" ,]
    [ tes      = "glsl code" ,]
    [ geometry = "glsl code" ,]
    [ fragment = "glsl code" ,]
    [ uniform      = { uniformName = number value, ...} ,] <span class=note>(specify a Lua array as an argument to uniformName to initialize GLSL arrays)</span>
    [ uniformInt    = { uniformName = number value, ...} ,] <span class=note>(specify a Lua array as an argument to uniformName to initialize GLSL arrays)</span>
    [ uniformFloat  = { uniformName = number value, ...} ,] <span class=note>(specify a Lua array as an argument to uniformName to initialize GLSL arrays)</span>
    [ uniformMatrix = { uniformName = number value, ...} ,]
    [ geoInputType = number inType,]
    [ geoOutputType = number outType,]
    [ geoOutputVerts = number maxVerts,]
    [ definitions = "string of shader #defines", ]
  }) -> number shaderID


{{LuaCallout
* The "Vertex" or vertex-shader is your GLSL-Code as string, its written in a C-Dialect. This shader is busy deforming the geometry of a unit but it can not create new polygons. Use it for waves, wobbling surfaces etc.
|prefix = Spring.
|name = SetUnitBuildSpeed
* The "Geometry" or Geometry-shader can create new vertices and vertice-stripes from points.
|arg1 = {{type|number}} builderID
|arg2 = {{type|number}} buildSpeed
|arg3 = {{bracket|{{type|number}} repairSpeed}}
|arg4 = {{bracket|{{type|number}} reclaimSpeed}}
|arg5 = {{bracket|{{type|number}} resurrectSpeed}}
|arg6 = {{bracket|{{type|number}} captureSpeed}}
|arg7 = {{bracket|{{type|number}} terraformSpeed}}
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}


* The "TCS" or Tesselation Control Shader controls how much tessellation a particular patch gets; it also defines the size of a patch, thus allowing it to augment data. It can also filter vertex data taken from the vertex shader. The main purpose of the TCS is to feed the tessellation levels to the Tessellation primitive generator stage, as well as to feed patch data (as its output values) to the Tessellation Evaluation Shader stage. TCS shader can be used with spring version >= 104.0.1-596 (maintenance), it's also available in develop branch of spring.


{{LuaCallout
* The "TES" or Tesselation Evaluation Shader takes the abstract patch generated by the tessellation primitive generation stage, as well as the actual vertex data for the entire patch, and generates a particular vertex from it. Each TES invocation generates a single vertex. It can also take per-patch data provided by the Tessellation Control Shader. TES shader can be used with spring version >= 104.0.1-596 (maintenance), it's also available in develop branch of spring.
|prefix = Spring.
|name = SetUnitBuildSpeed
|arg1 = {{type|number}} builderID
|arg2 = {{type|number}} buildSpeed
|arg3 = {{bracket}}{{type|number}} repairSpeed
|arg4 = {{bracket}}{{type|number}} reclaimSpeed
|arg5 = {{bracket}}{{type|number}} resurrectSpeed
|arg6 = {{bracket}}{{type|number}} captureSpeed
|arg7 = {{bracket}}{{type|number}} terraformSpeed {{rbracket}}{{rbracket}}{{rbracket}}{{rbracket}}{{rbracket}}
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}


[[Engine_Development|Development]] < [[Lua_Scripting|Lua Scripting]] < {{FULLPAGENAME}}
* The "Fragment" or Fragment-shader (sometimes called pixel-Shader) is post processing the allready rendered picture (for example drawing stars on the sky)- remember textures are not always 2 dimensional pictures. They can contain information about the depth, or the third value marks areas and the strength at which these are processed.


= Game End =
* The Uniforms are the values, you send along with the shader-program. To use them in the shader-program declare them like this:
<syntaxhighlight lang="c">uniform float frame;</syntaxhighlight>


{{LuaCallout
* From 101.0 onwards, the engine will automatically fill in an appropriately named uniform for team colour if it is declared;
|prefix = Spring.
<syntaxhighlight lang="c">uniform vec4 teamColor;</syntaxhighlight>
|name = KillTeam
|arg1 = {{type|number}} teamID
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|83.0}}<br> Will declare a team to be dead ( no further orders can be assigned to such teams's units ), Gaia team cannot be killed.
}}


'''gl.DeleteShader'''
  ( number shaderID ) -> nil


{{LuaCallout
'''gl.ActiveShader''' <font color="#55ee99">can be used in NON-drawing events (to update uniforms etc.)!</font>
|prefix = Spring.
  ( number shaderID, function [, arg1 [, arg2, ..]] ) -> nil
|name = GameOver
|arg1 = {{type|number}} allyTeamID1
|arg2 = {{type|number}} allyTeamID2
|arg3 = ...
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|83.0}}<br> 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.
}}


= RulesParams =
'''gl.UseShader'''
<span class=warning>String values are new since 95.0. Attention: Numeric paramValues in quotes will be converted to number.</span>
  ( number shaderID ) -> boolean linked


{{LuaCallout
'''gl.GetShaderLog'''
|prefix = Spring.
  ( ) -> string "infoLog"
|name = SetUnitRulesParam
|arg1 = {{type|number}} unitID
|arg2 = {{type|string}} paramName
|arg3 = {{type|number{{pipe}}string}} paramValue {{bracket}}
|arg4 = {{type|table}} losAccess {{rbracket}}
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <span class=note>Possible keys for the losAccess table are:
    `private` : only readable by the ally (default)
    `allied`  : readable by ally + ingame allied
    `inlos`  : readable if the unit is in LOS
    `inradar` : readable if the unit is in AirLOS
    `public`  : readable by all
  note: if one condition is fulfilled all beneath it are too (e.g. if an unit is in LOS it<br/>    can read params with `inradar=true` even if the param has `inlos=false`)
  note2: all GameRulesParam are public, TeamRulesParams can just be `private`,`allied`<br/>    and/or `public`
  note3: You can read RulesParams from '''any''' Lua enviroments! With those losAccess<br/>     policies you can limit their access.</span>
}}


'''gl.SetShaderParameter'''
<font color="#ff0000">Renamed to SetGeometryShaderParameter in spring version >= 104.0.1-596 (maintenance).</font>
<font color="#55ee99">needed by geometry shader programs (check the opengl GL_ARB_geometry_shader4 extension for glProgramParameteri)</font>
  ( number shaderID, number param, number value ) -> nil


{{LuaCallout
'''gl.SetTesselationShaderParameter'''
|prefix = Spring.
<font color="#0000ee">Available for spring versions >= 104.0.1-596 (maintenance).</font>
|name = SetFeatureRulesParam
<font color="#55ee99">needed by tesselation shader programs (check the opengl GL_ARB_tessellation_shader extension for glProgramParameteri)</font>
|arg1 = {{type|number}} featureID
  ( number param, number value ) -> nil
|arg2 = {{type|string}} paramName
|arg3 = {{type|number{{pipe}}string}} paramValue {{bracket}}
|arg4 = {{type|table}} losAccess {{rbracket}}
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <span class=warning>New since 102.0.</span><br>See above for further documentation of losAccess.
}}


 
'''gl.GetActiveUniforms'''
{{LuaCallout
   ( number shaderID ) -> {  
|prefix = Spring.
       [1] = { name = "name", type = "type", length = number length, size = number size },
|name = SetTeamRulesParam
       ...
|arg1 = {{type|number}} teamID
|arg2 = {{type|string}} paramName
|arg3 = {{type|number{{pipe}}string}} paramValue {{bracket}}
|arg4 = {{type|table}} losAccess {{rbracket}}
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = See above for further documentation of losAccess.
}}
 
 
 
{{LuaCallout
|prefix = Spring.
|name = SetGameRulesParam
|arg1 = {{type|string}} paramName
|arg2 = {{type|number{{pipe}}string}} paramValue {{bracket}}
|arg3 = {{type|table}} losAccess {{rbracket}}
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = See above for further documentation of losAccess.
}}
 
= Resources =
 
{{LuaCallout
|prefix = Spring.
|name = AddTeamResource
|arg1 = {{type|number}} teamID
|arg2 = {{type|string}} "metal" {{pipe}} "energy"
|arg3 = {{type|number}} amount
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = Adds metal or energy resources to the specified team.
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = UseTeamResource
|arg1 = {{type|number}} teamID
|arg2 = {{type|string}} "metal" {{pipe}} "energy"
|arg3 = {{type|number}} amount {{pipe}} { metal = {{type|number}} amount, energy = {{type|number}} amount }
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} hadEnough
|info = Consumes metal and/or energy resources of the specified team.
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetTeamResource
|arg1 = {{type|number}} teamID
|arg2 = {{type|string}} res
|arg3 = {{type|number}} amount
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = Possible values for res are:<br>"m"  = metal<br>"e"  = energy<br>"ms"  = metal storage<br>"es"  = energy storage<br>
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetTeamShareLevel
|arg1 = {{type|number}} teamID
|arg2 = {{type|string}} "metal" {{pipe}} "energy"
|arg3 = {{type|number}} amount
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = Changes the resource amount for a team beyond which resources aren't stored but transferred to other allied teams if possible.
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = ShareTeamResource
|arg1 = {{type|number}} teamID_src
|arg2 = {{type|number}} teamID_recv
|arg3 = {{type|string}} "metal" {{pipe}} "energy"
|arg4 = {{type|number}} amount
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = Transfers resources between two teams.
}}
 
= Teams =
 
 
{{LuaCallout
|prefix = Spring.
|name = SetAlly
|arg1 = {{type|number}} firstAllyTeamID
|arg2 = {{type|number}} secondAllyTeamID
|arg3 = {{type|bool}} ally
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|98.0}}<br>Changes the value of the (one-sided) alliance between: firstAllyTeamID -> secondAllyTeamID.
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = AssignPlayerToTeam
|arg1 = {{type|number}} playerID
|arg2 = {{type|number}} teamID
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|98.0}}<br>Assigns a player to a team.
}}
 
 
 
{{LuaCallout
|prefix = Spring.
|name = SetGlobalLos
|arg1 = {{type|number}} allyTeamID
|arg2 = {{type|bool}} globallos
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|101.0}}<br>Changes access to global line of sight for a team and its allies.
}}
 
= Unit Handling =
 
{{LuaCallout
|prefix = Spring.
|name = CreateUnit
|arg1 = {{type|string}} "defName" {{pipe}} {{type|number }} unitDefID
|arg2 = {{type|number}} x
|arg3 = {{type|number}} y
|arg4 = {{type|number}} z
|arg5 = {{type|string}} "facing" {{pipe}} {{type|number }} facing
|arg6 = {{type|number}} teamID {{bracket}}
|arg7 = {{type|bool}} build = false {{bracket}}
|arg8 = {{type|bool}} flattenGround = true {{bracket}}
|arg9 = {{type|number}} builderID {{rbracket}}{{rbracket}}{{rbracket}}
|return = {{type|number}} unitID {{pipe}} {{type|nil}} (meaning unit was not created)
|info = Offmap positions are clamped! Use MoveCtrl to move to such positions.<br>Possible values for facing are:<br>"south" {{pipe}} "s" {{pipe}} 0<br>"east"  {{pipe}} "e" {{pipe}} 1<br>"north" {{pipe}} "n" {{pipe}} 2<br>"west"  {{pipe}} "w" {{pipe}} 3<br><br>If build is true, the unit is created in "being built" state with buildProgress = 0<br>unitID and builderID are {{new|92.0}}, the former allowing to spawn a unit with a specific ID.
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = DestroyUnit
|arg1 = {{type|number}} unitID {{bracket}}
|arg2 = {{type|bool}} selfd = false {{bracket}}
|arg3 = {{type|bool}} reclaimed = false {{bracket}}
|arg4 = {{type|number}} attackerID {{rbracket}}{{rbracket}}{{rbracket}}
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = selfd := Makes the unit act like it self-destructed.<br>reclaimed := Don't show any DeathSequences, don't leave a wreckage. This does not give back the resources to the team!
}}
 
 
 
{{LuaCallout
|prefix = Spring.
|name = TransferUnit
|arg1 = {{type|number}} unitID
|arg2 = {{type|number}} newTeamID {{bracket}}
|arg3 = {{type|bool}} given = true {{rbracket}}
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = If given=false, the unit is captured.
}}
 
== Unit Control ==
 
{{LuaCallout
|prefix = Spring.
|name = SetUnitCosts
|arg1 = {{type|number}} unitID
|arg2 = { {{bracket}} buildTime = {{type|number}} amount {{rbracket}}
|arg3 = {{bracket}} metalCost = {{type|number}} amount  {{rbracket}}
|arg4 = {{bracket}} energyCost = {{type|number}} amount {{rbracket}} }
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetUnitTooltip
|arg1 = {{type|number}} unitID
|arg2 = {{type|string}} "tooltip"
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
 
{{LuaCallout
|prefix = Spring.
|name = SetUnitHealth
|arg1 = {{type|number}} unitID
|arg2 = {{type|number}} health {{pipe}} { {{bracket}} health = {{type|number}} health {{rbracket}}
|arg3 = {{bracket}} capture  = {{type|number}} capture  {{rbracket}}
|arg4 = {{bracket}} paralyze = {{type|number}} paralyze {{rbracket}}
|arg5 = {{bracket}} build    = {{type|number}} build {{rbracket}} }
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetUnitMaxHealth
|arg1 = {{type|number}} unitID
|arg2 = {{type|number}} maxHealth
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = AddUnitDamage
|arg1 = {{type|number}} unitID
|arg2 = {{type|number}} damage {{bracket}}
|arg3 = {{type|number}} paralyze = 0 {{bracket}}
|arg4 = {{type|number}} attackerID = -1 {{bracket}}
|arg5 = {{type|number}} weaponID = -1 {{bracket}}
|arg6 = {{type|number}} impulse_x {{bracket}}
|arg7 = {{type|number}} impulse_y {{bracket}}
|arg8 = {{type|number}} impulse_z {{rbracket}}{{rbracket}}{{rbracket}}{{rbracket}}{{rbracket}}{{rbracket}}
|arg9 =
|return = {{type|nil}}
|info = The number in the paralyze parameter equals to the paralyzetime in the WeaponDef.
}}
 
 
 
 
'''Spring.SetUnitStockpile'''
  ( number unitID [, number stockpile [, number buildPercent ]]) -> nil
 
'''Spring.SetUnitExperience'''
  ( number unitID, number experience ) -> nil
 
'''Spring.SetUnitFuel''' {{removed|101.0}}
  ( number unitID, number fuel ) -> nil
 
'''Spring.SetUnitCrashing''' {{new|83.0}}
  ( number unitID, boolean crashing ) -> boolean success
 
'''Spring.SetUnitLineage''' {{removed|83.0}}
  ( number unitID, number teamID [, boolean isRoot] ) -> nil
 
'''Spring.SetUnitNeutral'''
  ( number unitID, boolean neutral ) -> nil
 
'''Spring.SetUnitTarget''' <span class="warning">userTarget & success new in version 95.0, setting nil target new in 99.0, weaponNum new in 102.0</span>
  ( number unitID,
    number enemyUnitID | number x, number y, number z, | nil,
    [ boolean dgun = false [, boolean userTarget = false [, number weaponNum = -1 ]]] ) ->  success
 
'''Spring.SetUnitMaxRange'''
  ( number unitID, number maxRange ) -> nil
 
'''Spring.SetUnitMass''' {{new|101.0}}
  ( number unitID, number mass ) -> nil
 
'''Spring.SetUnitBlocking''' <span class="warning">crushable new in version 85.0</span>
  ( number unitID, boolean blocking [, boolean collide [, boolean crushable]] ) -> nil
 
'''Spring.SetUnitBlocking''' {{new|95.0}} changed parameters:
  number unitID,
  boolean isBlocking,
  boolean isSolidObjectCollidable,
  boolean isProjectileCollidable,
  boolean isRaySegmentCollidable,
  boolean crushable,
  boolean blockEnemyPushing,
  boolean blockHeightChanges
 
'''Spring.SetUnitMetalExtraction''' <span class="warning">&nbsp;&nbsp;&nbsp;"depth" corresponds to metal extraction rate (value range similar to "extractsMetal" unitDef)</span>
  ( number unitID, number depth [,number range] ) -> nil
 
'''Spring.SetUnitBuildSpeed'''
  ( number builderID,
    number buildSpeed, [ number repairSpeed [, number reclaimSpeed
  [,number resurrectSpeed [, number captureSpeed [, number terraformSpeed ]] ]]] ) -> nil
 
'''Spring.SetUnitNanoPieces''' {{new|92.0}}
  ( number builderID, table pieces ) -> nil
This saves a lot of engine calls, by replacing:
function script.QueryNanoPiece() return currentpiece end
Use it!
 
'''Spring.UnitAttach''' {{new|101.0}}
  ( number transporterID, number passengerID, number pieceNum ) -> nil
 
'''Spring.UnitDetach''' {{new|101.0}}
  ( number passengerID ) -> nil
 
'''Spring.UnitDetachFromAir''' {{new|101.0}}
  ( number passengerID ) -> nil
 
'''Spring.SetUnitLoadingTransport''' {{new|101.0}}
  ( number passengerID, number transportID ) -> nil
 
<span class="note">Disables collisions between the two units to allow colvol intersection during the approach.</span>
 
'''Spring.SetUnitPieceParent''' {{new|101.0}}
  ( number unitID, number AlteredPiece, number ParentPiece ) -> nil
Changes the pieces hierarchy of a unit, by attaching a piece to a new parent.
 
'''Spring.SetUnitPieceMatrix''' {{new|104.0}}
  ( number unitID, number pieceNum, table 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 (matrix should be an array of 16 floats, but is not otherwise sanity-checked).
 
'''Spring.SetUnitArmored''' <span class="warning">armorMultiple new in version 0.83.x</span>
  ( number unitID, boolean armored [, number armorMultiple] ) -> nil
 
'''Spring.SetUnitShieldState'''
  ( number unitID [, number weaponID = -1] [, boolean enabled] [, number power] ) -> nil
 
'''Spring.SetUnitFlanking'''
  ( number unitID, string "mode", number mode ) -> nil
   ( number unitID, string "moveFactor", number factor) -> nil
  ( number unitID, string "minDamage", number minDamage ) -> nil
  ( number unitID, string "mazDamage", number maxDamage ) -> nil
  ( number unitID, string "dir", number x, number y, number z) -> nil
 
'''Spring.SetUnitWeaponState'''
  ( number unitID, number weaponNum, table states ) -> nil
  ( number unitID, number weaponNum, string key, number value ) -> nil
  <span class="note">format of the states table:
    {
       ["reloadState"    = number value,]
      ["reloadFrame"    = number value,] (synonym for reloadState!)
      ["reloadTime"      = number value,]
      ["accuracy"        = number value,]
      ["sprayAngle"      = number value,]
      ["range"          = number value,] (*)
      ["projectileSpeed" = number value,]
      ["burst"          = number value,]
      ["burstRate"      = number value,]
      ["projectiles"    = number value,]
      ["salvoLeft"      = number value,]
      ["nextSalvo"      = number value,]
      ["aimReady"        = number value,] (<>0.0f := true)
    }
  (*) if you change the range of a weapon with dynamic damage
  make sure you use SetUnitWeaponDamages to change dynDamageRange as well.
  </span>
 
'''Spring.SetUnitWeaponDamages''' {{new|101.0}}
  ( number unitID, number weaponNum | "selfDestruct" | "explode", table damages ) -> nil
  ( number unitID, number weaponNum | "selfDestruct" | "explode", string key, number value ) -> nil
  <span class="note">format of the damages table:
  {
      ["paralyzeDamageTime" = number value,] 
      ["impulseFactor"      = number value,]
      ["impulseBoost"      = number value,]
      ["craterMult"        = number value,]
      ["craterBoost"        = number value,]
      ["dynDamageExp"      = number value,]
      ["dynDamageMin"      = number value,]
      ["dynDamageRange"    = number value,]
      ["dynDamageInverted"  = number value,] (<>0.0f := true)
      ["craterAreaOfEffect" = number value,]
      ["damageAreaOfEffect" = number value,]
      ["edgeEffectiveness"  = number value,]
      ["explosionSpeed"    = number value,]
      [number armorType    = number value,] (changes the damage against this armor type)
    }
  </span>
 
'''Spring.SetUnitCollisionVolumeData'''
  ( number unitID, number scaleX, number scaleY, number scaleZ,
    number offsetX, number offsetY, number offsetX,
    number vType, number tType, number Axis
  ) -> nil
  <span class="note">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
    };
  </span>
 
'''Spring.SetUnitPieceCollisionVolumeData'''
  ( number unitID, number pieceIndex, boolean enable,
    number scaleX, number scaleY, number scaleZ,
    number offsetX, number offsetY, number offsetZ
    [, number volumeType [, number primaryAxis]]
  ) -> nil
As of 101.0 this is 1-based piece index argument (was 0-based).
 
'''Spring.SetUnitTravel'''
  ( number unitID, number travel [, number travelPeriod] ) -> nil
 
'''Spring.SetUnitMoveGoal'''  <span class="note">used by default commands to get in build-,attackrange etc.</span>
  (number unitID, number goalx, number goaly, number goalz
  [, number goalRadius [, number moveSpeed [, bool moveRaw ]]] )
{{new|98.0}} <span class="note">moveRaw: [http://springrts.com/mantis/view.php?id=4412 allow unit to dumbly move to a coordinate without calculating path.]</span>
 
'''Spring.SetUnitLandGoal'''  {{new|101.0}}
  (number unitID, number goalx, number goaly, number goalz [, number goalRadius ] ) -> nil
Used in conjunction with {{name|Spring.UnitAttach}} et al to re-implement old airbase & fuel system in lua.
 
'''Spring.ClearUnitGoal''' {{new|102.0}}
  (number unitID) -> nil
 
'''Spring.SetUnitPhysics''' <span class="warning">drag new in version 95.0</span>
  ( number 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,
  ) -> nil
 
'''Spring.SetUnitPosition'''
  ( number unitID, number x, number z [, boolean alwaysAboveSea] ) -> nil
 
'''Spring.SetUnitDirection''' {{new|90.0}}
  ( number unitID, number x, number y, number z ) -> nil
 
'''Spring.SetUnitVelocity'''
  ( number unitID, number velx, number vely, number velz ) -> nil
 
'''Spring.SetUnitRotation'''
  ( number unitID, number rotx, number roty, number rotz ) -> nil
 
'''Spring.AddUnitImpulse'''
  ( number unitID, number x, number y, number z [, decayRate ] ) -> nil
 
'''Spring.AddUnitSeismicPing'''
  ( number unitID, number pingSize ) -> nil
 
'''Spring.RemoveBuildingDecal'''
  ( number unitID ) -> nil
 
'''Spring.SetUnitMidAndAimPos''' {{new|89.0}}
  ( number unitID,
    number mpx, number mpy, number mpz,
    number apx, number apy, number apz,
    [, boolean relative] ) -> boolean success
 
<font color="#55ee99">
mpx, mpy, mpz: new middle position of unit
 
apx, apy, apz: new position that enemies aim at on this unit
 
relative: are the new coordinates relative to world or unit coordinates?
</font>
 
 
'''Spring.SetUnitRadiusAndHeight''' {{new|89.0}}
  ( number unitID, number radius, number height ) -> boolean success
 
'''Spring.UnitWeaponFire'''
  ( number unitID, number weaponID ) -> nil
'''Spring.UnitWeaponHoldFire'''
  ( number unitID, number weaponID ) -> nil
 
== Unit LOS ==
'''Spring.SetUnitCloak'''
  ( number unitID,
    boolean cloaked | number scriptCloak,
    [ number decloakDistance | boolean decloakAbs ] ) -> nil
 
  <font color="#55ee99">
  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.</font>
 
'''Spring.SetUnitSonarStealth'''
  ( number unitID, boolean sonarStealth ) -> nil
 
'''Spring.SetUnitStealth'''
  ( number unitID, boolean stealth ) -> nil
 
'''Spring.SetUnitAlwaysVisible'''
  ( number unitID, boolean alwaysVisible ) -> nil
 
'''Spring.SetUnitLosMask'''
  ( number unitID, number allyTeam, number los | table losTypes ) -> nil
<font color="#55ee99">the 3th argument is either the bit-and combination of the following numbers:
  LOS_INLOS    = 1
  LOS_INRADAR  = 2
  LOS_PREVLOS  = 4
  LOS_CONTRADAR = 8
</font><font color="#55ee99">or a table of the following form:
  losTypes = {
    [los = boolean,]
    [radar = boolean,]
    [prevLos = boolean,]
    [contRadar = boolean,]
  }</font>
 
'''Spring.SetUnitLosState'''
  ( number unitID, number allyTeam, number los | table losTypes ) -> nil
  <font color="#55ee99">see above for more info on the arguments</font>
 
'''Spring.SetUnitSensorRadius'''
  ( number unitID, string type, number radius ) -> nil | number newRadius
  <font color="#55ee99">type can be:
  "los","airLos","radar","sonar","seismic","radarJammer","sonarJammer"</font>
 
 
'''Spring.SetRadarErrorParams''' {{new|95.0}}
  (number allyTeamID, number allyteamErrorSize
  [, number baseErrorSize [, number baseErrorMult ]]) -> nil
 
 
'''Spring.SetUnitPosErrorParams''' {{new|95.0}}
  (number unitID, number posErrorVector.x, number posErrorVector.y, number posErrorVector.z,
  number posErrorDelta.x, number posErrorDelta.y, number posErrorDelta.z
  [ , number nextPosErrorUpdate]) --> nil
 
== Unit Resourcing ==
'''Spring.SetUnitResourcing'''
  ( number unitID,
    string res, number amount |
    { res = number amount, ... }
  ) -> nil
<font color="#55ee99">
  possible values for res are: "[u|c][u|m][m|e]"
      unconditional | conditional
                use | make
              metal | energy
</font>
 
'''Spring.AddUnitResource'''
  ( number unitID, string "m" | "e", number amount ) -> nil
 
'''Spring.UseUnitResource'''
  ( number unitID, string "m" | "e", number amount ) -> nil | boolean okay
  ( number unitID, { ["m" | "metal" | "e" | "energy"] = amount, ... } ) -> nil | boolean okay
 
'''Spring.SetUnitHarvestStorage''' {{new|97.0}}
  ( number unitid, number metal )
 
<span class = "note">See also {{xtaglink|Gamedev:UnitDefs|harvestStorage}} UnitDef tag.</span>
 
= Feature Handling =
'''Spring.CreateFeature'''
  ( string "defName" | number featureDefID,
    number x, number y, number z
    [, number heading
    [, number AllyTeamID
    [, number featureID ]]] ) -> number featureID
 
'''Spring.DestroyFeature'''
  ( number featureID ) -> nil
 
'''Spring.TransferFeature'''
  ( number featureID, number teamID ) -> nil
 
 
== Feature Control ==
'''Spring.SetFeatureHealth'''
  ( number featureID, number health) -> nil
 
'''Spring.SetFeatureResources''' {{new|104.0}}
  ( number featureID, number metal, number energy [, number reclaimTime [, number reclaimLeft ]] )
 
'''Spring.SetFeatureReclaim'''
  ( number featureID, number reclaimLeft) -> nil
 
'''Spring.SetFeatureResurrect'''
  ( number featureID, number unitDefID | string unitDefName [, number facing | string "facing" [, number progress ]] ) -> nil
<font color="#55ee99">
  possible values for facing are:
    "south" | "s" | 0
    "east"  | "e" | 1
    "north" | "n" | 2
    "west"  | "w" | 3
</font>
{{new|104.0}} Second param can now be a number id instead of a string name, this also allows cancelling ressurection by passing {{value|-1}}. The level of progress can now be set via the additional 4th param.
 
'''Spring.SetFeaturePosition'''
  ( number featureID, number x, number y, number z [, boolean snapToGround]) -> nil
 
'''Spring.SetFeatureDirection'''
  ( number featureID, number x, number y, number z ) -> nil
 
'''Spring.SetFeatureRotation''' {{new|101.0}}
  ( number featureID, number x, number y, number z ) -> nil
 
'''Spring.SetFeatureVelocity''' {{New|95.0}}
 
'''Spring.SetFeaturePhysics''' {{New|95.0}}
 
(like their feature counterparts at [[Lua_SyncedCtrl#Unit_Control]])
 
'''Spring.SetFeatureMoveCtrl'''
  ( number featureID [, boolean enable [, number* args]]) to control feature movement
  the number* 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
    ]]]
 
As of spring 103.0 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 SetFeatureVelocity calls.
 
'''Spring.SetFeatureNoSelect'''
  ( number featureID, boolean noSelect ) -> nil
 
'''Spring.SetFeatureAlwaysVisible'''
  ( number featureID, boolean enable ) -> nil
 
'''Spring.SetFeatureCollisionVolumeData'''
  ( number featureID, number scaleX, number scaleY, number scaleZ,
    number offsetX, number offsetY, number offsetX,
    number vType, number tType, number Axis
  ) -> nil
  <span class=note>check Spring.SetUnitCollisionVolumeData for further explanation of the arguments</span>
 
'''Spring.SetFeaturePieceCollisionVolumeData''' {{new|101.0}}
  ( number featureID, number pieceIndex, boolean enable,
    number scaleX, number scaleY, number scaleZ,
    number offsetX, number offsetY, number offsetZ
    [, number volumeType [, number primaryAxis]]
  ) -> nil
 
'''Spring.SetFeatureMidAndAimPos''' {{new|89.0}}
  ( number unitID,
    number mpx, number mpy, number mpz,
    number apx, number apy, number apz,
    [, boolean relative] ) -> boolean success
 
  <span class=note>check Spring.SetUnitMidAndAimPos for further explanation of the arguments</span>
 
 
'''Spring.SetFeatureRadiusAndHeight''' {{new|89.0}}
  ( number unitID, number radius, number height ) -> boolean success
 
'''Spring.SetFeatureMass''' {{new|101.0}}
  ( number featureID, number mass ) -> nil
 
'''Spring.SetFeatureBlocking'''
  (number featureID, boolean blocking, boolean collidable) --> boolean
 
'''Spring.SetFeatureBlocking''' {{new|95.0}} changed parameters:
  number featureID,
  boolean isBlocking,
  boolean isSolidObjectCollidable,
  boolean isProjectileCollidable,
  boolean isRaySegmentCollidable,
  boolean crushable,
  boolean blockEnemyPushing,
  boolean blockHeightChanges
 
= Lua to COB =
'''Spring.CallCOBScript'''
  ( number unitID, number funcID | string funcName, number retArgs, COBArg1, COBArg2, ... )
    -> nil | number returnValue, number retArg1, number retArg2, ...
 
'''Spring.CallCOBScriptCB'''<br>
<font style="color:red;font-weight:600">broken in 0.78.2.1; will be removed with the introduction of Lua as COB replacement</font>
  ( number unitID, number funcID | string funcName, number retArgs, COBArg1, COBArg2, ... )
    -> nil | number returnValue, number CallbackData, number retArg1, number retArg2, ...
 
'''Spring.GetCOBScriptID'''
  ( number unitID, string funcName ) -> nil | number funcID
 
 
 
<span class="warning"><b>Note: Don't use Spring.[Get|Set]UnitCOBValue in LUS just because you are familar with it since bos/cob, use the mighty LuaSpringAPI instead!</b></span>
 
'''Spring.GetUnitCOBValue'''
  ( number unitID [, boolean splitData=false], number COBValue
    [, number param1 [,number param2 [, number param3 [, number param4 ] ] ] ] )
  -> number result | number result1, number result2
  <span class=note>you find the possible values for `COBValue` in [[Lua_ConstCOB#Get.2FSet|Lua_ConstCOB]]</span>
  <span class=note> also see [[Animation-CobConstants#Custom_Variables|Custom_Variables]]</span>
 
'''Spring.SetUnitCOBValue'''
  ( number unitID, number COBValue, number param1 [,number param2] ) -> nil
  <span class=note>you find the possible values for `COBValue` in [[Lua_ConstCOB#Get.2FSet|Lua_ConstCOB]]</span>
  <span class=note> also see [[Animation-CobConstants#Custom_Variables|Custom_Variables]]</span>
 
= Give Order =
<font color="#55ee99">options can also be a bitmask; e.g. 0 instead of an empty table (can avoid performance hit on table creation)<br>
see [[Lua CMDs]] for relevant constants
</font>
 
'''Spring.GiveOrderToUnit'''
  ( number unitID,
    number cmdID,
    params = {number, etc...},
    options = {"alt", "ctrl", "shift", "right"} ) -> nil
 
'''Spring.GiveOrderToUnitMap'''
  ( unitMap = { [unitID] = dontCare, etc... },
    number cmdID,
    params = {number, etc...},
    options = {"alt", "ctrl", "shift", "right"} ) -> nil
 
'''Spring.GiveOrderToUnitArray'''
  ( unitArray = { [1] = unitID, etc... },
    number cmdID,
    params = {number, etc...},
    options = {"alt", "ctrl", "shift", "right"} ) -> nil
 
'''Spring.GiveOrderArrayToUnitMap'''
  ( unitMap = { [number unitID] = dontCare, etc... },
    orderArray = {
       { number cmdID,
        {number, etc...},    <font color="#55ee99">params</font>
        {"alt", "ctrl", "shift", "right"}  <font color="#55ee99">options</font>
      }, ..
     }
     }
  ) -> nil
'''Spring.GiveOrderArrayToUnitArray'''
  ( unitArray = { [1] = number unitID, etc... },
    orderArray = {
      { number cmdID,
        {number, etc...},    <font color="#55ee99">params</font>
        {"alt", "ctrl", "shift", "right"}  <font color="#55ee99">options</font>
      }, ..
    }
  ) -> nil
=Ground=
== Grass ==
'''Spring.AddGrass'''
  ( number x, number z ) -> nil
'''Spring.RemoveGrass'''
  ( number x, number z ) -> nil
== Heightmap ==
<span class="note">Note that x & z coords are in worldspace (Game.mapSizeX/Z), still the heightmap resolution is [[Lua_ConstGame|Game.squareSize]].</span>
'''Spring.LevelHeightMap'''
  ( number x1, number z1 [, number x2, number z2], number height ) -> nil
'''Spring.AdjustHeightMap''' <span class="note">(heightmap[x][z] += height;)</span>
  ( number x1, number z1 [, number x2, number z2], number height ) -> nil
'''Spring.RevertHeightMap'''
  ( number x1, number z1 [, number x2, number z2], number origFactor ) -> nil


'''gl.GetUniformLocation'''
  ( number shaderID, name uniformName ) -> number locationID


'''Spring.SetHeightMapFunc'''
'''gl.Uniform'''
  ( lua_function [, arg1 ,[ arg2 [, ... ] ] ) -> nil | number absTotalHeightMapAmountChanged
   ( number locationID, number f1 [,number f2 [,number f3 [,number f4]]] ) -> nil
<span class="note">Example code:</span><code><pre>
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)
</pre></code>
'''Spring.AddHeightMap''' <span class="warning">can only be called in SetHeightMapFunc()</span>
   ( number x, number z, number height ) -> nil | number newHeight
'''Spring.SetHeightMap''' <span class="warning">can only be called in SetHeightMapFunc()</span>
  ( number x, number z, number height [,number terraform = 1] ) -> nil | number absHeightDiff
<span class="note">the terraform argument is a scaling factor:
so if 0 nothing will be changed (the terraform starts) and if it is 1 the terraform will be finished.</span>


'''gl.UniformInt'''
  ( number locationID, number int1 [,number int2 [,number int3 [,number int4]]] ) -> nil


'''gl.UniformArray''' {{new|95.0}}
  ( number locationID, number type, table uniforms ) -> nil
<span class="note">type can be one of {1 = int, 2 = float, 3 = float matrix}. In 104.0 the maximum length of the uniforms table increased from 32 entries to 1024.</span>


 
'''gl.UniformMatrix'''
 
   ( number locationID,  
 
    "shadow" |
'''Spring.LevelSmoothMesh'''
    "camera" |
   ( number x1, number z1 [, number x2, number z2], number height ) -> nil
    "caminv" |
'''Spring.AdjustSmoothMesh'''
    "camprj" |
  ( number x1, number z1 [, number x2, number z2], number height ) -> nil
    number m1, number m2, number m3, number m4 |
'''Spring.RevertSmoothMesh'''
    number m1, ... , number m9 |
  ( number x1, number z1 [, number x2, number z2], number origFactor ) -> nil
     number m1, ... , number m16
 
'''Spring.SetSmoothMeshFunc'''
  ( lua_function [, arg1 ,[ arg2 [, ... ] ] ) -> nil | number absTotalHeightMapAmountChanged
'''Spring.AddSmoothMesh''' <span class="warning">can only be called in SetSmoothMeshFunc()</span>
  ( number x, number z, number height ) -> nil | number newHeight
'''Spring.SetSmoothMesh''' <span class="warning">can only be called in SetSmoothMeshFunc()</span>
  ( number x, number z, number height [,number terraform = 1] ) -> nil | number absHeightDiff
 
== TerrainTypes ==
'''Spring.SetMapSquareTerrainType'''
  ( number x, number z, int newType ) -> nil | int oldType
'''Spring.SetTerrainTypeData'''
  ( int typeIndex
  [, number speedTanks = nil ]
  [, number speedKBOTs = nil ]
  [, number speedHovers = nil ]
  [, number speedShips = nil ] ) -> nil | boolean true
 
'''Spring.SetSquareBuildingMask''' {{new|103.0}}
  ( number x, number z, int mask ) -> nil
 
See also {{xtaglink|Gamedev:UnitDefs|buildingMask}} unitdef tag.
 
== MetalAmount ==
'''Spring.SetMetalAmount''' {{new|83.0}}
  ( number x, number z, number metalAmount)
<span class="note">x & z coords are in worldspace/16<br>metalAmount must be between 0 and 255*maxMetal (with maxMetal from the .smd or mapinfo.lua)</span>
 
= Command Descriptions =
<font color="red" style="font-size:120%; font-weight:600">Doesn't work in unsynced code!</font><br><br>
 
'''Spring.EditUnitCmdDesc'''
  ( number unitID, number cmdDescID, table cmdArray ) -> nil
<font color="#55ee99">
  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, ... } ]
  }
</font>
{{var|queueing}} is {{new|101.0}} and allows custom commands to be non-queueing (handy for state toggles).
 
'''Spring.InsertUnitCmdDesc'''
  ( number unitID [, number cmdDescID ] , table cmdArray ) -> nil
 
'''Spring.RemoveUnitCmdDesc'''
  ( number unitID [, number cmdDescID ] ) -> nil
 
= Other =
'''Spring.SetNoPause'''
  ( boolean noPause ) -> nil
 
'''Spring.SetUnitToFeature'''
  ( boolean tofeature ) -> nil
 
an ugly global switch that can be used to block units turning into features when they finish being built (like *A DT's do, which have the isFeature tag)
[http://springrts.com/phpbb/viewtopic.php?f=14&p=481521 thread]
 
'''Spring.SetExperienceGrade'''
  ( number expGrade [, number ExpPowerScale [, number ExpHealthScale [, number ExpReloadScale ]]] ) -> nil
 
  expGrade defines how often UnitExperience() will be called,
  Prior to 104.0 it is based on the following equation:
    (int) [exp/(exp+1)] / expGrade
  Post 104.0 it is the raw change.
 
'''Spring.SpawnExplosion''' {{new|104.0}}
  ( number posX = 0, number posY = 0, number posZ = 0,
    number dirX = 0, number dirY = 0, number dirZ = 0,
    table explosionParams
   ) -> nil
   ) -> nil
  <span class=note>possible keys of explosionParams are:
    weaponDef = number,
    owner = number,
    hitUnit = number,
    hitFeature = number,
    craterAreaOfEffect = number,
    damageAreaOfEffect = number,
    edgeEffectiveness = number,
    explosionSpeed = number,
    gfxMod = number,
    impactOnly = boolean,
    ignoreOwner = boolean,
    damageGround = boolean,
  </span>
<font color="#55ee99">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</font>
'''Spring.SpawnCEG'''
  ( string "cegname" | number cegID,
    number posX = 0, number posY = 0, number posZ = 0,
    number dirX = 0, number dirY = 0, number dirZ = 0,
    number radius = 0, number damage = 0
  ) -> nil | boolean success, cegID
<span class="warning">cegID new in 95.0</span>
'''Spring.SpawnSFX''' {{new|104.0}}
  ( number unitID, number sfxID,
    number posX = 0, number posY = 0, number posZ = 0,
    number dirX = 0, number dirY = 0, number dirZ = 0,
    number radius = 0, number damage = 0
    [, boolean absolute ]
  ) -> nil | boolean success
Equal to the [[Animation-LuaCallouts#Effects|UnitScript versions of EmitSFX]], but takes position and direction arguments (in either unit- or piece-space) instead of a piece index.
= Projectiles =
'''Spring.SpawnProjectile'''
  ( number weaponDefID, table projectileParams ) -> nil | number projectileID
  <span class=note>possible keys of projectileParams are:
    pos = {number x, number y, number z},
    end = {number x, number y, number z},
    speed = {number x, number y, number z},
    spread = {number x, number y, number z},
    error = {number x, number y, number z},
    owner = number,
    team = number,
    ttl = number,
    gravity = number,
    tracking = number,
    maxRange = number,
    startAlpha = number,
    endAlpha = number,
    model = string,
    cegTag = string,
  </span>
'''Spring.DeleteProjectile''' {{new|101.0}}
  ( number projID ) -> nil
Silently removes projectiles (no explosion).
'''Spring.SetProjectileTarget'''
<span class = "warning">Pre 95.0:</span>  ( number projectileID,
    [ number targetID, string targetTypeStr ] | [ number posX, number posY, number posZ ] )
    -> nil | boolean validTarget
<span class = "warning">Post 95.0:</span>  ( number projectileID,
    [ number targetID [, number targetType]]  |  [number posX, number posY, number posZ])
    --> nil | boolean validTarget
  <span class=note>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
  </span>
'''Spring.SetProjectileIgnoreTrackingError''' {{new|101.0}}
  ( number projID, bool ignore ) -> nil
'''Spring.SetProjectileIsIntercepted''' {{new|99.0}}
  ( number projID ) -> nil
'''Spring.SetProjectileMoveControl''' <span class=note>(disables engine movecontrol, so lua can fully control the physics)</span>
  ( number projID, boolean enable ) -> nil
'''Spring.SetProjectilePosition'''
  ( number projID [, number x = 0 [, number y = 0 [, number z = 0 ]]] ) -> nil
'''Spring.SetProjectileVelocity'''
  ( number projID [, number x = 0 [, number y = 0 [, number z = 0 ]]] ) -> nil
'''Spring.SetProjectileCollision'''
  ( number projID ) -> nil
'''Spring.SetProjectileGravity'''
  ( number projID [, number grav = 0] ) -> nil
'''Spring.SetProjectileSpinAngle''' {{new|95.0}} Deprecated
  ( number projID [, number spinAngle = 0] ) -> nil
'''Spring.SetProjectileSpinSpeed''' {{new|95.0}} Deprecated
  ( number projID [, number speed = 0] ) -> nil
'''Spring.SetProjectileSpinVec''' {{new|95.0}} Deprecated
  ( number projID [, number x = 0 [, number y = 0 [, number z = 0]]] ) -> nil
'''Spring.SetProjectileCEG'''
  ( number projID, string ceg_name ) -> nil
'''Spring.SetPieceProjectileParams''' {{new|95.0}}
  (number projectileID,
  [ number explosionFlags, [ number spinAngle, [ number spinSpeed,
  [ number spinVector.x, [ number spinVector.y, [ number spinVector.z ]]]]]]) --> nil
'''Spring.SetProjectileAlwaysVisible''' {{new|95.0}}
    (number projectileID, boolean alwaysVisible) --> nil
'''Spring.SetProjectileDamages''' {{new|101.0}}
  ( number unitID, number weaponNum, table damages ) -> nil
  ( number unitID, number weaponNum, string key, number value ) -> nil
  <span class="note">format of the damages table:
  {
      ["paralyzeDamageTime" = number value,] 
      ["impulseFactor"      = number value,]
      ["impulseBoost"      = number value,]
      ["craterMult"        = number value,]
      ["craterBoost"        = number value,]
      ["dynDamageExp"      = number value,]
      ["dynDamageMin"      = number value,]
      ["dynDamageRange"    = number value,]
      ["dynDamageInverted"  = number value,] (<>0.0f := true)
      ["craterAreaOfEffect" = number value,]
      ["damageAreaOfEffect" = number value,]
      ["edgeEffectiveness"  = number value,]
      ["explosionSpeed"    = number value,]
      [number armorType    = number value,] (changes the damage against this armor type)
    }
  </span>


[[category: Lua]]
[[category: Lua]]

Latest revision as of 21:51, 21 April 2021

Development < Lua Scripting < User:Master-athmos

These functions are ONLY available if the graphic board supports GLSL.

Please test in your scripts if one of them exists before you use them!


gl.CreateShader

 ({[ vertex   = "glsl code" ,]
   [ tcs      = "glsl code" ,]
   [ tes      = "glsl code" ,]
   [ geometry = "glsl code" ,]
   [ fragment = "glsl code" ,]
   [ uniform       = { uniformName = number value, ...} ,] (specify a Lua array as an argument to uniformName to initialize GLSL arrays)
   [ uniformInt    = { uniformName = number value, ...} ,] (specify a Lua array as an argument to uniformName to initialize GLSL arrays)
   [ uniformFloat  = { uniformName = number value, ...} ,] (specify a Lua array as an argument to uniformName to initialize GLSL arrays)
   [ uniformMatrix = { uniformName = number value, ...} ,]
   [ geoInputType = number inType,]
   [ geoOutputType = number outType,]
   [ geoOutputVerts = number maxVerts,]
   [ definitions = "string of shader #defines", ]
 }) -> number shaderID
  • The "Vertex" or vertex-shader is your GLSL-Code as string, its written in a C-Dialect. This shader is busy deforming the geometry of a unit but it can not create new polygons. Use it for waves, wobbling surfaces etc.
  • The "Geometry" or Geometry-shader can create new vertices and vertice-stripes from points.
  • The "TCS" or Tesselation Control Shader controls how much tessellation a particular patch gets; it also defines the size of a patch, thus allowing it to augment data. It can also filter vertex data taken from the vertex shader. The main purpose of the TCS is to feed the tessellation levels to the Tessellation primitive generator stage, as well as to feed patch data (as its output values) to the Tessellation Evaluation Shader stage. TCS shader can be used with spring version >= 104.0.1-596 (maintenance), it's also available in develop branch of spring.
  • The "TES" or Tesselation Evaluation Shader takes the abstract patch generated by the tessellation primitive generation stage, as well as the actual vertex data for the entire patch, and generates a particular vertex from it. Each TES invocation generates a single vertex. It can also take per-patch data provided by the Tessellation Control Shader. TES shader can be used with spring version >= 104.0.1-596 (maintenance), it's also available in develop branch of spring.
  • The "Fragment" or Fragment-shader (sometimes called pixel-Shader) is post processing the allready rendered picture (for example drawing stars on the sky)- remember textures are not always 2 dimensional pictures. They can contain information about the depth, or the third value marks areas and the strength at which these are processed.
  • The Uniforms are the values, you send along with the shader-program. To use them in the shader-program declare them like this:

<syntaxhighlight lang="c">uniform float frame;</syntaxhighlight>

  • From 101.0 onwards, the engine will automatically fill in an appropriately named uniform for team colour if it is declared;

<syntaxhighlight lang="c">uniform vec4 teamColor;</syntaxhighlight>

gl.DeleteShader

 ( number shaderID ) -> nil

gl.ActiveShader can be used in NON-drawing events (to update uniforms etc.)!

 ( number shaderID, function [, arg1 [, arg2, ..]] ) -> nil

gl.UseShader

 ( number shaderID ) -> boolean linked

gl.GetShaderLog

 ( ) -> string "infoLog"

gl.SetShaderParameter Renamed to SetGeometryShaderParameter in spring version >= 104.0.1-596 (maintenance). needed by geometry shader programs (check the opengl GL_ARB_geometry_shader4 extension for glProgramParameteri)

 ( number shaderID, number param, number value ) -> nil

gl.SetTesselationShaderParameter Available for spring versions >= 104.0.1-596 (maintenance). needed by tesselation shader programs (check the opengl GL_ARB_tessellation_shader extension for glProgramParameteri)

 ( number param, number value ) -> nil

gl.GetActiveUniforms

 ( number shaderID ) -> { 
     [1] = { name = "name", type = "type", length = number length, size = number size },
     ...
   }

gl.GetUniformLocation

 ( number shaderID, name uniformName ) -> number locationID

gl.Uniform

 ( number locationID, number f1 [,number f2 [,number f3 [,number f4]]] ) -> nil

gl.UniformInt

 ( number locationID, number int1 [,number int2 [,number int3 [,number int4]]] ) -> nil

gl.UniformArray New in version 95.0

 ( number locationID, number type, table uniforms ) -> nil

type can be one of {1 = int, 2 = float, 3 = float matrix}. In 104.0 the maximum length of the uniforms table increased from 32 entries to 1024.

gl.UniformMatrix

 ( number locationID, 
   "shadow" |
   "camera" |
   "caminv" |
   "camprj" |
   number m1, number m2, number m3, number m4 |
   number m1, ... , number m9 |
   number m1, ... , number m16
 ) -> nil