Lua UnsyncedCtrl

Development < Lua Scripting < Lua UnsyncedCtrl


NOTE: Entries below marked (needs ModUICtrl) require the setting ModUICtrl to be enabled in the users springsettings.cfg, if you want to use them in unsynced LuaRules/LuaGaia. It is enabled by default so you generally don't need to care.

Contents

UI

Spring.SetLastMessagePosition

 ( number x, number y, number z ) -> nil

Ingame Console

Spring.Echo

 ( arg1 [, arg2 [, ... ] ] ) -> nil
 Useful for debugging.
Prints values in the spring chat console.
Hint: the default print() writes to STDOUT.

Spring.SendCommands (needs ModUICtrl)

 ( string command1 [, string command2 [ ... ] ] ) -> nil
 ( {string command1, string command2, ...} ) -> nil


GUI

Spring.SetActiveCommand (needs ModUICtrl)

 ( 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.ForceLayoutUpdate (needs ModUICtrl)

 ( ) -> nil

Spring.SetDrawSelectionInfo disables the "Selected Units x" box in the GUI (needs ModUICtrl)

 ( boolean enable ) -> nil

Mouse

Spring.SetMouseCursor (needs ModUICtrl)

 ( string cursorName [, number scale ] ) -> nil

Spring.WarpMouse (needs ModUICtrl)

 ( number x, number y ) -> nil

LOS Colors

Spring.SetLosViewColors (needs ModUICtrl)

 ( 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" ) -> nil

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

Markers

Spring.MarkerAddPoint (needs ModUICtrl)

 ( number x, number y, number z [, string text = ""] ) -> nil

Spring.MarkerAddLine (needs ModUICtrl)

 ( number x1, number y1, number z1, number x2, number y2, number z2 ) -> nil

Spring.MarkerErasePosition (needs ModUICtrl)

 ( number x, number y, number z ) -> nil

Sounds

Spring.PlaySoundFile

 ( string "soundfile" [, number volume
   [, number x, number y, number z ] ] ) -> nil | boolean
 Plays WAV or OGG sounds. By default, the soundfile is expected to be in the "Sounds" folder.

Spring.PlaySoundStream

 ( string "oggfile" [, number volume = 1.0
   [, number x, number y, number z ]] ) -> nil | boolean true
 Allow you to play an Ogg Vorbis (.OGG) compressed sound file.
Note: you may only play _ONE_ stream at a time. If another stream is playing and
you try to start a second one the call will fail, and silence will result.

Spring.StopSoundStream

 ( ) -> nil
 Terminates any SoundStream is running.
Since only one may play at any time (see above), this can be used as an interrupt.

Spring.PauseSoundStream

 ( ) -> nil

Spring.SetSoundStreamVolume

 ( number volume ) -> nil

SendLuaMessage

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

Spring.SendLuaUIMsg (needs ModUICtrl)

 ( string message, string mode ) -> nil
 possible modes are:
"s"/"specs" & "a"/"allies"

Spring.SendLuaGaiaMsg (needs ModUICtrl)

 ( string message ) -> nil

Spring.SendLuaRulesMsg (needs ModUICtrl)

 ( string message ) -> nil

Units

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 (needs ModUICtrl)

 ( number unitID, number groupID ) -> nil

Give Order

Spring.GiveOrder gives order to all selected units (needs ModUICtrl)

 ( number cmdID,
   params = {number, etc...},
   options = {"alt", "ctrl", "shift", "right"} ) -> nil | boolean true

Spring.GiveOrderToUnit (needs ModUICtrl)

 ( number unitID,
   number cmdID,
   params = {number, etc...},
   options = {"alt", "ctrl", "shift", "right"} ) -> nil | boolean true

Spring.GiveOrderToUnitMap (needs ModUICtrl)

 ( unitMap = { [unitID] = dontCare, etc... },
   number cmdID,
   params = {number, etc...},
   options = {"alt", "ctrl", "shift", "right"} ) -> nil | boolean true

Spring.GiveOrderToUnitArray (needs ModUICtrl)

 ( unitArray = { [1] = unitID, etc... },
   number cmdID,
   params = {number, etc...},
   options = {"alt", "ctrl", "shift", "right"} ) -> nil | boolean true

Spring.GiveOrderArrayToUnitMap (needs ModUICtrl)

 ( unitMap = { [number unitID] = dontCare, etc... },
   orderArray = {
     { number cmdID,
       params = {number, etc...},
       options = {"alt", "ctrl", "shift", "right"}
     }, ..
   }
 ) -> nil | boolean true

Spring.GiveOrderArrayToUnitArray (needs ModUICtrl)

 ( unitArray = { [1] = number unitID, etc... },
   orderArray = {
     { number cmdID,
       params = {number, etc...},
       options = {"alt", "ctrl", "shift", "right"}
     }, ..
   }
 ) -> nil | boolean true


Spring.SetBuildFacing

 ( int Facing ) -> nil

Spring.SetBuildSpacing

 ( int Spacing ) -> nil

Unit NoDraw,NoSelect,NoMinimap

Spring.SetUnitNoDraw LuaGadgets only!

 ( number unitID, boolean noDraw ) -> nil

Spring.SetUnitNoSelect LuaGadgets only!

 ( number unitID, boolean noSelect ) -> nil

Spring.SetUnitNoMinimap LuaGadgets only!

 ( number unitID, boolean noMinimap ) -> nil

GUI

Spring.SetDrawSky

 ( boolean drawSky ) -> nil

Spring.SetDrawWater

 ( boolean drawWater ) -> nil

Spring.SetDrawGround

 ( boolean drawGround ) -> nil

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 default hotspot is center!

 ( string "cmdName", string "iconFileName"
   [, boolean overwrite [, boolean hotSpotTopLeft] ] ) -> nil | boolean

Spring.ReplaceMouseCursor default hotspot is center!

 ( string "oldFileName", string "newFileName" [, boolean hotSpotTopLeft] ) -> nil | boolean

Spring.SetCustomCommandDrawData register your custom cmd so it gets visible in the unit's cmd queue

 ( number cmdID,
   number cmdIconID | string iconname | nil,
   { number r, number g, number b, number a } [, boolean showArea ] ) -> nil | true

Sharing

Spring.SetShareLevel note: shareLevel is 0<= x <= 1 (needs ModUICtrl)

 ( string "metal" | "energy", number shareLevel ) -> nil

Spring.ShareResources (needs ModUICtrl)

 ( number teamID, string "units" ) -> nil
 ( number teamID, string "metal" | "energy", number amount ) -> nil

UnitDef RadarIcons & BuildPics

Spring.AddUnitIcon (needs ModUICtrl)

 ( string iconName, string texFile [, number size [, number dist [, boolean radAdjust ]]] ) -> nil | boolean

Spring.FreeUnitIcon (needs ModUICtrl)

 ( string iconName ) -> nil | boolean

Spring.SetUnitDefIcon (RadarIcon) (needs ModUICtrl)

 ( number unitDefID, string iconName ) -> nil

Spring.SetUnitDefImage (BuildPic) (needs ModUICtrl)

 ( number unitDefID, luaTexture | string texFile ) -> nil

Camera

Spring.SetCameraState

 ( table camState, number camTime) -> nil | boolean

camState has the same format as the output of Spring.GetCameraState(). See Lua_camState for details about camState.

Spring.SetCameraTarget

 ( number x, number z, number y [,number transTime] ) -> nil

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

Spring.SetCameraOffset (needs ModUICtrl)

 ( [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 (needs ModUICtrl)

 ( number path ) -> nil | boolean

Engine Config

The following functions read the engine configs saved in .springrc, springsettings.cfg or what ever your os prefers.

Spring.GetConfigInt (needs ModUICtrl)

 ( string name [, number default] ) -> nil | number

Spring.SetConfigInt (needs ModUICtrl)

 ( string name, number value ) -> nil

Spring.GetConfigString (needs ModUICtrl)

 ( string name [, string default] ) -> nil | string

Spring.SetConfigString (needs ModUICtrl)

 ( string name, string value ) -> nil

Make Font

Spring.MakeFont (needs ModUICtrl)

 ( [string inputFile], table options ) -> nil | boolean

options = {

 outName = string,
 inData = string,
 height = number,
 texWidth = number,
 minChar = number,
 maxChar = number,
 outlineMode = number,
 outlineRadius = number,
 outlineWeight = number,
 padding = number,
 stuffing = number,
 debug = number,

}

World Primitives

outdated! use opengl api instead!

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

Misc

Spring.Restart (0.79+)

 ( string commandline_args, string startscript ) -> if this call returns, something went wrong

commandline_args are commandline arguments passed to spring executable

startscript is the CONTENT of the script.txt spring should use to start (if empty, no startscript is added, you can still point spring to your custom script.txt when you add the filepath to commandline_args

Retrieved from "http://springrts.com/wiki/Lua_UnsyncedCtrl"

This page has been accessed 2,722 times. This page was last modified 10:48, 13 March 2010.


 
 

Page editing toolbox

Browse
Main Page
Community portal
Current events
Recent changes
Random page
Help
Donations
Edit
View source
Editing help
This page
Discuss this page
Post a comment
Printable version
Context
Page history
What links here
Related changes
My pages
Log in
Special pages
New pages
File list
Statistics
Bug reports
More...

Site layout created by Roflcopter.