Lua UnsyncedCtrl: Difference between revisions

From Spring
Jump to navigationJump to search
Argh (talk | contribs)
JK (talk | contribs)
there is no loop argument in PlaySoundStream, also shortened the descriptions (this is a documentation not a tutorial)
Line 3: Line 3:
   ( arg1 [, arg2 [, ... ] ] ) -> nil
   ( arg1 [, arg2 [, ... ] ] ) -> nil


<font color="darkgreen">This command is roughly equivalent to ''print'', in standard Lua (with a few exceptions, documented in the Wiki).  This is the most important single troubleshooting tool for coders wanting to check variable values, etc.
  <font color="darkgreen">Usefull for debugging.<br> Prints values in the spring chat console (hint: the default print() writes to STDIN).</font>
 
Typical usage:
 
local a,b,c = 1,2,3
 
Spring.Echo(a,b,c)
 
Results in "1,2,3" being shown in the Spring console.</font>


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


<font color="darkgreen">This command plays WAV sounds. By default, the soundfile is expected to be in the "Sounds" folder, just like sounds used for sound effects, etc.</font>
  <font color="darkgreen">Plays WAV sounds. <i>By default</i>, the soundfile is expected to be in the "Sounds" folder.</font>


'''Spring.PlaySoundStream''' <font color="darkgreen">(plays ogg-files!!!)</font>
'''Spring.PlaySoundStream'''
   ( string "oggfile" [, number volume = 1.0
   ( string "oggfile" [, number volume = 1.0
     [, number x, number y, number z ], boolean loop ] ) -> nil | boolean true
     [, number x, number y, number z ]] ) -> nil | boolean true
<font color="darkgreen">This command will allow you to play an Ogg Vorbis (.OGG) compressed sound file. Important note: you may only play ONE streaming sound at a time. And, if one stream tries to start playing, but another one isn't quite done yet, the call will fail, and silence will result.  So, always either kill the stream, or put enough time between stream calls, or both, to ensure proper results.</font>
  <font color="darkgreen">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.</font>


'''Spring.StopSoundStream'''
'''Spring.StopSoundStream'''
   ( ) -> nil
   ( ) -> nil
<font color="darkgreen">This command terminates whatever SoundStream is running. Since only one may play at any time (see above), this can be used as an interrupt.</font>
  <font color="darkgreen">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 ==

Revision as of 12:00, 15 April 2008

Pipes

Spring.Echo

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

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.

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