|
|
| (14 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> |
|
| |
|
|
| |
|
| <div class="note">
| | '''gl.CreateShader''' |
| NOTE: Prior to 102.0, entries below marked <font color="red" style="font-weight:600">(needs ModUICtrl)</font> require the setting ModUICtrl to be enabled in the users [[springrc]], if you want to use them in unsynced LuaRules/LuaGaia. It is enabled by default in previous versions and removed in 102.0 so you generally don't need to care.</div>
| | ({[ 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 |
|
| |
|
| = UI =
| | * 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. |
| '''Spring.SetLastMessagePosition'''
| | |
| ( number x, number y, number z ) -> nil
| | * The "Geometry" or Geometry-shader can create new vertices and vertice-stripes from points. |
|
| |
|
| = Ingame Console =
| | * 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. |
| '''Spring.Echo'''
| |
| ( arg1 [, arg2 [, ... ] ] ) -> nil
| |
|
| |
|
| <font color="#55ee99">Useful for debugging.<br> Prints values in the spring chat console.<br> Hint: the default print() writes to STDOUT.</font>
| | * 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. |
|
| |
|
| '''Spring.Log'''
| | * 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. |
| ( string section, int logLevel | string logLevel,
| |
| arg2 [, arg3 [, ... ] ] ) -> nil
| |
|
| |
|
| <font color="#55ee99">Possible values for logLevel are:
| | * The Uniforms are the values, you send along with the shader-program. To use them in the shader-program declare them like this: |
| "debug" | LOG.DEBUG
| | <syntaxhighlight lang="c">uniform float frame;</syntaxhighlight> |
| "info" | LOG.INFO
| |
| "notice" | LOG.NOTICE (engine default) {{new|97}}
| |
| "warning" | LOG.WARNING
| |
| "error" | LOG.ERROR
| |
| "fatal" | LOG.FATAL</font>
| |
|
| |
|
| '''Spring.SendCommands''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| | * From 101.0 onwards, the engine will automatically fill in an appropriately named uniform for team colour if it is declared; |
| ( string command1 [, string command2 [ ... ] ] ) -> nil
| | <syntaxhighlight lang="c">uniform vec4 teamColor;</syntaxhighlight> |
| ( {string command1, string command2, ...} ) -> nil
| |
|
| |
|
| == GUI ==
| | '''gl.DeleteShader''' |
| '''Spring.SetActiveCommand''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font> | | ( number shaderID ) -> nil |
| ( string action [, string actionExtra ] ) -> nil | boolean
| |
| ( number cmdIndex [, number button = 1 | |
| [, boolean leftClick, boolean rightClick,
| |
| boolean alt, boolean ctrl, boolean meta, boolean shift]] ) -> nil | boolean
| |
| '''Spring.LoadCmdColorsConfig''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( string config ) -> nil
| |
| '''Spring.LoadCtrlPanelConfig''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( string config ) -> nil
| |
| '''Spring.ForceLayoutUpdate''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( ) -> nil
| |
| '''Spring.SetDrawSelectionInfo''' <font color="#55ee99">disables the "Selected Units x" box in the GUI</font> <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( boolean enable ) -> nil
| |
|
| |
|
| == Mouse ==
| | '''gl.ActiveShader''' <font color="#55ee99">can be used in NON-drawing events (to update uniforms etc.)!</font> |
| '''Spring.SetMouseCursor''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font> | | ( number shaderID, function [, arg1 [, arg2, ..]] ) -> nil |
| ( string cursorName [, number scale ] ) -> nil | |
| '''Spring.WarpMouse''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( number x, number y ) -> nil
| |
|
| |
|
| == LOS Colors ==
| | '''gl.UseShader''' |
| '''Spring.SetLosViewColors''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font> | | ( number shaderID ) -> boolean linked |
|
| |
|
| <span class=warning>New arguments since 100.0 (radar2 is the inside of radar edge):</span>
| | '''gl.GetShaderLog''' |
| ( always = {r,g,b}, LOS = {r,g,b}, radar = {r,g,b}, jam = {r,g,b}, radar2 = {r,g,b}) -> nil | | ( ) -> string "infoLog" |
|
| |
|
| | '''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 |
|
| |
|
| <span class=warning>Arguments for 99.0 and before:</span> | | '''gl.SetTesselationShaderParameter''' |
| ( table reds = { number always, number LOS, number radar, number jam }, | | <font color="#0000ee">Available for spring versions >= 104.0.1-596 (maintenance).</font> |
| table greens = { number always, number LOS, number radar, number jam },
| | <font color="#55ee99">needed by tesselation shader programs (check the opengl GL_ARB_tessellation_shader extension for glProgramParameteri)</font> |
| table blues = { number always, number LOS, number radar, number jam } ) -> nil
| | ( number param, number value ) -> nil |
|
| |
|
| == SendMessage ==
| | '''gl.GetActiveUniforms''' |
| '''Spring.SendMessage'''
| | ( number shaderID ) -> { |
| ( string "message" ) -> nil
| | [1] = { name = "name", type = "type", length = number length, size = number size }, |
| '''Spring.SendMessageToPlayer'''
| | ... |
| ( number playerID, string "message" ) -> nil
| |
| '''Spring.SendMessageToTeam'''
| |
| ( number teamID, string "message" ) -> nil
| |
| '''Spring.SendMessageToAllyTeam'''
| |
| ( number allyID, string "message" ) -> nil
| |
| '''Spring.SendMessageToSpectators'''
| |
| ( string "message" ) -> nil
| |
| Funfact:
| |
| <PLAYER#> (with # being a playerid) inside the string will be replaced with the players name.
| |
| ie
| |
| Spring.SendMessage ("<PLAYER1> did something")
| |
| might display as "ProRusher did something"
| |
| | |
| == Markers ==
| |
| '''Spring.MarkerAddPoint''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( number x, number y, number z [, string text = "" [, bool localOnly] ] ) -> nil
| |
| '''Spring.MarkerAddLine''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( number x1, number y1, number z1, number x2, number y2, number z2 ) -> nil
| |
| '''Spring.MarkerErasePosition''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( number x, number y, number z ) -> nil
| |
| | |
| = Sounds =
| |
| '''Spring.LoadSoundDef'''
| |
| ( string "soundfile" ) -> nil | boolean success
| |
| <span class=note>Loads a SoundDefs file, the format is the same as in `gamedata/sounds.lua`.</span>
| |
| | |
| '''Spring.PlaySoundFile''' <span class=note>Plays WAV or OGG sounds.</span>
| |
| ( string "soundfile" [, number volume = 1.0
| |
| [, number posx, number posy, number posz
| |
| [, number speedx, number speedy, number speedz ] ] ], [string/number <span class=note>channel</span> ] ) -> nil | boolean
| |
| <span class=note>`channel` is new in Spring0.83, and can be one of those:
| |
| "general" || 0 || nil (default)
| |
| "battle" || "sfx" | 1
| |
| "unitreply" || "voice" || 2
| |
| "userinterface" || "ui" || 3
| |
| </span>
| |
| | |
| '''Spring.PlaySoundStream'''
| |
| ( string "oggfile" [, number volume = 1.0
| |
| [, bool enqueue ]] ) -> nil | boolean true
| |
| <span class=note>Allow you to play an Ogg Vorbis (.OGG) compressed sound file.<br> In 83.0 and up multiple sound streams may be played at once </span>
| |
| '''Spring.StopSoundStream'''
| |
| ( ) -> nil
| |
| <span class=note>Terminates any SoundStream currently running.</span>
| |
| '''Spring.PauseSoundStream'''
| |
| ( ) -> nil
| |
| '''Spring.SetSoundStreamVolume'''
| |
| ( number volume ) -> nil
| |
| | |
| = SendLuaMessage =
| |
| <font color="#55ee99">Very important! (allows synced inter-lua-enviroment communications)</font>
| |
| | |
| '''Spring.SendLuaUIMsg''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( string message, string mode ) -> nil
| |
| <font color="#55ee99">possible modes are:<br>"s"/"specs" & "a"/"allies"</font>
| |
| '''Spring.SendLuaGaiaMsg''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( string message ) -> nil
| |
| '''Spring.SendLuaRulesMsg''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( string message ) -> nil
| |
| | |
| = AI =
| |
| '''Spring.SendSkirmishAIMessage''' {{new|83.0}} | |
| ( number aiTeam, string message ) | |
| -> nil | boolean ai_processed, { [1] = string response1, etc... }
| |
| <span class="note">Note there is nothing in this table due to "limitations" of the AI interface.</span>
| |
| | |
| = Units =
| |
| '''Spring.SetUnitLeaveTracks''' {{new|83.0}}
| |
| ( number unitID, boolean leavetracks ) -> nil
| |
| | |
| '''Spring.SetUnitSelectionVolumeData''' {{new|104.0}}
| |
| ( number featureID, number scaleX, number scaleY, number scaleZ,
| |
| number offsetX, number offsetY, number offsetX,
| |
| number vType, number tType, number Axis
| |
| ) -> nil
| |
| | |
| == Unit Selection ==
| |
| '''Spring.SelectUnitMap'''
| |
| ( { [unitID] = anything, ...} [,boolean append] ) -> nil
| |
| '''Spring.SelectUnitArray'''
| |
| ( { [1] = unitID1 , [2] = unitID2 , ...} [,boolean append] ) -> nil
| |
| | |
| '''Spring.SetDrawSelectionInfo'''
| |
| ( boolean drawSelectionInfo ) -> nil
| |
| | |
| == Unit Group ==
| |
| '''Spring.SetUnitGroup''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( number unitID, number groupID ) -> nil
| |
| | |
| == Give Order ==
| |
| '''Spring.GiveOrder''' <font color="#55ee99">gives order to all selected units</font> <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( number cmdID,
| |
| params = {number, etc...},
| |
| options = {"alt", "ctrl", "shift", "right"} ) -> nil | boolean true
| |
| '''Spring.GiveOrderToUnit''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( number unitID,
| |
| number cmdID,
| |
| params = {number, etc...},
| |
| options = {"alt", "ctrl", "shift", "right"} ) -> nil | boolean true
| |
| '''Spring.GiveOrderToUnitMap''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( unitMap = { [unitID] = dontCare, etc... },
| |
| number cmdID,
| |
| params = {number, etc...},
| |
| options = {"alt", "ctrl", "shift", "right"} ) -> nil | boolean true
| |
| '''Spring.GiveOrderToUnitArray''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( unitArray = { [1] = unitID, etc... },
| |
| number cmdID,
| |
| params = {number, etc...},
| |
| options = {"alt", "ctrl", "shift", "right"} ) -> nil | boolean true
| |
| '''Spring.GiveOrderArrayToUnitMap''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( unitMap = { [number unitID] = dontCare, etc... },
| |
| orderArray = {
| |
| { number cmdID, | |
| params = {number, etc...},
| |
| options = {"alt", "ctrl", "shift", "right"}
| |
| }, ..
| |
| } | | } |
| ) -> nil | boolean true
| |
| '''Spring.GiveOrderArrayToUnitArray''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( unitArray = { [1] = number unitID, etc... },
| |
| orderArray = {
| |
| { number cmdID,
| |
| params = {number, etc...},
| |
| options = {"alt", "ctrl", "shift", "right"}
| |
| }, ..
| |
| },
| |
| [boolean pairwise]
| |
| ) -> nil | boolean true
| |
|
| |
| <span class="note">pairwise param ({{new|89.0}}) is used to send multiple units a single individual command</span>
| |
|
| |
|
| | '''gl.GetUniformLocation''' |
| | ( number shaderID, name uniformName ) -> number locationID |
|
| |
|
| '''Spring.SetBuildFacing''' | | '''gl.Uniform''' |
| ( int Facing ) -> nil | | ( number locationID, number f1 [,number f2 [,number f3 [,number f4]]] ) -> nil |
|
| |
|
| '''Spring.SetBuildSpacing''' | | '''gl.UniformInt''' |
| ( int Spacing ) -> nil | | ( number locationID, number int1 [,number int2 [,number int3 [,number int4]]] ) -> nil |
|
| |
|
| == Unit NoDraw,NoSelect,NoMinimap ==
| | '''gl.UniformArray''' {{new|95.0}} |
| '''Spring.SetUnitNoDraw''' <font color="red">LuaGadgets only!</font> | | ( number locationID, number type, table uniforms ) -> nil |
| ( number unitID, boolean noDraw ) -> 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> |
| '''Spring.SetUnitNoSelect''' <font color="red">LuaGadgets only!</font>
| |
| ( number unitID, boolean noSelect ) -> nil
| |
| '''Spring.SetUnitNoMinimap''' <font color="red">LuaGadgets only!</font>
| |
| ( number unitID, boolean noMinimap ) -> nil
| |
|
| |
|
| = Features =
| | '''gl.UniformMatrix''' |
| '''Spring.SetFeatureFade''' {{new|101.0}} | | ( number locationID, |
| ( int featureID, bool allow ) -> nil | | "shadow" | |
| Control whether a feature will fade or not when zoomed out.
| | "camera" | |
| | | "caminv" | |
| '''Spring.SetFeatureNoDraw''' <font color="red">LuaGadgets only!</font>
| | "camprj" | |
| ( number featureID, boolean noDraw ) -> nil
| | number m1, number m2, number m3, number m4 | |
| | | number m1, ... , number m9 | |
| '''Spring.SetFeatureSelectionVolumeData''' {{new|104.0}}
| | number m1, ... , number m16 |
| ( number featureID, number scaleX, number scaleY, number scaleZ,
| |
| number offsetX, number offsetY, number offsetX, | |
| number vType, number tType, number Axis | |
| ) -> nil | | ) -> nil |
|
| |
| = Developers =
| |
| '''Spring.SetDrawSky'''
| |
| ( boolean drawSky ) -> nil
| |
| '''Spring.SetDrawWater'''
| |
| ( boolean drawWater ) -> nil
| |
| '''Spring.SetDrawGround'''
| |
| ( boolean drawGround ) -> nil
| |
|
| |
| '''Spring.SetWaterParams''' <span class=warning>As of 104.0 no longer needs cheating enabled</span>
| |
| ( table params ) -> nil
| |
| <span class=note>Allows to change water params (mostly BumpWater ones) at runtime. You may want to set BumpWaterUseUniforms in your [[springrc]] to 1, then you don't even need to restart BumpWater via `/water 4`.</span><br>
| |
| <span class=note>`params` table may contain:
| |
| params = {
| |
| absorb = {number r, number g, number b},
| |
| baseColor = {number r, number g, number b},
| |
| minColor = {number r, number g, number b},
| |
| surfaceColor = {number r, number g, number b},
| |
| diffuseColor = {number r, number g, number b},
| |
| specularColor = {number r, number g, number b},
| |
| planeColor = {number r, number g, number b},
| |
| texture = string file,
| |
| foamTexture = string file,
| |
| normalTexture = string file,
| |
| damage = number value,
| |
| repeatX = number value,
| |
| repeatY = number value,
| |
| surfaceAlpha = number value,
| |
| ambientFactor = number value,
| |
| diffuseFactor = number value,
| |
| specularFactor = number value,
| |
| specularPower = number value,
| |
| fresnelMin = number value,
| |
| fresnelMax = number value,
| |
| fresnelPower = number value,
| |
| reflectionDistortion = number value,
| |
| blurBase = number value,
| |
| blurExponent = number value,
| |
| perlinStartFreq = number value,
| |
| perlinLacunarity = number value,
| |
| perlinAmplitude = number value,
| |
| numTiles = number value,
| |
| shoreWaves = boolean value,
| |
| forceRendering = boolean value,
| |
| hasWaterPlane = boolean value,
| |
| }</span>
| |
|
| |
| '''Spring.SetMapRenderingParams''' {{new|104.0}}
| |
| ( table params ) -> nil
| |
| <span class=note>Allows to change map rendering params at runtime.</span><br>
| |
| <span class=note>`params` table may contain:
| |
| params = {
| |
| splatTexMults = {number r, number g, number b, number a},
| |
| splatTexScales = {number r, number g, number b, number a},
| |
| voidWater = boolean value,
| |
| voidGround = boolean value,
| |
| splatDetailNormalDiffuseAlpha = boolean value,
| |
| }</span>
| |
|
| |
| '''Spring.SetLogSectionFilterLevel''' {{New|95.0}}
| |
| ( string sectionName, string|number logLevel )
| |
| see [[infolog.txt]] for possible log sections (?)
| |
|
| |
| '''Spring.SetDrawGroundDeferred''' {{New|95.0}}
| |
| ( boolean drawGroundDeferred [, boolean drawGroundForward] ) -> nil
| |
| {{new|101.0}} {{var|drawGroundForward}} allows disabling of the forward pass
| |
|
| |
| '''Spring.SetDrawModelsDeferred''' {{New|95.0}}
| |
| ( boolean drawUnitsDeferred,
| |
| boolean drawFeaturesDeferred
| |
| [, boolean drawUnitsForward
| |
| [, boolean drawFeaturesForward ]]
| |
| ) -> nil
| |
|
| |
| {{new|101.0}} {{var|drawFeaturesForward}}, {{var|drawUnitsForward}} allows disabling of the respective forward passes
| |
|
| |
| '''Spring.SetVideoCapturingMode''' {{new|104.0}}
| |
| ( boolean allowCaptureMode ) -> nil
| |
|
| |
| This doesn't actually record the game in any way, it just regulates the framerate and interpolations.
| |
|
| |
| '''Spring.SetVideoCapturingTimeOffset''' {{new|104.0}}
| |
| ( number timeOffset ) -> nil
| |
|
| |
| = GUI =
| |
| '''Spring.DrawUnitCommands'''
| |
| ( number unitID ) -> nil
| |
| ( { [1] = unitID, ... } [, false ] ) -> nil
| |
| ( { [unitID] = anything, ... }, true ) -> nil
| |
|
| |
| '''Spring.SetTeamColor'''
| |
| ( number teamID, number r, number g, number b ) -> nil
| |
|
| |
| '''Spring.AssignMouseCursor''' <font class=note>changes/creates the cursor of a single CursorCmd</font>
| |
| ( string "cmdName", string "iconFileName"
| |
| [, boolean overwrite = true [, boolean hotSpotTopLeft = false] ] ) -> nil | boolean
| |
| <font class=note>Note, that iconFileName is not the full filename instead it is like this:<br/>
| |
| wanted filename: Anims/cursorattack_0.bmp<br/>
| |
| => iconFileName: cursorattack
| |
| </font>
| |
|
| |
| '''Spring.ReplaceMouseCursor''' <font class=note>mass replace all occurrence of the cursor in all CursorCmds</font>
| |
| ( string "oldFileName", string "newFileName" [, boolean hotSpotTopLeft = false] ) -> nil | boolean
| |
|
| |
| '''Spring.SetCustomCommandDrawData''' <font class=note>register your custom cmd so it gets visible in the unit's cmd queue</font>
| |
| ( number cmdID,
| |
| number cmdID_cloneIcon | string iconname,
| |
| { number r, number g, number b, number a } [, boolean showArea ] ) -> nil
| |
| ( number cmdID, nil) -> nil
| |
|
| |
| = Sharing =
| |
| '''Spring.SetShareLevel''' <font color="#55ee99">note: shareLevel is 0<= x <= 1</font> <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( string "metal" | "energy", number shareLevel ) -> nil
| |
| '''Spring.ShareResources''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( number teamID, string "units" ) -> nil
| |
| ( number teamID, string "metal" | "energy", number amount ) -> nil
| |
|
| |
| = UnitDef RadarIcons & BuildPics =
| |
| '''Spring.AddUnitIcon'''
| |
| ( string iconName, string texFile [, number size [, number dist [, boolean radAdjust ]]] )
| |
| -> nil | boolean
| |
| '''Spring.FreeUnitIcon'''
| |
| ( string iconName ) -> nil | boolean
| |
| '''Spring.SetUnitDefIcon''' <font color="#55ee99">(RadarIcon)</font> <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( number unitDefID, string iconName ) -> nil
| |
| '''Spring.SetUnitDefImage''' <font color="#55ee99">(BuildPic)</font> <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( number unitDefID, luaTexture | string texFile ) -> nil
| |
|
| |
| = Camera =
| |
| '''Spring.SetCameraState'''
| |
| ( table camState, number camTime) -> nil | boolean
| |
| <font color="#55ee99">camState has the same format as the output of Spring.GetCameraState(). See [[Lua_camState]] for details about camState.
| |
|
| |
| The camState's mode/name must fit the rest of the state. Getting a state, changing its mode/name and then passing it to SetCameraState will have undesired results. [https://springrts.com/mantis/view.php?id=5028#c15491 Also see #5028]</font>
| |
|
| |
| '''Spring.SetCameraTarget'''
| |
| ( number x, number y, number z [,number transTime] ) -> nil
| |
| <font color="#55ee99">For Spring Engine XZ represents horizontal, from north west corner of map and Y vertical, from water level and rising.</font>
| |
|
| |
| '''Spring.SetCameraOffset''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( [number px = 0 [, number py = 0 [, number pz = 0
| |
| [, number tx = 0 [, number ty = 0 [, number tz = 0]]]]]] ) -> nil
| |
|
| |
| = (Virtual-)FileSystem =
| |
| '''Spring.ExtractModArchiveFile'''
| |
| ( string modfile ) -> boolean
| |
| '''Spring.CreateDir''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
| |
| ( string path ) -> nil | boolean
| |
|
| |
| The full VFS API is available at [[Lua_VFS|link]].
| |
|
| |
| = Engine Config =
| |
| The following functions read the engine configs saved in [[Springsettings.cfg]], a version-ed instance of these or a custom file supplied on the command line.
| |
| If ''*Overlay'' is ''true'', the value will only be set in memory, and not be restored for the next game
| |
|
| |
| '''Spring.SetConfigInt'''
| |
| ( string name, number value [, boolean useOverlay = false] ) -> nil
| |
|
| |
| '''Spring.SetConfigFloat''' {{new|104.0}}
| |
| ( string name, number value [, boolean useOverlay = false] ) -> nil
| |
|
| |
| '''Spring.SetConfigString'''
| |
| ( string name, string value [, boolean useOverlay = false] ) -> nil
| |
|
| |
| = World Primitives =
| |
| <font color="red" style="font-weight:600">outdated! use opengl api instead!</font>
| |
|
| |
| '''Spring.AddWorldIcon'''
| |
| ( number cmdID, number x, number y, number z ) -> nil
| |
| '''Spring.AddWorldText'''
| |
| ( string "text", number x, number y, number z ) -> nil
| |
| '''Spring.AddWorldUnit'''
| |
| ( number unitDefID,
| |
| number x, number y, number z,
| |
| number team, number facing) -> nil
| |
|
| |
| = Sun =
| |
| The dynamic Sun must be invoked via /dynamicsun (Dynamic sun was removed in 104.0, use SetSunDirection, SetSunLighting & SetAtmosphere instead).
| |
|
| |
| '''Spring.SetSunManualControl''' {{removed|104.0}}
| |
| ( boolean setManualControl ) - > nil
| |
|
| |
| '''Spring.SetSunParameters''' {{removed|104.0}}
| |
| ( number dirX, number dirY, number dirZ, number dist, number startTime, number orbitTime ) -> nil
| |
|
| |
| '''Spring.SetSunDirection'''
| |
| ( number dirX, number dirY, number dirZ ) -> nil
| |
|
| |
| '''Spring.SetSunLighting''' {{new|101.0}}
| |
| ( table params ) -> nil
| |
|
| |
| <span class=note>It can be used to modify the following sun lighting parameters:
| |
| {ground,unit}{Ambient,Diffuse,Specular}Color and specularExponent
| |
| All Colourvalues have to in the Range from 0.0 to 1.0 for all colors and the alpha
| |
| Example usage: Spring.SetSunLighting({groundAmbientColor = {1, 0.1, 1}, groundDiffuseColor = {1, 0.1, 1} })
| |
| </span>
| |
|
| |
| '''Spring.SetAtmosphere''' {{new|101.0}}
| |
| ( table params ) -> nil
| |
|
| |
| <span class=note>It can be used to modify the following atmosphere parameters:
| |
| fog{Start,End}, {sun,sky,cloud}Color
| |
| Example usage: Spring.SetAtmosphere({ fogStart = 0, fogEnd = 0.5, fogColor = { 0.7, 0.2, 0.2, 1 }})
| |
| </span>
| |
|
| |
| = Misc =
| |
|
| |
| '''Spring.Reload''' {{new|99.0}}
| |
| ( string startscript )
| |
| <font color="#55ee99">start-script is the CONTENT of the [[script.txt]] spring should use to start.</font>
| |
|
| |
| '''Spring.Restart''' {{new|0.79}}
| |
| ( string commandline_args, string startscript )
| |
| -> if this call returns, something went wrong
| |
| <font color="#55ee99">''commandline_args'' are commandline arguments passed to spring executable</font>
| |
|
| |
| '''Spring.Start''' {{new|102.0}}
| |
| ( string commandline_args, string startscript )
| |
| -> if this call returns, something went wrong
| |
| <font color="#55ee99">Launches a new Spring instance without terminating the existing one</font>
| |
|
| |
| <font color="#55ee99">start-script is the CONTENT of the [[script.txt]] spring should use to start (if empty, no start-script is added, you can still point spring to your custom script.txt when you add the file-path to ''commandline_args''</font>
| |
|
| |
|
| |
| '''Spring.SetWMIcon''' {{new|83.0}}
| |
| ( string iconFileName ) -> nil
| |
| <font color="#55ee99">Sets the icon for the process which is seen in the OS task-bar and other places (default: spring-logo).<br/>
| |
| Note: has to be 24bit or 32bit<br/>
| |
| Note: on windows, it has to be 32x32 pixels in size (recommended for cross-platform)<br/>
| |
| Note: ''*.bmp'' images have to be in BGR format (default for m$ ones).<br/>
| |
| Note: ''*.ico'' images are not supported.</font>
| |
|
| |
|
| |
| '''Spring.SetWMCaption''' {{new|83.0}}
| |
| ( string title [, string titleShort = title ] ) -> nil
| |
|
| |
| <font color="#55ee99">Sets the window ''title'' for the process (default: "Spring <version>").</font>
| |
|
| |
| <font color="#55ee99">The ''shortTitle'' is displayed in the OS task-bar (default: "Spring <version>").</font>
| |
|
| |
| <font color="#55ee99">'''NOTE:''' ''shortTitle'' is only ever possibly used under X11 (Linux & OS X), but not with QT (KDE) and never under Windows. See [http://www.gpwiki.org/index.php/SDL:Tutorials:Initializing_SDL_Libraries#About_the_icon_.28.22Icon_Title.22.29_parameter_on_different_window-managers this site] for more details.</font>
| |
|
| |
|
| |
| '''Spring.ClearWatchDogTimer''' {{new|83.0}}
| |
| ( [ string threadName = main ] ) -> nil
| |
|
| |
|
| |
| '''Spring.SetClipboard''' {{new|98.0}}
| |
| ( string text) -> nil
| |
|
| |
| = Rendering =
| |
| == Preload ==
| |
| Allow the engine to load the unit's model (and texture) in a background thread. Wreckages and buildOptions of a unit are automatically preloaded.
| |
|
| |
| '''Spring.PreloadUnitDefModel''' {{new|101.0}}
| |
| ( number unitDefID ) -> nil
| |
|
| |
| '''Spring.PreloadFetureDefModel''' {{new|101.0}}
| |
| ( number featureDefID ) -> nil
| |
|
| |
| == Lighting ==
| |
| <font color="red" style="font-weight:600">NOTE: these (0.83+) lighting callouts only work when called from unsynced gadgets!</font>
| |
|
| |
| '''Spring.AddMapLight''' <font color="red" style="font-weight:600">(requires MaxDynamicMapLights > 0)</font>
| |
| (table lightParams) -> number lightHandle
| |
| '''Spring.AddModelLight''' <font color="red" style="font-weight:600">(requires MaxDynamicModelLights > 0)</font>
| |
| (table lightParams) -> number lightHandle
| |
|
| |
| '''Spring.UpdateMapLight'''
| |
| (number lightHandle, table lightParams) -> boolean success
| |
| '''Spring.UpdateModelLight'''
| |
| (number lightHandle, table lightParams) -> boolean success
| |
|
| |
| '''Spring.SetMapLightTrackingState'''
| |
| (number lightHandle, number unitOrProjectileID,
| |
| boolean enableTracking, boolean unitOrProjectile) -> boolean success
| |
| '''Spring.SetModelLightTrackingState'''
| |
| (number lightHandle, number unitOrProjectileID,
| |
| boolean enableTracking, boolean unitOrProjectile) -> boolean success
| |
|
| |
| '''lightParams''' is a table that should contain at least one of the following recognized key/value pairs:
| |
|
| |
| lightParams = {
| |
| position = {px, py, pz},
| |
| direction = {dx, dy, dz},
| |
| ambientColor = {red, green, blue},
| |
| diffuseColor = {red, green, blue},
| |
| specularColor = {red, green, blue},
| |
| intensityWeight = {ambientWeight, diffuseWeight, specularWeight},
| |
|
| |
| -- per-frame decay of ambientColor (spread over TTL frames)
| |
| ambientDecayRate = {ambientRedDecay, ambientGreenDecay, ambientBlueDecay},
| |
| -- per-frame decay of diffuseColor (spread over TTL frames)
| |
| diffuseDecayRate = {diffuseRedDecay, diffuseGreenDecay, diffuseBlueDecay},
| |
| -- per-frame decay of specularColor (spread over TTL frames)
| |
| specularDecayRate = {specularRedDecay, specularGreenDecay, specularBlueDecay},
| |
| -- *DecayType = 0.0 -> interpret *DecayRate values as linear, else as exponential
| |
| decayFunctionType = {ambientDecayType, diffuseDecayType, specularDecayType},
| |
|
| |
| radius = number elmos,
| |
| fov = number degrees,
| |
| ttl = number frames,
| |
| priority = number,
| |
| ignoreLOS = boolean,
| |
| }
| |
|
| |
| = Map =
| |
| '''Spring.SetSkyBoxTexture''' {{new|101.0}}
| |
| ( string texName ) -> nil
| |
|
| |
| '''Spring.SetMapShadingTexture''' {{new|101.0}}
| |
| ( string texType, string texName ) -> boolean success
| |
|
| |
| <div class="note">Example usage: Spring.SetMapShadingTexture("$ssmf_specular", "name_of_my_shiny_texture")</div>
| |
|
| |
| '''Spring.SetMapSquareTexture'''
| |
| ( number texSqrX, number texSqrY, string luaTexName ) -> boolean success
| |
|
| |
| '''Spring.SetMapShader''' {{101.0}}
| |
| ( number standardShaderID, number deferredShaderID ) -> nil
| |
|
| |
| <div class="note">The ID's must refer to valid programs returned by gl.CreateShader. Passing in a value of 0 will cause the respective shader to revert back to its engine default. Custom map shaders that declare a uniform ivec2 named "texSquare" can sample from the default diffuse texture(s), which are always bound to TU 0.</div>
| |
|
| |
|
| [[category: Lua]] | | [[category: Lua]] |