Lua UnsyncedCtrl: Difference between revisions

From Spring
Jump to navigationJump to search
 
(29 intermediate revisions by 6 users not shown)
Line 4: Line 4:


<div class="note">
<div class="note">
NOTE: 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 so you generally don't need to care.</div>
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>


= UI =
= UI =
'''Spring.SetLastMessagePosition'''
 
  ( number x, number y, number z ) -> nil
{{LuaCallout
|prefix = Spring.
|name = SetLastMessagePosition
|arg1 = {{type|number}} x
|arg2 = {{type|number}} y
|arg3 = {{type|number}} z
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}


= Ingame Console =
= Ingame Console =
'''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>
{{LuaCallout
|prefix = Spring.
|name = Echo
|arg1 = {{type|arg1}} {{bracket}}
|arg2 = {{type|arg2}} {{bracket}}
|arg3 = {{type|...}} {{rbracket}}{{rbracket}}
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = Useful for debugging.<br> Prints values in the spring chat console.<br> Hint: the default print() writes to STDOUT.
}}


'''Spring.Log'''
  ( string section, int logLevel | string logLevel,
    arg2 [, arg3 [, ... ] ] ) -> nil


  <font color="#55ee99">Possible values for logLevel are:
{{LuaCallout
|prefix = Spring.
|name = Log
|arg1 = {{type|string}} section
|arg2 = {{type|number}} logLevel {{pipe}} {{type|string}} logLevel
|arg3 = {{type|string}} LogMessage1 {{bracket}}
|arg4 = {{type|string}} LogMessage2{{bracket}}
|arg5 = ... {{rbracket}}{{rbracket}}
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
<pre>Possible values for logLevel are:
     "debug"  | LOG.DEBUG
     "debug"  | LOG.DEBUG
     "info"    | LOG.INFO
     "info"    | LOG.INFO
     "notice"  | LOG.NOTICE (engine default) {{new|97}}
     "notice"  | LOG.NOTICE (engine default) (new in Version 97)
     "warning" | LOG.WARNING
     "warning" | LOG.WARNING
     "error"  | LOG.ERROR
     "error"  | LOG.ERROR
     "fatal"  | LOG.FATAL</font>
     "fatal"  | LOG.FATAL</pre>
 
 
 
{{LuaCallout
|prefix = Spring.
|name = SendCommands
|arg1 = {{type|string}} command1 {{bracket}}
|arg2 = {{type|string}} command2 {{bracket}}
|arg3 = {{type|...}} {{rbracket}}{{rbracket}}
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}


'''Spring.SendCommands''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
or
  ( string command1 [, string command2 [ ... ] ] ) -> nil
 
  ( {string command1, string command2, ...} ) -> nil
{{LuaCallout
|prefix = Spring.
|name = SendCommands
|arg1 = { {{type|string}} command1, {{type|string}} command2, ... }
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}


== GUI ==
== GUI ==
'''Spring.SetActiveCommand''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
 
  ( string action [, string actionExtra ] ) -> nil | boolean
{{LuaCallout
  ( number cmdIndex [, number button = 1
|prefix = Spring.
    [, boolean leftClick, boolean rightClick,
|name = SetActiveCommand
    boolean alt, boolean ctrl, boolean meta, boolean shift]] ) -> nil | boolean
|arg1 = {{type|string}} action {{bracket}}
'''Spring.LoadCmdColorsConfig''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
|arg2 = {{type|string}} actionExtra {{rbracket}}
  ( string config ) -> nil
|arg3 =
'''Spring.LoadCtrlPanelConfig''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
|arg4 =
  ( string config ) -> nil
|arg5 =
'''Spring.ForceLayoutUpdate''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
|arg6 =
  ( ) -> nil
|arg7 =
'''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>
|arg8 =
  ( boolean enable ) -> nil
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} commandSet
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}
 
or
 
{{LuaCallout
|prefix = Spring.
|name = SetActiveCommand
|arg1 = {{type|number}} cmdIndex {{bracket}}
|arg2 = {{type|number}} button = 1 {{bracket}}
|arg3 = {{type|bool}} leftClick {{bracket}}
|arg4 = {{type|bool}} rightClick {{bracket}}
|arg5 = {{type|bool}} alt {{bracket}}
|arg6 = {{type|bool}} ctrl {{bracket}}
|arg7 = {{type|bool}} meta {{bracket}}
|arg8 = {{type|bool}} shift {{rbracket}}{{rbracket}}{{rbracket}}{{rbracket}}{{rbracket}}{{rbracket}}{{rbracket}}
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} commandSet
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = LoadCmdColorsConfig
|arg1 = {{type|string}} config  
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = LoadCtrlPanelConfig
|arg1 = {{type|string}} config  
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}
 
 
 
{{LuaCallout
|prefix = Spring.
|name = ForceLayoutUpdate
|arg1 =
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetDrawSelectionInfo
|arg1 = {{type|bool}} enable
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font><br>Disables the "Selected Units x" box in the GUI.
}}


== Mouse ==
== Mouse ==
'''Spring.SetMouseCursor''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
 
  ( string cursorName [, number scale ] ) -> nil
{{LuaCallout
'''Spring.WarpMouse''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
|prefix = Spring.
  ( number x, number y ) -> nil
|name = SetMouseCursor
|arg1 = {{type|string}} cursorName {{bracket}}
|arg2 = {{type|number}} scale {{rbracket}}
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = WarpMouse
|arg1 = {{type|number}} x
|arg2 = {{type|number}} y
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}


== LOS Colors ==
== LOS Colors ==
'''Spring.SetLosViewColors''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
 
  ( table reds = { number always, number LOS, number radar, number jam },  
{{LuaCallout
|prefix = Spring.
|name = SetLosViewColors
|arg1 = {{type|table}} always = {r,g,b}
|arg2 = {{type|table}} LOS = {r,g,b}
|arg3 = {{type|table}} radar = {r,g,b}
|arg4 = {{type|table}} jam = {r,g,b}
|arg5 = {{type|table}} radar2 = {r,g,b}
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font><br>New arguments since 100.0 (radar2 is the inside of radar edge). Arguments for 99.0 and before:<br>
}}
<pre>( table reds = { number always, number LOS, number radar, number jam },  
     table greens = { number always, number LOS, number radar, number jam },
     table greens = { number always, number LOS, number radar, number jam },
     table blues = { number always, number LOS, number radar, number jam } ) -> nil
     table blues = { number always, number LOS, number radar, number jam } ) -> nil</pre>


== SendMessage ==
== SendMessage ==
'''Spring.SendMessage'''
 
  ( string "message" ) -> nil
{{LuaCallout
'''Spring.SendMessageToPlayer'''
|prefix = Spring.
  ( number playerID, string "message" ) -> nil
|name = SendMessage
'''Spring.SendMessageToTeam'''
|arg1 = {{type|string}} message
  ( number teamID, string "message" ) -> nil
|arg2 =
'''Spring.SendMessageToAllyTeam'''
|arg3 =
  ( number allyID, string "message" ) -> nil
|arg4 =
'''Spring.SendMessageToSpectators'''
|arg5 =
  ( string "message" ) -> nil
|arg6 =
Funfact:
|arg7 =
<PLAYER#> (with # being a playerid) inside the string will be replaced with the players name.
|arg8 =
ie
|arg9 =
Spring.SendMessage ("<PLAYER1> did something")
|return = {{type|nil}}
might display as "ProRusher did something"
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SendMessageToPlayer
|arg1 = {{type|number}} playerID
|arg2 = {{type|string}} message
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SendMessageToTeam
|arg1 = {{type|number}} teamID
|arg2 = {{type|string}} message
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
 
{{LuaCallout
|prefix = Spring.
|name = SendMessageToAllyTeam
|arg1 = {{type|number}} allyID
|arg2 = {{type|string}} message
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SendMessageToSpectators
|arg1 = {{type|string}} message
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <PLAYER#> (with # being a playerid) inside the string will be replaced with the players name - i.e. :<br>Spring.SendMessage ("<PLAYER1> did something")<br>might display as "ProRusher did something"
}}


== Markers ==
== 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>
{{LuaCallout
  ( number x1, number y1, number z1, number x2, number y2, number z2 ) -> nil
|prefix = Spring.
'''Spring.MarkerErasePosition''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
|name = MarkerAddPoint
  ( number x, number y, number z ) -> nil
|arg1 = {{type|number}} x
|arg2 = {{type|number}} y
|arg3 = {{type|number}} z {{bracket}}
|arg4 = {{type|string}} text = "" {{bracket}}
|arg5 = {{type|bool}} localOnly {{rbracket}}{{rbracket}}
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = MarkerAddLine
|arg1 = {{type|number}} x1
|arg2 = {{type|number}} y1
|arg3 = {{type|number}} z1
|arg4 = {{type|number}} x2
|arg5 = {{type|number}} y2
|arg6 = {{type|number}} z2
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = MarkerErasePosition
|arg1 = {{type|number}} x
|arg2 = {{type|number}} y
|arg3 = {{type|number}} z
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}


= Sounds =
= 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>
{{LuaCallout
  ( string "soundfile" [, number volume = 1.0
|prefix = Spring.
    [, number posx, number posy, number posz  
|name = LoadSoundDef
    [, number speedx, number speedy, number speedz ] ] ], [string/number <span class=note>channel</span> ] ) -> nil | boolean
|arg1 = {{type|string}} soundfile
  <span class=note>`channel` is new in Spring0.83, and can be one of those:
|arg2 =
    "general" || 0 || nil (default)
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} success
|info = Loads a SoundDefs file, the format is the same as in `gamedata/sounds.lua`.
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = PlaySoundFile
|arg1 = {{type|string}} soundfile {{bracket}}
|arg2 = {{type|number}} volume = 1.0 {{bracket}}
|arg3 = {{type|number}} posx {{bracket}}
|arg4 = {{type|number}} posy {{bracket}}
|arg5 = {{type|number}} posz {{bracket}}
|arg6 = {{type|number}} speedx{{bracket}}
|arg7 = {{type|number}} speedy{{bracket}}
|arg8 = {{type|number}} speedz{{bracket}}
|arg9 = {{type|number}} {{pipe}} {{type|string}} channel {{rbracket}}{{rbracket}}{{rbracket}}{{rbracket}}{{rbracket}}{{rbracket}}{{rbracket}}{{rbracket}}
|return = {{type|nil}} {{pipe}} {{type|bool}} playSound
|info = Possible arguments for channel argument:
}}
<pre>    "general" || 0 || nil (default)
     "battle" || "sfx" | 1
     "battle" || "sfx" | 1
     "unitreply" || "voice" || 2
     "unitreply" || "voice" || 2
     "userinterface" || "ui" || 3
     "userinterface" || "ui" || 3</pre>
  </span>


'''Spring.PlaySoundStream'''
 
  ( string "oggfile" [, number volume = 1.0
{{LuaCallout
    [, bool enqueue ]] ) -> nil | boolean true
|prefix = Spring.
  <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>
|name = PlaySoundStream
'''Spring.StopSoundStream'''
|arg1 = {{type|string}} oggfile {{bracket}}
  ( ) -> nil
|arg2 = {{type|number}} volume = 1.0 {{bracket}}
  <span class=note>Terminates any SoundStream currently running.</span>
|arg3 = {{type|bool}} enqueue {{rbracket}}{{rbracket}}
'''Spring.PauseSoundStream'''
|arg4 =
  ( ) -> nil
|arg5 =
'''Spring.SetSoundStreamVolume'''
|arg6 =
  ( number volume ) -> nil
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} true
|info = Allows to play an Ogg Vorbis (.OGG) compressed sound file.<br> In 83.0 and up multiple sound streams may be played at once.
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = StopSoundStream
|arg1 =
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = Terminates any SoundStream currently running.
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = PauseSoundStream
|arg1 =
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetSoundStreamVolume
|arg1 = {{type|number}} volume
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}


= SendLuaMessage =
= SendLuaMessage =
<font color="#55ee99">Very important! (allows synced inter-lua-enviroment communications)</font>
<font color="#55ee99">Very important! (allows synced inter-lua-enviroment communications)</font>


'''Spring.SendLuaUIMsg''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
{{LuaCallout
  ( string message, string mode ) -> nil
|prefix = Spring.
  <font color="#55ee99">possible modes are:<br>"s"/"specs" & "a"/"allies"</font>
|name = SendLuaUIMsg
'''Spring.SendLuaGaiaMsg''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
|arg1 = {{type|string}} message
  ( string message ) -> nil
|arg2 = {{type|string}} mode
'''Spring.SendLuaRulesMsg''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
|arg3 =
  ( string message ) -> nil
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font><br>Possible modes are:<br>"s"/"specs" & "a"/"allies"
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SendLuaGaiaMsg
|arg1 = {{type|string}} message
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SendLuaRulesMsg
|arg1 = {{type|string}} message
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}


= AI =
= AI =
'''Spring.SendSkirmishAIMessage''' {{new|83.0}}
 
  ( number aiTeam, string message )
{{LuaCallout
  -> nil | boolean ai_processed, { [1] = string response1, etc... }
|prefix = Spring.
<span class="note">Note there is nothing in this table due to "limitations" of the AI interface.</span>
|name = SendSkirmishAIMessage
|arg1 = {{type|number}} aiTeam
|arg2 = {{type|string}} message
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} ai_processed, { {{bracket|1}} = {{type|string}} response1, ... }
|info = {{new|83.0}}<br>Note there is nothing in this table due to "limitations" of the AI interface.
}}


= Units =
= Units =
'''Spring.SetUnitLeaveTracks''' {{new|83.0}}
 
  ( number unitID, boolean leavetracks ) -> nil
{{LuaCallout
|prefix = Spring.
|name = SetUnitLeaveTracks
|arg1 = {{type|number}} unitID
|arg2 = {{type|bool}} leavetracks
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|83.0}}
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetUnitSelectionVolumeData
|arg1 = {{type|number}} featureID
|arg2 = {{type|number}} scaleX, {{type|number}} scaleY, {{type|number}} scaleZ
|arg3 = {{type|number}} offsetX, {{type|number}} offsetY, {{type|number}} offsetZ
|arg4 = {{type|number}} vType
|arg5 = {{type|number}} tType
|arg6 = {{type|number}} Axis
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|104.0}}
}}


== Unit Selection ==
== Unit Selection ==
'''Spring.SelectUnitMap'''
  ( { [unitID] = anything, ...} [,boolean append] ) -> nil
'''Spring.SelectUnitArray'''
  ( { [1] = unitID1 , [2] = unitID2 , ...} [,boolean append] ) -> nil


'''Spring.SetDrawSelectionInfo'''
{{LuaCallout
  ( boolean drawSelectionInfo ) -> nil
|prefix = Spring.
|name = SelectUnitMap
|arg1 = { {{bracket|unitID}} = anything, ... } {{bracket}}
|arg2 = {{type|bool}} append {{rbracket}}
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SelectUnitArray
|arg1 = { {{bracket|1}} = unitID1, {{bracket|2}} = unitID2, ... } {{bracket}}
|arg2 = {{type|bool}} append {{rbracket}}
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
 
{{LuaCallout
|prefix = Spring.
|name = SetDrawSelectionInfo
|arg1 = {{type|bool}} drawSelectionInfo
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}


== Unit Group ==
== Unit Group ==
'''Spring.SetUnitGroup''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
 
  ( number unitID, number groupID ) -> nil
{{LuaCallout
|prefix = Spring.
|name = SetUnitGroup
|arg1 = {{type|number}} unitID
|arg2 = {{type|number}} groupID
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}


== Give Order ==
== 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>
{{LuaCallout
|prefix = Spring.
|name = GiveOrder
|arg1 = {{type|number}} cmdID
|arg2 = {{type|table}} params = {number, etc...}
|arg3 = {{type|table}} options = {"alt", "ctrl", "shift", "right"}
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} true
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font><br>Gives order to all selected units.
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = GiveOrderToUnit
|arg1 = {{type|number}} unitID
|arg2 = {{type|number}} cmdID
|arg3 = {{type|table}} params = {number, etc...}
|arg4 = {{type|table}} options = {"alt", "ctrl", "shift", "right"}
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} true
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = GiveOrderToUnitMap
|arg1 = {{type|table}} unitMap = { {{bracket|unitID}} = arg1, etc... }
|arg2 = {{type|number}} cmdID
|arg3 = {{type|table}} params = {number, etc...}
|arg4 = {{type|table}} options = {"alt", "ctrl", "shift", "right"}
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} true
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = GiveOrderToUnitArray
|arg1 = {{type|table}} unitArray = { {{bracket|1}} = {{type|number}} unitID, etc... }
|arg2 = {{type|number}} cmdID
|arg3 = {{type|table}} params = {number, etc...}
|arg4 = {{type|table}} options = {"alt", "ctrl", "shift", "right"}
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} true
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = GiveOrderArrayToUnitMap
|arg1 = {{type|table}} unitMap = { {{bracket|unitID}} = arg1, etc... }
|arg2 = {{type|table}} orderArray = { {{type|number}} cmdID, {{type|table}} params = {number, etc...}, {{type|table}} options = {"alt", "ctrl", "shift", "right"} }
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} true
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = GiveOrderArrayToUnitArray
|arg1 = {{type|table}} unitArray = { {{bracket|11}} = {{type|number}} unitID, etc... }
|arg2 = {{type|table}} orderArray = { {{type|number}} cmdID, {{type|table}} params = {number, etc...}, {{type|table}} options = {"alt", "ctrl", "shift", "right"} } {{bracket}}
|arg3 = {{type|bool}} pairwise {{rbracket}}
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} true
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font><br>"pairwise" paramater ({{new|89.0}}) is used to send multiple units a single individual command.
}}
 
 


{{LuaCallout
|prefix = Spring.
|name = SetBuildFacing
|arg1 = {{type|number}} facing
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}


'''Spring.SetBuildFacing'''
  ( int Facing ) -> nil


'''Spring.SetBuildSpacing'''
{{LuaCallout
  ( int Spacing ) -> nil
|prefix = Spring.
|name = SetBuildSpacing
|arg1 = {{type|number}} spacing
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}


== Unit NoDraw,NoSelect,NoMinimap ==
== Unit NoDraw,NoSelect,NoMinimap ==
'''Spring.SetUnitNoDraw''' <font color="red">LuaGadgets only!</font>
 
  ( number unitID, boolean noDraw ) -> nil
 
'''Spring.SetUnitNoSelect''' <font color="red">LuaGadgets only!</font>
{{LuaCallout
  ( number unitID, boolean noSelect ) -> nil
|prefix = Spring.
'''Spring.SetUnitNoMinimap''' <font color="red">LuaGadgets only!</font>
|name = SetUnitNoDraw
  ( number unitID, boolean noMinimap ) -> nil
|arg1 = {{type|number}} unitID
|arg2 = {{type|bool}} noDraw
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">LuaGadgets only!</font>
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetUnitNoSelect
|arg1 = {{type|number}} unitID
|arg2 = {{type|bool}} noSelect
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">LuaGadgets only!</font>
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetUnitNoMinimap
|arg1 = {{type|number}} unitID
|arg2 = {{type|bool}} noMinimap
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">LuaGadgets only!</font>
}}
 
= Features =
 
{{LuaCallout
|prefix = Spring.
|name = SetFeatureFade
|arg1 = {{type|number}} featureID
|arg2 = {{type|bool}} allow
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|101.0}}<br>Control whether a feature will fade or not when zoomed out.
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetFeatureNoDraw
|arg1 = {{type|number}} featureID
|arg2 = {{type|bool}} noDraw
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">LuaGadgets only!</font>
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetFeatureSelectionVolumeData
|arg1 = {{type|number}} featureID
|arg2 = {{type|number}} scaleX, {{type|number}} scaleY, {{type|number}} scaleZ
|arg3 = {{type|number}} offsetX, {{type|number}} offsetY, {{type|number}} offsetZ
|arg4 = {{type|number}} vType
|arg5 = {{type|number}} tType
|arg6 = {{type|number}} Axis
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|104.0}}
}}


= Developers =
= Developers =
'''Spring.SetDrawSky'''
  ( boolean drawSky ) -> nil
'''Spring.SetDrawWater'''
  ( boolean drawWater ) -> nil
'''Spring.SetDrawGround'''
  ( boolean drawGround ) -> nil


'''Spring.SetWaterParams''' <span class=warning>needs cheating enabled!</span>
{{LuaCallout
  ( table params ) -> nil
|prefix = Spring.
<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>
|name = SetDrawSky
  <span class=note>`params` table may contain:
|arg1 = {{type|bool}} drawSky
  params = {
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetDrawWater
|arg1 = {{type|bool}} drawWater
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetDrawGround
|arg1 = {{type|bool}} drawGround
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetWaterParams
|arg1 = {{type|table}} params
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = As of 104.0 no longer needs cheating enabled.<br>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`. "Params" table contains:
}}
<pre> params = {
     absorb = {number r, number g, number b},
     absorb = {number r, number g, number b},
     baseColor = {number r, number g, number b},
     baseColor = {number r, number g, number b},
Line 247: Line 1,030:
     forceRendering = boolean value,
     forceRendering = boolean value,
     hasWaterPlane = boolean value,
     hasWaterPlane = boolean value,
   }</span>
   }</pre>
 
 
{{LuaCallout
|prefix = Spring.
|name = SetMapRenderingParams
|arg1 = {{type|table}} params
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|104.0}}<br>Allows to change map rendering params at runtime.<br>"Params" table contains:
}}
<pre>  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,
  }</pre>
 
 
 
{{LuaCallout
|prefix = Spring.
|name = SetLogSectionFilterLevel
|arg1 = {{type|string}} sectionName
|arg2 = {{type|string}} {{pipe}} {{type|number}} logLevel
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{New|95.0}}<br>See [[infolog.txt]] for possible log sections.
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetDrawGroundDeferred
|arg1 = {{type|bool}} drawGroundDeferred {{bracket}}
|arg2 = {{type|bool}} drawGroundForward {{rbracket}}
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|101.0}} {{var|drawGroundForward}} allows disabling of the forward pass
}}
 
 
 
 
{{LuaCallout
|prefix = Spring.
|name = SetDrawModelsDeferred
|arg1 = {{type|bool}} drawUnitsDeferred
|arg2 = {{type|bool}} drawFeaturesDeferred {{bracket}}
|arg3 = {{type|bool}} drawUnitsForward {{bracket}}
|arg4 = {{type|bool}} drawFeaturesForward  {{rbracket}}{{rbracket}}
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|101.0}} {{var|drawFeaturesForward}}, {{var|drawUnitsForward}} allows disabling of the respective forward passes
}}


'''Spring.SetLogSectionFilterLevel''' {{New|95.0}}
  (string sectionName, string|number logLevel)
see [[infolog.txt]] for possible log sections (?)


'''Spring.SetDrawGroundDeferred''' {{New|95.0}}
{{LuaCallout
    (boolean) -> nil
|prefix = Spring.
'''Spring.SetDrawModelsDeferred''' {{New|95.0}}
|name = SetVideoCapturingMode
    (boolean) -> nil
|arg1 = {{type|bool}} allowCaptureMode
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|104.0}}<br>This doesn't actually record the game in any way, it just regulates the framerate and interpolations.
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetVideoCapturingTimeOffset
|arg1 = {{type|bool}} timeOffset
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|104.0}}
}}


= GUI =
= GUI =
'''Spring.DrawUnitCommands'''
  ( number unitID ) -> nil
  ( { [1] = unitID, ... } [, false ] ) -> nil
  ( { [unitID] = anything, ... }, true  ) -> nil


'''Spring.SetTeamColor'''
{{LuaCallout
  ( number teamID, number r, number g, number b ) -> nil
|prefix = Spring.
|name = DrawUnitCommands
|arg1 = {{type|number}} unitID
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|104.0}}
}}
 
or
 
{{LuaCallout
|prefix = Spring.
|name = DrawUnitCommands
|arg1 = {{type|table}} units = { {{bracket|1}} = unitID, ... } {{bracket}}
|arg2 = {{type|bool}} false
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
or
 
{{LuaCallout
|prefix = Spring.
|name = DrawUnitCommands
|arg1 = {{type|table}} units = { {{bracket|unitID}} = arg1, ... }
|arg2 = {{type|bool}} true
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetTeamColor
|arg1 = {{type|number}} teamID
|arg2 = {{type|number}} r
|arg3 = {{type|number}} g
|arg4 = {{type|number}} b
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
 
{{LuaCallout
|prefix = Spring.
|name = AssignMouseCursor
|arg1 = {{type|string}} cmdName
|arg2 = {{type|string}} iconFileName {{bracket}}
|arg3 = {{type|bool}} overwrite = true {{bracket}}
|arg4 = {{type|bool}} hotSpotTopLeft = false {{rbracket}}{rbracket}}
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} assigned
|info = Changes/creates the cursor of a single CursorCmd. Note, that iconFileName is not the full filename instead it is like this:<br/>Wanted filename: Anims/cursorattack_0.bmp<br/>=> iconFileName: cursorattack
}}


'''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>
{{LuaCallout
  ( string "oldFileName", string "newFileName" [, boolean hotSpotTopLeft = false] ) -> nil | boolean
|prefix = Spring.
|name = ReplaceMouseCursor
|arg1 = {{type|string}} oldFileName
|arg2 = {{type|string}} newFileName {{bracket}}
|arg3 = {{type|bool}} hotSpotTopLeft = false {{rbracket}}
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} assigned
|info = Mass replace all occurrence of the cursor in all CursorCmds.
}}


'''Spring.SetCustomCommandDrawData''' <font class=note>register your custom cmd so it gets visible in the unit's cmd queue</font>
 
  ( number cmdID,
{{LuaCallout
    number cmdID_cloneIcon | string iconname,
|prefix = Spring.
    { number r, number g, number b, number a } [, boolean showArea ] ) -> nil
|name = SetCustomCommandDrawData
  ( number cmdID, nil) -> nil
|arg1 = {{type|number}} cmdID
|arg2 = {{type|number}} cmdID_cloneIcon {{pipe}} {{type|string}} iconname
|arg3 = {{type|table}} RGBA = { {{type|number}} r, {{type|number}} g, {{type|number}} b, {{type|number}} a } {{bracket}}
|arg4 = {{type|bool}} showArea {{rbracket}}
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} assigned
|info = Register your custom cmd so it gets visible in the unit's cmd queue
}}
 
or
 
{{LuaCallout
|prefix = Spring.
|name = SetCustomCommandDrawData
|arg1 = {{type|number}} cmdID
|arg2 = {{type|nil}}
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} assigned
|info = Register your custom cmd so it gets visible in the unit's cmd queue
}}


= Sharing =
= 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
{{LuaCallout
'''Spring.ShareResources''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
|prefix = Spring.
  ( number teamID, string "units" ) -> nil
|name = SetShareLevel
  ( number teamID, string "metal" | "energy", number amount ) -> nil
|arg1 = {{type|string}} metal {{pipe}} {{type|string}} energy
|arg2 = {{type|number}} shareLevel
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">LuaGadgets only!</font><br>Note: shareLevel is 0<= x <= 1 .
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = ShareResources
|arg1 = {{type|number}} teamID
|arg2 = {{type|string}} units
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">LuaGadgets only!</font>
}}
 
or
 
 
{{LuaCallout
|prefix = Spring.
|name = ShareResources
|arg1 = {{type|number}} teamID
|arg2 = {{type|string}} metal {{pipe}} {{type|string}} energy
|arg3 = {{type|number}} amount
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">LuaGadgets only!</font>
}}


= UnitDef RadarIcons & BuildPics =
= UnitDef RadarIcons & BuildPics =
'''Spring.AddUnitIcon'''
 
  ( string iconName, string texFile [, number size [, number dist [, boolean radAdjust ]]] )
{{LuaCallout
  -> nil | boolean
|prefix = Spring.
'''Spring.FreeUnitIcon'''
|name = AddUnitIcon
  ( string iconName ) -> nil | boolean
|arg1 = {{type|string}} iconName
'''Spring.SetUnitDefIcon'''  <font color="#55ee99">(RadarIcon)</font> <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
|arg2 = {{type|string}} texFile {{bracket}}
  ( number unitDefID, string iconName ) -> nil
|arg3 = {{type|number}} size {{bracket}}
'''Spring.SetUnitDefImage'''  <font color="#55ee99">(BuildPic)</font> <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
|arg4 = {{type|number}} dist {{bracket}}
  ( number unitDefID, luaTexture | string texFile ) -> nil
|arg5 = {{type|bool}} radAdjust {{rbracket}}{{rbracket}}{{rbracket}}
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} added
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = FreeUnitIcon
|arg1 = {{type|string}} iconName
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} freed
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetUnitDefIcon
|arg1 = {{type|number}} unitDefID
|arg2 = {{type|string}} iconName
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font><br>Sets radar icon.
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetUnitDefImage
|arg1 = {{type|number}} unitDefID
|arg2 = {{type|string}} luaTexture {{pipe}} {{type|string}} texFile
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font><br>Sets buildpic.
}}


= Camera =
= 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.</font>


'''Spring.SetCameraTarget'''
{{LuaCallout
  ( number x, number y, number z [,number transTime] ) -> nil
|prefix = Spring.
<font color="#55ee99">For Spring Engine XZ represents horizontal, from north west corner of map and Y vertical, from water level and rising.</font>
|name = SetCameraState
|arg1 = {{type|table}} camState
|arg2 = {{type|number}} camTime
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} stateSet
|info = camState has the same format as the output of Spring.GetCameraState(). See [[Lua_camState]] for details about camState.<br>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]
}}


'''Spring.SetCameraOffset''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
 
  ( [number px = 0 [, number py = 0 [, number pz = 0
{{LuaCallout
    [, number tx = 0 [, number ty = 0 [, number tz = 0]]]]]] ) -> nil
|prefix = Spring.
|name = SetCameraTarget
|arg1 = {{type|number}} x, {{type|number}} y, {{type|number}} z {{bracket}}
|arg2 = {{type|number}} transTime {{rbracket}}
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = For Spring Engine XZ represents horizontal, from north west corner of map and Y vertical, from water level and rising.
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetCameraOffset
|arg1 = {{type|number}} px = 0 {{bracket}}
|arg2 = {{type|number}} py = 0 {{bracket}}
|arg3 = {{type|number}} pz = 0 {{bracket}}
|arg4 = {{type|number}} tx = 0 {{bracket}}
|arg5 = {{type|number}} ty = 0 {{bracket}}
|arg6 = {{type|number}} tz = 0 {{rbracket}}{{rbracket}}{{rbracket}}{{rbracket}}{{rbracket}}
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}


= (Virtual-)FileSystem =
= (Virtual-)FileSystem =
'''Spring.ExtractModArchiveFile'''
 
  ( string modfile ) -> boolean
{{LuaCallout
'''Spring.CreateDir''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
|prefix = Spring.
  ( number path ) -> nil | boolean
|name = ExtractModArchiveFile
|arg1 = {{type|string}} modfile
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|bool}} extracted
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = CreateDir
|arg1 = {{type|string}} path
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|bool}} dirCreated
|info = <font color="maroon" style="font-weight:600">Needs ModUICtrl.</font>
}}
 
The full VFS API is available at [[Lua_VFS|link]].


= Engine Config =
= Engine Config =
<font color="#55ee99">The following functions read the engine configs saved in [[springrc]], 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</font>


'''Spring.GetConfigInt''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
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.
  ( string name [, number default [, boolean setInOverlay = false]] ) -> nil | number
If ''*Overlay'' is ''true'', the value will only be set in memory, and not be restored for the next game.
'''Spring.SetConfigInt''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
 
  ( string name, number value [, boolean useOverlay = false] ) -> nil
{{LuaCallout
'''Spring.GetConfigString''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
|prefix = Spring.
  ( string name [, string default [, boolean setInOverlay = false]] ) -> nil | string
|name = SetConfigInt
'''Spring.SetConfigString''' <font color="red" style="font-weight:600">(needs ModUICtrl)</font>
|arg1 = {{type|string}} name
  ( string name, string value [, boolean useOverlay = false] ) -> nil
|arg2 = {{type|number}} value {{bracket}}
|arg3 = {{type|bool}} useOverlay = false {{rbracket}}
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
 
{{LuaCallout
|prefix = Spring.
|name = SetConfigFloat
|arg1 = {{type|string}} name
|arg2 = {{type|number}} value {{bracket}}
|arg3 = {{type|bool}} useOverlay = false {{rbracket}}
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =  
|arg9 =  
|return = {{type|nil}}
|info = {{new|104.0}}
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetConfigString
|arg1 = {{type|string}} name
|arg2 = {{type|number}} value {{bracket}}
|arg3 = {{type|bool}} useOverlay = false {{rbracket}}
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|104.0}}
}}


= World Primitives =
= World Primitives =
<font color="red" style="font-weight:600">outdated! use opengl api instead!</font>
<font color="red" style="font-weight:600">outdated! use opengl api instead!</font>


'''Spring.AddWorldIcon'''
{{LuaCallout
  ( number cmdID, number x, number y, number z ) -> nil
|prefix = Spring.
'''Spring.AddWorldText'''
|name = AddWorldIcon
  ( string "text", number x, number y, number z ) -> nil
|arg1 = {{type|number}} cmdID
'''Spring.AddWorldUnit'''
|arg2 = {{type|number}} x, {{type|number}} y, {{type|number}} z
  ( number unitDefID,
|arg3 =
    number x, number y, number z,
|arg4 =
    number team, number facing) -> nil
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = AddWorldText
|arg1 = {{type|string}} text
|arg2 = {{type|number}} x, {{type|number}} y, {{type|number}} z
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = AddWorldUnit
|arg1 = {{type|number}} unitDefID
|arg2 = {{type|number}} x, {{type|number}} y, {{type|number}} z
|arg3 = {{type|number}} team
|arg4 = {{type|number}} facing
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}


= Sun  =
= Sun  =
'''Spring.SetSunManualControl'''
The dynamic Sun must be invoked via /dynamicsun (Dynamic sun was removed in 104.0, use SetSunDirection, SetSunLighting & SetAtmosphere instead).
  ( boolean setManualControl ) - > nil


'''Spring.SetSunParameters'''
{{LuaCallout
  ( number dirX, number dirY, number dirZ, number dist, number startTime, number orbitTime ) -> nil
|prefix = Spring.
|name = SetSunManualControl
|arg1 = {{type|bool}} setManualControl
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{removed|104.0}}
}}


'''Spring.SetSunDirection'''
 
  ( number dirX, number dirY, number dirZ ) -> nil
 
{{LuaCallout
|prefix = Spring.
|name = SetSunParameters
|arg1 = {{type|number}} dirX
|arg2 = {{type|number}} dirY
|arg3 = {{type|number}} dirZ
|arg4 = {{type|number}} dist
|arg5 = {{type|number}} startTime
|arg6 = {{type|number}} orbitTime
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{removed|104.0}}
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetSunDirection
|arg1 = {{type|number}} dirX
|arg2 = {{type|number}} dirY
|arg3 = {{type|number}} dirZ
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetSunLighting
|arg1 = {{type|table}} params
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|101.0}}<br>It can be used to modify the following sun lighting parameters:
}}
<pre>    {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} })</pre>
 
 
{{LuaCallout
|prefix = Spring.
|name = SetAtmosphere
|arg1 = {{type|table}} params
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|101.0}}<br>It can be used to modify the following atmosphere parameters:
}}
<pre>    fog{Start,End}, {sun,sky,cloud}Color
    Example usage: Spring.SetAtmosphere({ fogStart = 0, fogEnd  = 0.5, fogColor = { 0.7, 0.2, 0.2, 1 }})</pre>


= Misc =
= Misc =


'''Spring.Reload''' {{new|99.0}}
{{LuaCallout
  ( string startscript )
|prefix = Spring.
<font color="#55ee99">start-script is the CONTENT of the [[script.txt]] spring should use to start.</font>
|name = Reload
|arg1 = {{type|string}} startscript
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = -
|info = {{new|99.0}}<br>start-script is the CONTENT of the [[script.txt]] spring should use to start.
}}


'''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>


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


{{LuaCallout
|prefix = Spring.
|name = Restart
|arg1 = {{type|string}} commandline_args
|arg2 = {{type|string}} startscript
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = -
|info = {{new|0.79}}<br>If this call returns, something went wrong.<br>''commandline_args'' are commandline arguments passed to spring executable.
}}


'''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>


{{LuaCallout
|prefix = Spring.
|name = Start
|arg1 = {{type|string}} commandline_args
|arg2 = {{type|string}} startscript
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = -
|info = {{new|102.0}}<br>If this call returns, something went wrong.<br>Launches a new Spring instance without terminating the existing one.<br>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''.
}}


'''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>
{{LuaCallout
|prefix = Spring.
|name = SetWMIcon
|arg1 = {{type|string}} iconFileName
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|83.0}}<br>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 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>
{{LuaCallout
|prefix = Spring.
|name = SetWMCaption
|arg1 = {{type|string}} title {{bracket}}
|arg2 = {{type|string}} titleShort = title {{rbracket}}
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|83.0}}<br>Sets the window ''title'' for the process (default: "Spring <version>").<br>The ''shortTitle'' is displayed in the OS task-bar (default: "Spring <version>").<br>'''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.
}}




'''Spring.ClearWatchdogTimer''' {{new|83.0}}
{{LuaCallout
  ( [ string threadName = main ] ) -> nil
|prefix = Spring.
|name = ClearWatchDogTimer
|arg1 = {{bracket}} {{type|string}} threadName = main {{rbracket}}
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|83.0}}
}}




'''Spring.SetClipboard''' {{new|98.0}}
{{LuaCallout
  ( string text) -> nil
|prefix = Spring.
|name = SetClipboard
|arg1 = {{type|string}} text
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|98.0}}
}}


= Rendering =
= 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.
{{LuaCallout
|prefix = Spring.
|name = PreloadUnitDefModel
|arg1 = {{type|number}} unitDefID
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{{new|101.0}}
}}
{{LuaCallout
|prefix = Spring.
|name = PreloadFetureDefModel
|arg1 = {{type|number}} featureDefID
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{{new|101.0}}
}}
== Lighting ==
<font color="red" style="font-weight:600">NOTE: these (0.83+) lighting callouts only work when called from unsynced gadgets!</font>
<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 &gt; 0)</font>
{{LuaCallout
  (table lightParams) -> number lightHandle
|prefix = Spring.
'''Spring.AddModelLight''' <font color="red" style="font-weight:600">(requires MaxDynamicModelLights &gt; 0)</font>
|name = AddMapLight
  (table lightParams) -> number lightHandle
|arg1 = {{type|table}} lightParams
|arg2 =  
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =  
|return = {{type|number}} lightHandle
|info = (requires MaxDynamicMapLights &gt; 0)
}}


'''Spring.UpdateMapLight'''
  (number lightHandle, table lightParams) -> boolean success
'''Spring.UpdateModelLight'''
  (number lightHandle, table lightParams) -> boolean success


'''Spring.SetMapLightTrackingState'''
{{LuaCallout
  (number lightHandle, number unitOrProjectileID,
|prefix = Spring.
  boolean enableTracking, boolean unitOrProjectile) -> boolean success
|name = AddModelLight
'''Spring.SetModelLightTrackingState'''
|arg1 = {{type|table}} lightParams
  (number lightHandle, number unitOrProjectileID,
|arg2 =
  boolean enableTracking, boolean unitOrProjectile) -> boolean success
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|number}} lightHandle
|info = (requires MaxDynamicMapLights &gt; 0)
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = UpdateMapLight
|arg1 = {{type|number}} lightHandle
|arg2 = {{type|table}} lightParams
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|bool}} success
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = UpdateModelLight
|arg1 = {{type|number}} lightHandle
|arg2 = {{type|table}} lightParams
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|bool}} success
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetMapLightTrackingState
|arg1 = {{type|number}} lightHandle
|arg2 = {{type|number}} unitOrProjectileID
|arg3 = {{type|bool}} enableTracking
|arg4 = {{type|bool}} unitOrProjectile
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|bool}} success
|info =
}}
 
 
{{LuaCallout
|prefix = Spring.
|name = SetModelLightTrackingState
|arg1 = {{type|number}} lightHandle
|arg2 = {{type|number}} unitOrProjectileID
|arg3 = {{type|bool}} enableTracking
|arg4 = {{type|bool}} unitOrProjectile
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|bool}} success
|info =
}}
 


'''lightParams''' is a table that should contain at least one of the following recognized key/value pairs:
'''lightParams''' is a table that should contain at least one of the following recognized key/value pairs:
Line 442: Line 1,988:
     }
     }


= Map =
{{LuaCallout
|prefix = Spring.
|name = SetSkyBoxTexture
|arg1 = {{type|string}} texName
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|101.0}}
}}
{{LuaCallout
|prefix = Spring.
|name = SetMapShadingTexture
|arg1 = {{type|string}} texType
|arg2 = {{type|string}} texName
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|bool}} success
|info = {{new|101.0}}
}}
<div class="note">Example usage: Spring.SetMapShadingTexture("$ssmf_specular", "name_of_my_shiny_texture")</div>
{{LuaCallout
|prefix = Spring.
|name = SetMapSquareTexture
|arg1 = {{type|number}} texSqrX
|arg2 = {{type|number}} texSqrY
|arg3 = {{type|string}} luaTexName
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|bool}} success
|info =
}}
{{LuaCallout
|prefix = Spring.
|name = SetMapShader
|arg1 = {{type|number}} standardShaderID
|arg2 = {{type|number}} deferredShaderID
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = {{new|101.0}}
}}


'''Spring.SetMapSquareTexture'''
<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>
  (number texSqrX, number texSqrY, string luaTexName) -> boolean success


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

Latest revision as of 16:22, 2 June 2022

Development < Lua Scripting < Lua UnsyncedCtrl


NOTE: Prior to 102.0, entries below marked (needs ModUICtrl) 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.

UI

Spring.SetLastMessagePosition ( number x, number y, number z )
return: nil

Ingame Console

Spring.Echo ( arg1 [, arg2 [, ... ]] )
return: nil

Useful for debugging.
Prints values in the spring chat console.
Hint: the default print() writes to STDOUT.


Spring.Log ( string section, number logLevel | string logLevel, string LogMessage1 [, string LogMessage2[, ... ]] )
return: nil

Possible values for logLevel are:
    "debug"   | LOG.DEBUG
    "info"    | LOG.INFO
    "notice"  | LOG.NOTICE (engine default) (new in Version 97)
    "warning" | LOG.WARNING
    "error"   | LOG.ERROR
    "fatal"   | LOG.FATAL


Spring.SendCommands ( string command1 [, string command2 [, ... ]] )
return: nil

Needs ModUICtrl.

or

Spring.SendCommands ( { string command1, string command2, ... } )
return: nil

Needs ModUICtrl.

GUI

Spring.SetActiveCommand ( string action [, string actionExtra ] )
return: nil | bool commandSet

Needs ModUICtrl.

or

Spring.SetActiveCommand ( number cmdIndex [, number button = 1 [, bool leftClick [, bool rightClick [, bool alt [, bool ctrl [, bool meta [, bool shift ]]]]]]] )
return: nil | bool commandSet

Needs ModUICtrl.


Spring.LoadCmdColorsConfig ( string config )
return: nil

Needs ModUICtrl.


Spring.LoadCtrlPanelConfig ( string config )
return: nil

Needs ModUICtrl.


Spring.ForceLayoutUpdate ( )
return: nil

Needs ModUICtrl.


Spring.SetDrawSelectionInfo ( bool enable )
return: nil

Needs ModUICtrl.
Disables the "Selected Units x" box in the GUI.

Mouse

Spring.SetMouseCursor ( string cursorName [, number scale ] )
return: nil

Needs ModUICtrl.


Spring.WarpMouse ( number x, number y )
return: nil

Needs ModUICtrl.

LOS Colors

Spring.SetLosViewColors ( table always = {r,g,b}, table LOS = {r,g,b}, table radar = {r,g,b}, table jam = {r,g,b}, table radar2 = {r,g,b} )
return: nil

Needs ModUICtrl.
New arguments since 100.0 (radar2 is the inside of radar edge). Arguments for 99.0 and before:
( table reds = { number always, number LOS, number radar, number jam }, 
    table greens = { number always, number LOS, number radar, number jam },
    table blues = { number always, number LOS, number radar, number jam } ) -> nil

SendMessage

Spring.SendMessage ( string message )
return: nil


Spring.SendMessageToPlayer ( number playerID, string message )
return: nil


Spring.SendMessageToTeam ( number teamID, string message )
return: nil


Spring.SendMessageToAllyTeam ( number allyID, string message )
return: nil


Spring.SendMessageToSpectators ( string message )
return: nil

<PLAYER#> (with # being a playerid) inside the string will be replaced with the players name - i.e. :
Spring.SendMessage ("<PLAYER1> did something")
might display as "ProRusher did something"

Markers

Spring.MarkerAddPoint ( number x, number y, number z [, string text = "" [, bool localOnly ]] )
return: nil

Needs ModUICtrl.


Spring.MarkerAddLine ( number x1, number y1, number z1, number x2, number y2, number z2 )
return: nil

Needs ModUICtrl.


Spring.MarkerErasePosition ( number x, number y, number z )
return: nil

Needs ModUICtrl.

Sounds

Spring.LoadSoundDef ( string soundfile )
return: nil | bool success

Loads a SoundDefs file, the format is the same as in `gamedata/sounds.lua`.


Spring.PlaySoundFile ( string soundfile [, number volume = 1.0 [, number posx [, number posy [, number posz [, number speedx[, number speedy[, number speedz[, number | string channel ]]]]]]]] )
return: nil | bool playSound

Possible arguments for channel argument:
    "general" || 0 || nil (default)
    "battle" || "sfx" | 1
    "unitreply" || "voice" || 2
    "userinterface" || "ui" || 3


Spring.PlaySoundStream ( string oggfile [, number volume = 1.0 [, bool enqueue ]] )
return: nil | bool true

Allows to play an Ogg Vorbis (.OGG) compressed sound file.
In 83.0 and up multiple sound streams may be played at once.


Spring.StopSoundStream ( )
return: nil

Terminates any SoundStream currently running.


Spring.PauseSoundStream ( )
return: nil


Spring.SetSoundStreamVolume ( number volume )
return: nil

SendLuaMessage

Very important! (allows synced inter-lua-enviroment communications)

Spring.SendLuaUIMsg ( string message, string mode )
return: nil

Needs ModUICtrl.
Possible modes are:
"s"/"specs" & "a"/"allies"


Spring.SendLuaGaiaMsg ( string message )
return: nil

Needs ModUICtrl.


Spring.SendLuaRulesMsg ( string message )
return: nil

Needs ModUICtrl.

AI

Spring.SendSkirmishAIMessage ( number aiTeam, string message )
return: nil | bool ai_processed, { [1] = string response1, ... }

New in version 83.0
Note there is nothing in this table due to "limitations" of the AI interface.

Units

Spring.SetUnitLeaveTracks ( number unitID, bool leavetracks )
return: nil

New in version 83.0


Spring.SetUnitSelectionVolumeData ( number featureID, number scaleX, number scaleY, number scaleZ, number offsetX, number offsetY, number offsetZ, number vType, number tType, number Axis )
return: nil

New in version 104.0

Unit Selection

Spring.SelectUnitMap ( { [unitID] = anything, ... } [, bool append ] )
return: nil


Spring.SelectUnitArray ( { [1] = unitID1, [2] = unitID2, ... } [, bool append ] )
return: nil


Spring.SetDrawSelectionInfo ( bool drawSelectionInfo )
return: nil

Unit Group

Spring.SetUnitGroup ( number unitID, number groupID )
return: nil

Needs ModUICtrl.

Give Order

Spring.GiveOrder ( number cmdID, table params = {number, etc...}, table options = {"alt", "ctrl", "shift", "right"} )
return: nil | bool true

Needs ModUICtrl.
Gives order to all selected units.


Spring.GiveOrderToUnit ( number unitID, number cmdID, table params = {number, etc...}, table options = {"alt", "ctrl", "shift", "right"} )
return: nil | bool true

Needs ModUICtrl.


Spring.GiveOrderToUnitMap ( table unitMap = { [unitID] = arg1, etc... }, number cmdID, table params = {number, etc...}, table options = {"alt", "ctrl", "shift", "right"} )
return: nil | bool true

Needs ModUICtrl.


Spring.GiveOrderToUnitArray ( table unitArray = { [1] = number unitID, etc... }, number cmdID, table params = {number, etc...}, table options = {"alt", "ctrl", "shift", "right"} )
return: nil | bool true

Needs ModUICtrl.


Spring.GiveOrderArrayToUnitMap ( table unitMap = { [unitID] = arg1, etc... }, table orderArray = { number cmdID, table params = {number, etc...}, table options = {"alt", "ctrl", "shift", "right"} } )
return: nil | bool true

Needs ModUICtrl.


Spring.GiveOrderArrayToUnitArray ( table unitArray = { [11] = number unitID, etc... }, table orderArray = { number cmdID, table params = {number, etc...}, table options = {"alt", "ctrl", "shift", "right"} } [, bool pairwise ] )
return: nil | bool true

Needs ModUICtrl.
"pairwise" paramater (New in version 89.0) is used to send multiple units a single individual command.


Spring.SetBuildFacing ( number facing )
return: nil


Spring.SetBuildSpacing ( number spacing )
return: nil

Unit NoDraw,NoSelect,NoMinimap

Spring.SetUnitNoDraw ( number unitID, bool noDraw )
return: nil

LuaGadgets only!


Spring.SetUnitNoSelect ( number unitID, bool noSelect )
return: nil

LuaGadgets only!


Spring.SetUnitNoMinimap ( number unitID, bool noMinimap )
return: nil

LuaGadgets only!

Features

Spring.SetFeatureFade ( number featureID, bool allow )
return: nil

New in version 101.0
Control whether a feature will fade or not when zoomed out.


Spring.SetFeatureNoDraw ( number featureID, bool noDraw )
return: nil

LuaGadgets only!


Spring.SetFeatureSelectionVolumeData ( number featureID, number scaleX, number scaleY, number scaleZ, number offsetX, number offsetY, number offsetZ, number vType, number tType, number Axis )
return: nil

New in version 104.0

Developers

Spring.SetDrawSky ( bool drawSky )
return: nil


Spring.SetDrawWater ( bool drawWater )
return: nil


Spring.SetDrawGround ( bool drawGround )
return: nil


Spring.SetWaterParams ( table params )
return: nil

As of 104.0 no longer needs cheating enabled.
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`. "Params" table contains:
  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,
  }


Spring.SetMapRenderingParams ( table params )
return: nil

New in version 104.0
Allows to change map rendering params at runtime.
"Params" table contains:
  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,
  }


Spring.SetLogSectionFilterLevel ( string sectionName, string | number logLevel )
return: nil

New in version 95.0
See infolog.txt for possible log sections.


Spring.SetDrawGroundDeferred ( bool drawGroundDeferred [, bool drawGroundForward ] )
return: nil

New in version 101.0 drawGroundForward allows disabling of the forward pass



Spring.SetDrawModelsDeferred ( bool drawUnitsDeferred, bool drawFeaturesDeferred [, bool drawUnitsForward [, bool drawFeaturesForward ]] )
return: nil

New in version 101.0 drawFeaturesForward, drawUnitsForward allows disabling of the respective forward passes


Spring.SetVideoCapturingMode ( bool allowCaptureMode )
return: nil

New in version 104.0
This doesn't actually record the game in any way, it just regulates the framerate and interpolations.


Spring.SetVideoCapturingTimeOffset ( bool timeOffset )
return: nil

New in version 104.0

GUI

Spring.DrawUnitCommands ( number unitID )
return: nil

New in version 104.0

or

Spring.DrawUnitCommands ( table units = { [1] = unitID, ... } [, bool false )
return: nil

or

Spring.DrawUnitCommands ( table units = { [unitID] = arg1, ... }, bool true )
return: nil


Spring.SetTeamColor ( number teamID, number r, number g, number b )
return: nil


Spring.AssignMouseCursor ( string cmdName, string iconFileName [, bool overwrite = true [, bool hotSpotTopLeft = false ]{rbracket, {{{arg5}}}, {{{arg6}}}, {{{arg7}}}, {{{arg8}}}, {{{arg9}}} )

|arg5 = |arg6 = |arg7 = |arg8 = |arg9 = |return = nil | bool assigned |info = Changes/creates the cursor of a single CursorCmd. Note, that iconFileName is not the full filename instead it is like this:
Wanted filename: Anims/cursorattack_0.bmp
=> iconFileName: cursorattack }}


Spring.ReplaceMouseCursor ( string oldFileName, string newFileName [, bool hotSpotTopLeft = false ] )
return: nil | bool assigned

Mass replace all occurrence of the cursor in all CursorCmds.


Spring.SetCustomCommandDrawData ( number cmdID, number cmdID_cloneIcon | string iconname, table RGBA = { number r, number g, number b, number a } [, bool showArea ] )
return: nil | bool assigned

Register your custom cmd so it gets visible in the unit's cmd queue

or

Spring.SetCustomCommandDrawData ( number cmdID, nil )
return: nil | bool assigned

Register your custom cmd so it gets visible in the unit's cmd queue

Sharing

Spring.SetShareLevel ( string metal | string energy, number shareLevel )
return: nil

LuaGadgets only!
Note: shareLevel is 0<= x <= 1 .


Spring.ShareResources ( number teamID, string units )
return: nil

LuaGadgets only!

or


Spring.ShareResources ( number teamID, string metal | string energy, number amount )
return: nil

LuaGadgets only!

UnitDef RadarIcons & BuildPics

Spring.AddUnitIcon ( string iconName, string texFile [, number size [, number dist [, bool radAdjust ]]] )
return: nil | bool added


Spring.FreeUnitIcon ( string iconName )
return: nil | bool freed


Spring.SetUnitDefIcon ( number unitDefID, string iconName )
return: nil

Needs ModUICtrl.
Sets radar icon.


Spring.SetUnitDefImage ( number unitDefID, string luaTexture | string texFile )
return: nil

Needs ModUICtrl.
Sets buildpic.

Camera

Spring.SetCameraState ( table camState, number camTime )
return: nil | bool stateSet

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. [1] Also see #5028]


Spring.SetCameraTarget ( number x, number y, number z [, number transTime ] )
return: nil

For Spring Engine XZ represents horizontal, from north west corner of map and Y vertical, from water level and rising.


Spring.SetCameraOffset ( number px = 0 [, number py = 0 [, number pz = 0 [, number tx = 0 [, number ty = 0 [, number tz = 0 ]]]]] )
return: nil

Needs ModUICtrl.

(Virtual-)FileSystem

Spring.ExtractModArchiveFile ( string modfile )
return: bool extracted


Spring.CreateDir ( string path )
return: nil | bool dirCreated

Needs ModUICtrl.

The full VFS API is available at 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 [, bool useOverlay = false ] )
return: nil


Spring.SetConfigFloat ( string name, number value [, bool useOverlay = false ] )
return: nil

New in version 104.0


Spring.SetConfigString ( string name, number value [, bool useOverlay = false ] )
return: nil

New in version 104.0

World Primitives

outdated! use opengl api instead!

Spring.AddWorldIcon ( number cmdID, number x, number y, number z )
return: nil


Spring.AddWorldText ( string text, number x, number y, number z )
return: nil


Spring.AddWorldUnit ( number unitDefID, number x, number y, number z, number team, number facing )
return: nil

Sun

The dynamic Sun must be invoked via /dynamicsun (Dynamic sun was removed in 104.0, use SetSunDirection, SetSunLighting & SetAtmosphere instead).

Spring.SetSunManualControl ( bool setManualControl )
return: nil

Removed from version 104.0


Spring.SetSunParameters ( number dirX, number dirY, number dirZ, number dist, number startTime, number orbitTime )
return: nil

Removed from version 104.0


Spring.SetSunDirection ( number dirX, number dirY, number dirZ )
return: nil


Spring.SetSunLighting ( table params )
return: nil

New in version 101.0
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} })


Spring.SetAtmosphere ( table params )
return: nil

New in version 101.0
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 }})

Misc

Spring.Reload ( string startscript )
return: -

New in version 99.0
start-script is the CONTENT of the script.txt spring should use to start.


Spring.Restart ( string commandline_args, string startscript )
return: -

New in version 0.79
If this call returns, something went wrong.
commandline_args are commandline arguments passed to spring executable.


Spring.Start ( string commandline_args, string startscript )
return: -

New in version 102.0
If this call returns, something went wrong.
Launches a new Spring instance without terminating the existing one.
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.


Spring.SetWMIcon ( string iconFileName )
return: nil

New in version 83.0
Sets the icon for the process which is seen in the OS task-bar and other places (default: spring-logo).
Note: has to be 24bit or 32bit.
Note: on windows, it has to be 32x32 pixels in size (recommended for cross-platform)
Note: *.bmp images have to be in BGR format (default for m$ ones).
Note: *.ico images are not supported.


Spring.SetWMCaption ( string title [, string titleShort = title ] )
return: nil

New in version 83.0
Sets the window title for the process (default: "Spring <version>").
The shortTitle is displayed in the OS task-bar (default: "Spring <version>").
NOTE: shortTitle is only ever possibly used under X11 (Linux & OS X), but not with QT (KDE) and never under Windows. See this site for more details.


Spring.ClearWatchDogTimer ( [ string threadName = main ] )
return: nil

New in version 83.0


Spring.SetClipboard ( string text )
return: nil

New in version 98.0

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 ( number unitDefID )
return: nil

{New in version 101.0


Spring.PreloadFetureDefModel ( number featureDefID )
return: nil

{New in version 101.0

Lighting

NOTE: these (0.83+) lighting callouts only work when called from unsynced gadgets!

Spring.AddMapLight ( table lightParams )
return: number lightHandle

(requires MaxDynamicMapLights > 0)


Spring.AddModelLight ( table lightParams )
return: number lightHandle

(requires MaxDynamicMapLights > 0)


Spring.UpdateMapLight ( number lightHandle, table lightParams )
return: bool success


Spring.UpdateModelLight ( number lightHandle, table lightParams )
return: bool success


Spring.SetMapLightTrackingState ( number lightHandle, number unitOrProjectileID, bool enableTracking, bool unitOrProjectile )
return: bool success


Spring.SetModelLightTrackingState ( number lightHandle, number unitOrProjectileID, bool enableTracking, bool unitOrProjectile )
return: bool 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 ( string texName )
return: nil

New in version 101.0


Spring.SetMapShadingTexture ( string texType, string texName )
return: bool success

New in version 101.0
Example usage: Spring.SetMapShadingTexture("$ssmf_specular", "name_of_my_shiny_texture")

Spring.SetMapSquareTexture ( number texSqrX, number texSqrY, string luaTexName )
return: bool success


Spring.SetMapShader ( number standardShaderID, number deferredShaderID )
return: nil

New in version 101.0
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.