Lua UnsyncedCtrl: Difference between revisions

From Spring
Jump to navigationJump to search
Jonanin (talk | contribs)
No edit summary
Jonanin (talk | contribs)
No edit summary
Line 3: Line 3:
   ( arg1 [, arg2 [, ... ] ] ) -> nil
   ( arg1 [, arg2 [, ... ] ] ) -> nil


   <font color="lightblue">Usefull for debugging.<br> Prints values in the spring chat console (hint: the default print() writes to STDOUT).</font>
   <font color="#55ee99">Usefull for debugging.<br> Prints values in the spring chat console (hint: the default print() writes to STDOUT).</font>


'''Spring.PlaySoundFile'''
'''Spring.PlaySoundFile'''
Line 9: Line 9:
     [, number x, number y, number z ] ] ) -> nil | boolean
     [, number x, number y, number z ] ] ) -> nil | boolean


   <font color="lightblue">Plays WAV sounds. <i>By default</i>, the soundfile is expected to be in the "Sounds" folder.</font>
   <font color="#55ee99">Plays WAV sounds. <i>By default</i>, the soundfile is expected to be in the "Sounds" folder.</font>


'''Spring.PlaySoundStream'''
'''Spring.PlaySoundStream'''
   ( string "oggfile" [, number volume = 1.0
   ( string "oggfile" [, number volume = 1.0
     [, number x, number y, number z ]] ) -> nil | boolean true
     [, number x, number y, number z ]] ) -> nil | boolean true
   <font color="lightblue">Allow you to play an Ogg Vorbis (.OGG) compressed sound file.<br> <b>Note:</b> you may only play _ONE_ stream at a time. If another stream is playing and<br> you try to start a second one the call will fail, and silence will result.<br> <b>Note2:</b> the file has to be on the local filesystem, so you can't playback ogg's<br> in your mod with this command, to do so you have to extract it before and save<br> it on the local filesystem.</font>
   <font color="#55ee99">Allow you to play an Ogg Vorbis (.OGG) compressed sound file.<br> <b>Note:</b> you may only play _ONE_ stream at a time. If another stream is playing and<br> you try to start a second one the call will fail, and silence will result.<br> <b>Note2:</b> the file has to be on the local filesystem, so you can't playback ogg's<br> in your mod with this command, to do so you have to extract it before and save<br> it on the local filesystem.</font>


'''Spring.StopSoundStream'''
'''Spring.StopSoundStream'''
   ( ) -> nil
   ( ) -> nil
   <font color="lightblue">Terminates any SoundStream is running.<br> Since only one may play at any time (see above), this can be used as an interrupt.</font>
   <font color="#55ee99">Terminates any SoundStream is running.<br> Since only one may play at any time (see above), this can be used as an interrupt.</font>


== SendMessage ==
== SendMessage ==
Line 65: Line 65:
'''Spring.SetTeamColor'''
'''Spring.SetTeamColor'''
   ( number teamID, number r, number g, number b ) -> nil
   ( number teamID, number r, number g, number b ) -> nil
'''Spring.AssignMouseCursor''' <font color="lightblue">default hotspot is center!</font>
'''Spring.AssignMouseCursor''' <font color="#55ee99">default hotspot is center!</font>
   ( string "cmdName", string "iconFileName"
   ( string "cmdName", string "iconFileName"
     [, boolean overwrite [, boolean hotSpotTopLeft] ] ) -> nil | boolean
     [, boolean overwrite [, boolean hotSpotTopLeft] ] ) -> nil | boolean
'''Spring.ReplaceMouseCursor''' <font color="lightblue">default hotspot is center!</font>
'''Spring.ReplaceMouseCursor''' <font color="#55ee99">default hotspot is center!</font>
   ( string "oldFileName", string "newFileName" [, boolean hotSpotTopLeft] ) -> nil | boolean
   ( string "oldFileName", string "newFileName" [, boolean hotSpotTopLeft] ) -> nil | boolean


'''Spring.SetCustomCommandDrawData''' <font color="lightblue">register your custom cmd so it gets visible in the unit's cmd queue</font>
'''Spring.SetCustomCommandDrawData''' <font color="#55ee99">register your custom cmd so it gets visible in the unit's cmd queue</font>
   ( number cmdID,
   ( number cmdID,
     number cmdIconID | string iconname | nil,
     number cmdIconID | string iconname | nil,
Line 79: Line 79:
'''Spring.SetCameraState'''
'''Spring.SetCameraState'''
   ( table camState, number camTime) -> nil | boolean
   ( table camState, number camTime) -> nil | boolean
<font color="green">camState = {
<font color="#55ee99">camState = {
   mode = cameraID,
   mode = cameraID,
     1 = cameraID,
     1 = cameraID,

Revision as of 22:18, 2 October 2008

Pipes

Spring.Echo

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

Spring.PlaySoundFile

 ( string "soundfile" [, number volume
   [, number x, number y, number z ] ] ) -> nil | boolean
 Plays WAV 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.
Note2: the file has to be on the local filesystem, so you can't playback ogg's
in your mod with this command, to do so you have to extract it before and save
it on the local filesystem.

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.

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

Unit Selection

Spring.SelectUnitMap

 ( { [unitID] = anything, ...} [,boolean append] ) -> nil

Spring.SelectUnitArray

 ( { [1] = unitID1 , [2] = unitID2 , ...} [,boolean append] ) -> nil

Unit Control

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

Camera

Spring.SetCameraState

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

camState = {

 mode = cameraID,
    1 = cameraID,
    2 = posX,
    3 = posY,
    4 = posZ,
    5 = dirX,
    6 = dirY,
    7 = dirZ,
    ... and more (depending on the camera ...

}

Spring.SetCameraTarget

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

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