Module UnsyncedRead
Callouts to get state
See also:
Decals
- Spring.GetAllGroundDecals
- Spring.GetGroundDecalMiddlePos
- Spring.GetDecalQuadPos
- Spring.GetGroundDecalSizeAndHeight
- Spring.GetGroundDecalRotation
- Spring.GetGroundDecalTexture
- Spring.GetDecalTextures
- Spring.SetGroundDecalTextureParams
- Spring.GetGroundDecalAlpha
- Spring.GetGroundDecalNormal
- Spring.GetGroundDecalTint
- Spring.GetGroundDecalMisc
- Spring.GetGroundDecalCreationFrame
- Spring.GetGroundDecalOwner
- Spring.GetGroundDecalType
Misc
Replay
Game/Menu Name
Profiling
- Spring.GetProfilerTimeRecord
- Spring.GetProfilerRecordNames
- Spring.GetLuaMemUsage
- Spring.GetVidMemUsage
Class Timer
- Spring.GetTimer
- Get a timer with millisecond resolution
- Spring.GetTimerMicros
- Get a timer with microsecond resolution
- Spring.GetFrameTimer
- Get a timer for the start of the frame
- Spring.DiffTimers
Screen/Rendering Info
- Spring.GetNumDisplays
- Spring.GetViewGeometry
- Get main view geometry (map and game rendering)
- Spring.GetDualViewGeometry
- Get dual view geometry (minimap when enabled)
- Spring.GetWindowGeometry
- Get main window geometry
- Spring.GetWindowDisplayMode
- Get main window display mode
- Spring.GetScreenGeometry
- Get screen geometry
- Spring.GetMiniMapGeometry
- Get minimap geometry
- Spring.GetMiniMapRotation
- Get minimap rotation
- Spring.GetMiniMapDualScreen
- Spring.GetSelectionBox
- Get vertices from currently active selection box
- Spring.GetDrawSelectionInfo
- Spring.IsAboveMiniMap
- Spring.GetDrawFrame
- Spring.GetFrameTimeOffset
- Spring.GetLastUpdateSeconds
- Spring.GetVideoCapturingMode
Unit attributes
- Spring.IsUnitAllied
- Spring.IsUnitSelected
- Spring.GetUnitLuaDraw
- Spring.GetUnitNoDraw
- Spring.GetUnitEngineDrawMask
- Spring.GetUnitAlwaysUpdateMatrix
- Spring.GetUnitDrawFlag
- Spring.GetUnitNoMinimap
- Spring.GetUnitNoSelect
- Spring.UnitIconGetDraw
- Spring.GetUnitSelectionVolumeData
Feature attributes
- Spring.GetFeatureLuaDraw
- Spring.GetFeatureNoDraw
- Spring.GetFeatureEngineDrawMask
- Spring.GetFeatureAlwaysUpdateMatrix
- Spring.GetFeatureDrawFlag
- Spring.GetFeatureSelectionVolumeData
Inview
- Spring.IsUnitInView
- Spring.IsUnitVisible
- Spring.IsUnitIcon
- Spring.IsAABBInView
- Spring.IsSphereInView
- Spring.GetUnitViewPosition
- Spring.GetVisibleUnits
- Spring.GetVisibleFeatures
- Spring.GetVisibleProjectiles
- Spring.GetRenderUnits
- Spring.GetRenderUnitsDrawFlagChanged
- Spring.GetRenderFeatures
- Spring.GetRenderFeaturesDrawFlagChanged
- Spring.ClearUnitsPreviousDrawFlag
- Spring.ClearFeaturesPreviousDrawFlag
- Spring.GetUnitsInScreenRectangle
- Get units inside a rectangle area on the map
- Spring.GetFeaturesInScreenRectangle
- Get features inside a rectangle area on the map
- Spring.GetLocalPlayerID
- Spring.GetLocalTeamID
- Spring.GetLocalAllyTeamID
- Spring.GetSpectatingState
- Spring.GetSelectedUnits
- Spring.GetSelectedUnitsSorted
- Get selected units aggregated by unitDefID
- Spring.GetSelectedUnitsCounts
- Get an aggregate count of selected units per unitDefID
- Spring.GetSelectedUnitsCount
- Returns the amount of selected units
- Spring.GetBoxSelectionByEngine
- Get if selection box is handled by engine
- Spring.IsGUIHidden
- Spring.HaveShadows
- Spring.HaveAdvShading
- Spring.GetWaterMode
- Spring.GetMapDrawMode
- Spring.GetMapSquareTexture
- rgb
- Color triple (RGB)
- Spring.GetLosViewColors
- Spring.GetNanoProjectileParams
- Spring.GetCameraNames
- Get available cameras
- camState
- Parameters for camera state
- Spring.GetCameraState
- Spring.GetCameraPosition
- Spring.GetCameraDirection
- Spring.GetCameraRotation
- Spring.GetCameraFOV
- xyz
- Cartesian triple (XYZ)
- Spring.GetCameraVectors
- Spring.WorldToScreenCoords
- Spring.TraceScreenRay
- Get information about a ray traced from screen to world position
- Spring.GetPixelDir
- Spring.GetTeamColor
- Spring.GetTeamOrigColor
- Spring.GetDrawSeconds
Sound
Game Speed
Commands
- Spring.GetActiveCommand
- Spring.GetDefaultCommand
- cmdDesc
- Command Description
- Spring.GetActiveCmdDescs
- Spring.GetActiveCmdDesc
- Spring.GetCmdDescIndex
- Spring.GetBuildFacing
- Spring.GetBuildSpacing
- Spring.GetGatherMode
- Spring.GetActivePage
Mouse State
Text
Console
Key Input
- Spring.GetKeyFromScanSymbol
- Spring.GetKeyState
- Spring.GetModKeyState
- Spring.GetPressedKeys
- Spring.GetPressedScans
- Spring.GetInvertQueueKey
- Spring.GetKeyCode
- Spring.GetKeySymbol
- Spring.GetScanSymbol
- keybindingSpec
- Keybinding spec
- Spring.GetKeyBindings
- Spring.GetActionHotKeys
Unit Groups
- Spring.GetGroupList
- Spring.GetSelectedGroup
- Spring.GetUnitGroup
- Spring.GetGroupUnits
- Spring.GetGroupUnitsSorted
- Spring.GetGroupUnitsCounts
- Spring.GetGroupUnitsCount
Team/Player Info
Configuration
- configSpec
- Configuration spec
- Spring.GetConfigParams
- Spring.GetConfigInt
- Spring.GetConfigFloat
- Spring.GetConfigString
- Spring.GetLogSections
Decals
Spring.GetAllGroundDecals()
Returns:
- {[number],...} decalIDs
Spring.GetGroundDecalMiddlePos(decalID)
Parameters:
-
decalID
number
Returns:
- nil or number posX
- number posZ
Spring.GetDecalQuadPos(decalID)
Parameters:
-
decalID
number
Returns:
- nil or number posTL.x
- number posTL.z
- number posTR.x
- number posTR.z
- number posBR.x
- number posBR.z
- number posBL.x
- number posBL.z
Spring.GetGroundDecalSizeAndHeight(decalID)
Parameters:
-
decalID
number
Returns:
- nil or number sizeX
- number sizeY
- number projCubeHeight
Spring.GetGroundDecalRotation(decalID)
Parameters:
-
decalID
number
Returns:
- nil or number rotation in radians
Spring.GetGroundDecalTexture(decalID[, isMainTex=true])
Parameters:
-
decalID
number -
isMainTex
bool If false, it gets the normals/glow map (default true)
Returns:
- nil or string texture
Spring.GetDecalTextures([isMainTex=true])
Parameters:
-
isMainTex
bool If false, it gets the texture for normals/glow maps (default true)
Returns:
- {[string],...} textureNames All textures on the atlas and available for use in SetGroundDecalTexture
Spring.SetGroundDecalTextureParams(decalID)
Parameters:
-
decalID
number
Returns:
- nil or number texWrapDistance if non-zero sets the mode to repeat the texture along the left-right direction of the decal every texWrapFactor elmos
- number texTraveledDistance shifts the texture repetition defined by texWrapFactor so the texture of a next line in the continuous multiline can start where the previous finished. For that it should collect all elmo lengths of the previously set multiline segments.
Spring.GetGroundDecalAlpha(decalID)
Parameters:
-
decalID
number
Returns:
- nil or number alpha Between 0 and 1
- number alphaFalloff Between 0 and 1, per second
Spring.GetGroundDecalNormal(decalID)
If all three equal 0, the decal follows the normals of ground at midpoint
Parameters:
-
decalID
number
Returns:
- nil or number normal.x
- number normal.y
- number normal.z
Spring.GetGroundDecalTint(decalID)
Gets the tint of the ground decal. A color of (0.5, 0.5, 0.5, 0.5) is effectively no tint
Parameters:
-
decalID
number
Returns:
- nil or number tintR
- number tintG
- number tintB
- number tintA
Spring.GetGroundDecalMisc(decalID)
Returns less important parameters of a ground decal
Parameters:
-
decalID
number
Returns:
- nil or number dotElimExp
- number refHeight
- number minHeight
- number maxHeight
- number forceHeightMode
Spring.GetGroundDecalCreationFrame(decalID)
Min can be not equal to max for "gradient" style decals, e.g. unit tracks
Parameters:
-
decalID
number
Returns:
- nil or number creationFrameMin
- number creationFrameMax
Spring.GetGroundDecalOwner(decalID)
Parameters:
-
decalID
number
Returns:
- nil or number unitID|number featureID(+MAX_UNITS)
Spring.GetGroundDecalType(decalID)
Misc
Spring.GetUnitTransformMatrix(unitID)
Parameters:
-
unitID
number
Returns:
- number or nil m11 nil when unitID cannot be parsed
- number m12
- number m13
- number m14
- number m21
- number m22
- number m23
- number m24
- number m31
- number m32
- number m33
- number m34
- number m41
- number m42
- number m43
- number m44
Spring.GetFeatureTransformMatrix(featureID)
Parameters:
-
featureID
number
Returns:
- number or nil m11 nil when featureID cannot be parsed
- number m12
- number m13
- number m14
- number m21
- number m22
- number m23
- number m24
- number m31
- number m32
- number m33
- number m34
- number m41
- number m42
- number m43
- number m44
Spring.GetSyncedGCInfo([collectGC=false])
Parameters:
-
collectGC
bool collect before returning metric (default false)
Returns:
- nil or number GC values are expressed in Kbytes: #bytes/2^10
Replay
Spring.IsReplay()
Returns:
- nil or bool isReplay
Spring.GetReplayLength()
Returns:
- nil or number timeInSeconds
Game/Menu Name
Spring.GetGameName()
Returns:
- string name
Spring.GetMenuName()
Returns:
- string name name .. version from Modinfo.lua. E.g. "Spring: 1944 test-5640-ac2d15b".
Profiling
Spring.GetProfilerTimeRecord(profilerName[, frameData=false])
Parameters:
-
profilerName
string -
frameData
bool (default false)
Returns:
- number total in ms
- number current in ms
- number max_dt
- number time_pct
- number peak_pct
- nil or {[number]=number,...} frameData where key is the frame index and value is duration
Spring.GetProfilerRecordNames()
Returns:
- {string,...} profilerNames
Spring.GetLuaMemUsage()
Returns:
- number luaHandleAllocedMem in kilobytes
- number luaHandleNumAllocs divided by 1000
- number luaGlobalAllocedMem in kilobytes
- number luaGlobalNumAllocs divided by 1000
- number luaUnsyncedGlobalAllocedMem in kilobytes
- number luaUnsyncedGlobalNumAllocs divided by 1000
- number luaSyncedGlobalAllocedMem in kilobytes
- number luaSyncedGlobalNumAllocs divided by 1000
Spring.GetVidMemUsage()
Returns:
- number usedMem in MB
- number availableMem in MB
Class Timer
Spring.GetTimer()
Get a timer with millisecond resolution
Returns:
Spring.GetTimerMicros()
Get a timer with microsecond resolution
Returns:
Spring.GetFrameTimer([lastFrameTime=false])
Get a timer for the start of the frame
This should give better results for camera interpolations
Parameters:
-
lastFrameTime
bool whether to use last frame time instead of last frame start (default false)
Returns:
Spring.DiffTimers(endTimer, startTimer[, returnMs=false[, fromMicroSecs=false]])
Parameters:
-
endTimer
Timer -
startTimer
Timer -
returnMs
bool whether to returntimeAmount
in milliseconds as opposed to seconds (default false) -
fromMicroSecs
bool whether timers are in microseconds instead of milliseconds (default false)
Returns:
- number timeAmount
Screen/Rendering Info
Spring.GetNumDisplays()
Returns:
- number numDisplays as returned by
SDL_GetNumVideoDisplays
Spring.GetViewGeometry()
Get main view geometry (map and game rendering)
Returns:
- number viewSizeX in px
- number viewSizeY in px
- number viewPosX offset from leftmost screen left border in px
- number viewPosY offset from bottommost screen bottom border in px
Spring.GetDualViewGeometry()
Get dual view geometry (minimap when enabled)
Returns:
- number dualViewSizeX in px
- number dualViewSizeY in px
- number dualViewPosX offset from leftmost screen left border in px
- number dualViewPosY offset from bottommost screen bottom border in px
Spring.GetWindowGeometry()
Get main window geometry
Returns:
- number winSizeX in px
- number winSizeY in px
- number winPosX in px
- number winPosY in px
- number windowBorderTop in px
- number windowBorderLeft in px
- number windowBorderBottom in px
- number windowBorderRight in px
Spring.GetWindowDisplayMode()
Get main window display mode
Returns:
- number width in px
- number height in px
- number bits per pixel
- number refresh rate in Hz
Spring.GetScreenGeometry([displayIndex=-1[, queryUsable=false]])
Get screen geometry
Parameters:
-
displayIndex
number (default -1) -
queryUsable
bool (default false)
Returns:
- number screenSizeX in px
- number screenSizeY in px
- number screenPosX in px
- number screenPosY in px
- number windowBorderTop in px
- number windowBorderLeft in px
- number windowBorderBottom in px
- number windowBorderRight in px
- nil or number screenUsableSizeX in px
- nil or number screenUsableSizeY in px
- nil or number screenUsablePosX in px
- nil or number screenUsablePosY in px
Spring.GetMiniMapGeometry()
Get minimap geometry
Returns:
- number minimapPosX in px
- number minimapPosY in px
- number minimapSizeX in px
- number minimapSizeY in px
- bool minimized
- bool maximized
Spring.GetMiniMapRotation()
Get minimap rotation
Returns:
- number amount in radians
Spring.GetMiniMapDualScreen()
Returns:
- string or false position "left"|"right" when dual screen is enabled, false when not
Spring.GetSelectionBox()
Get vertices from currently active selection box
Returns nil when selection box is inactive
Returns:
- nil or number left
- nil or number top
- nil or number right
- nil or number bottom
See also:
Spring.GetDrawSelectionInfo()
Returns:
- bool
Spring.IsAboveMiniMap(x, y)
Parameters:
-
x
number -
y
number
Returns:
- bool isAbove
Spring.GetDrawFrame()
Returns:
- number low_16bit
- number high_16bit
Spring.GetFrameTimeOffset()
Ideally, when running 30hz sim, and 60hz rendering, the draw frames should have and offset of either 0.0 frames, or 0.5 frames. When draw frames are not integer multiples of sim frames, some interpolation happens, and this timeoffset shows how far along it is.
Returns:
- nil or number offset of the current draw frame from the last sim frame, expressed in fractions of a frame
Spring.GetLastUpdateSeconds()
Returns:
- nil or number lastUpdateSeconds
Spring.GetVideoCapturingMode()
Returns:
- bool allowRecord
Unit attributes
Spring.IsUnitAllied(unitID)
Parameters:
-
unitID
number
Returns:
- nil or bool isAllied nil with unitID cannot be parsed
Spring.IsUnitSelected(unitID)
Parameters:
-
unitID
number
Returns:
- nil or bool isSelected nil when unitID cannot be parsed
Spring.GetUnitLuaDraw(unitID)
Parameters:
-
unitID
number
Returns:
- nil or bool draw nil when unitID cannot be parsed
Spring.GetUnitNoDraw(unitID)
Parameters:
-
unitID
number
Returns:
- nil or bool nil when unitID cannot be parsed
Spring.GetUnitEngineDrawMask(unitID)
Parameters:
-
unitID
number
Returns:
- nil or bool nil when unitID cannot be parsed
Spring.GetUnitAlwaysUpdateMatrix(unitID)
Parameters:
-
unitID
number
Returns:
- nil or bool nil when unitID cannot be parsed
Spring.GetUnitDrawFlag(unitID)
Parameters:
-
unitID
number
Returns:
- nil or number nil when unitID cannot be parsed
Spring.GetUnitNoMinimap(unitID)
Parameters:
-
unitID
number
Returns:
- nil or bool nil when unitID cannot be parsed
Spring.GetUnitNoSelect(unitID)
Parameters:
-
unitID
number
Returns:
- nil or bool nil when unitID cannot be parsed
Spring.UnitIconGetDraw(unitID, nil)
Parameters:
-
unitID
number -
nil
nil or bool when unitID is invalid
Spring.GetUnitSelectionVolumeData(unitID)
Parameters:
-
unitID
number
Returns:
- number or nil scaleX nil when unitID cannot be parsed
- number scaleY
- number scaleZ
- number offsetX
- number offsetY
- number offsetZ
- number volumeType
- number useContHitTest
- number getPrimaryAxis
- bool ignoreHits
Feature attributes
Spring.GetFeatureLuaDraw(featureID)
Parameters:
-
featureID
number
Returns:
- nil or bool nil when featureID cannot be parsed
Spring.GetFeatureNoDraw(featureID)
Parameters:
-
featureID
number
Returns:
- nil or bool nil when featureID cannot be parsed
Spring.GetFeatureEngineDrawMask(featureID)
Parameters:
-
featureID
number
Returns:
- nil or bool nil when featureID cannot be parsed
Spring.GetFeatureAlwaysUpdateMatrix(featureID)
Parameters:
-
featureID
number
Returns:
- nil or bool nil when featureID cannot be parsed
Spring.GetFeatureDrawFlag(featureID)
Parameters:
-
featureID
number
Returns:
- nil or number nil when featureID cannot be parsed
Spring.GetFeatureSelectionVolumeData(featureID)
Parameters:
-
featureID
number
Returns:
- number or nil scaleX nil when unitID cannot be parsed
- number scaleY
- number scaleZ
- number offsetX
- number offsetY
- number offsetZ
- number volumeType
- number useContHitTest
- number getPrimaryAxis
- bool ignoreHits
Inview
Spring.IsUnitInView(unitID)
Parameters:
-
unitID
number
Returns:
- nil or bool inView nil when unitID cannot be parsed
Spring.IsUnitVisible(unitID[, radius], checkIcon)
Parameters:
-
unitID
number -
radius
number unitRadius when not specified (optional) -
checkIcon
bool
Returns:
- nil or bool isVisible nil when unitID cannot be parsed
Spring.IsUnitIcon(unitID)
Parameters:
-
unitID
number
Returns:
- nil or bool isUnitIcon nil when unitID cannot be parsed
Spring.IsAABBInView(minX, minY, minZ, maxX, maxY, maxZ)
Parameters:
-
minX
number -
minY
number -
minZ
number -
maxX
number -
maxY
number -
maxZ
number
Returns:
- bool inView
Spring.IsSphereInView(posX, posY, posZ[, radius=0])
Parameters:
-
posX
number -
posY
number -
posZ
number -
radius
number (default 0)
Returns:
- bool inView
Spring.GetUnitViewPosition(unitID[, midPos=false])
Parameters:
-
unitID
number -
midPos
bool (default false)
Returns:
- number or nil x nil when unitID cannot be parsed
- number y
- number z
Spring.GetVisibleUnits([teamID=-1[, radius=30[, icons=true]]])
Parameters:
-
teamID
number (default -1) -
radius
number (default 30) -
icons
bool (default true)
Returns:
- nil or {[number],...} unitIDs
Spring.GetVisibleFeatures([teamID=-1[, radius=30[, icons=true[, geos=true]]]])
Parameters:
-
teamID
number (default -1) -
radius
number (default 30) -
icons
bool (default true) -
geos
bool (default true)
Returns:
- nil or {[number],...} featureIDs
Spring.GetVisibleProjectiles([allyTeamID=-1[, addSyncedProjectiles=true[, addWeaponProjectiles=true[, addPieceProjectiles=true]]]])
Parameters:
-
allyTeamID
number (default -1) -
addSyncedProjectiles
bool (default true) -
addWeaponProjectiles
bool (default true) -
addPieceProjectiles
bool (default true)
Returns:
- nil or {[number],...} projectileIDs
Spring.GetRenderUnits()
Spring.GetRenderUnitsDrawFlagChanged()
Spring.GetRenderFeatures()
Spring.GetRenderFeaturesDrawFlagChanged()
Spring.ClearUnitsPreviousDrawFlag()
Returns:
- nil
Spring.ClearFeaturesPreviousDrawFlag()
Returns:
- nil
Spring.GetUnitsInScreenRectangle(left, top, right, bottom[, allegiance=-1])
Get units inside a rectangle area on the map
Parameters:
-
left
number -
top
number -
right
number -
bottom
number -
allegiance
number teamID when > 0, when < 0 one of AllUnits = -1, MyUnits = -2, AllyUnits = -3, EnemyUnits = -4 (default -1)
Returns:
- nil or {[number],...} unitIDs
Spring.GetFeaturesInScreenRectangle(left, top, right, bottom)
Get features inside a rectangle area on the map
Parameters:
-
left
number -
top
number -
right
number -
bottom
number
Returns:
- nil or {[number],...} featureIDs
Spring.GetLocalPlayerID()
Returns:
- number playerID
Spring.GetLocalTeamID()
Returns:
- number teamID
Spring.GetLocalAllyTeamID()
Returns:
- number allyTeamID
Spring.GetSpectatingState()
Returns:
- bool spectating
- bool spectatingFullView
- bool spectatingFullSelect
Spring.GetSelectedUnits()
Returns:
- {[number],...} unitIDs
Spring.GetSelectedUnitsSorted()
Get selected units aggregated by unitDefID
Returns:
- {[number]={number,...},...} where keys are unitDefIDs and values are unitIDs
- n the number of unitDefIDs
Spring.GetSelectedUnitsCounts()
Get an aggregate count of selected units per unitDefID
Returns:
- {[number]=number,...} unitsCounts where keys are unitDefIDs and values are counts
- n the number of unitDefIDs
Spring.GetSelectedUnitsCount()
Returns the amount of selected units
Returns:
- number selectedUnitsCount
Spring.GetBoxSelectionByEngine()
Get if selection box is handled by engine
Returns:
- bool when true engine won't select units inside selection box when released
See also:
Spring.IsGUIHidden()
Returns:
- bool
Spring.HaveShadows()
Returns:
- shadowsLoaded
Spring.HaveAdvShading()
Returns:
- bool useAdvShading
- bool groundUseAdvShading
Spring.GetWaterMode()
Spring.GetMapDrawMode()
Returns:
- nil or string "normal"|"height"|"metal"|"pathTraversability"|"los"
Spring.GetMapSquareTexture(texSquareX, texSquareY, lodMin, luaTexName[, lodMax=lodMin])
Parameters:
-
texSquareX
number -
texSquareY
number -
lodMin
number -
luaTexName
string -
lodMax
number (default lodMin)
Returns:
- nil or bool success
rgb
Color triple (RGB)
Fields:
-
r
number -
g
number -
b
number
Spring.GetLosViewColors()
Returns:
- { always=rgb, LOS=rgb, radar=rgb, jam=rgb, radar2=rgb }
Spring.GetNanoProjectileParams()
Returns:
- number rotVal in degrees
- number rotVel in degrees
- number rotAcc in degrees
- number rotValRng in degrees
- number rotVelRng in degrees
- number rotAccRng in degrees
Spring.GetCameraNames()
Get available cameras
Returns:
- {[string] = number} where keys are names and values are indices
camState
Parameters for camera state
Highly dependent on the type of the current camera controller
Fields:
-
name
string "ta"|"spring"|"rot"|"ov"|"free"|"fps"|"dummy" -
mode
number the camera mode: 0 (fps), 1 (ta), 2 (spring), 3 (rot), 4 (free), 5 (ov), 6 (dummy) -
fov
number -
px
number Position X of the ground point in screen center -
py
number Position Y of the ground point in screen center -
pz
number Position Z of the ground point in screen center -
dx
number Camera direction vector X -
dy
number Camera direction vector Y -
dz
number Camera direction vector Z -
rx
number Camera rotation angle on X axis (spring) -
ry
number Camera rotation angle on Y axis (spring) -
rz
number Camera rotation angle on Z axis (spring) -
angle
number Camera rotation angle on X axis (aka tilt/pitch) (ta) -
flipped
number -1 for when south is down, 1 for when north is down (ta) -
dist
number Camera distance from the ground (spring) -
height
number Camera distance from the ground (ta) -
oldHeight
number Camera distance from the ground, cannot be changed (rot)
Spring.GetCameraState([useReturns=true])
Parameters:
-
useReturns
bool when true return multiple values instead of table (default true)
Returns:
- any or camState ret1
- any or nil ret2
- any or nil retn
Spring.GetCameraPosition()
Returns:
- posX
- posY
- posZ
Spring.GetCameraDirection()
Returns:
- dirX
- dirY
- dirZ
Spring.GetCameraRotation()
Returns:
- rotX in radians
- rotY in radians
- rotZ in radians
Spring.GetCameraFOV()
Returns:
- number vFOV
- number hFOV
xyz
Cartesian triple (XYZ)
Fields:
-
x
number -
y
number -
z
number
Spring.GetCameraVectors()
Returns:
- { forward = xyz, up = xyz, right = xyz, topFrustumPlane = xyz, botFrustumPlane = xyz, lftFrustumPlane = xyz, rgtFrustumPlane = xyz }
Spring.WorldToScreenCoords(x, y, z)
Parameters:
-
x
number -
y
number -
z
number
Returns:
- viewPortX
- viewPortY
- viewPortZ
Spring.TraceScreenRay(screenX, screenY[, onlyCoords=false[, useMinimap=false[, includeSky=false[, ignoreWater=false[, heightOffset=0]]]]])
Get information about a ray traced from screen to world position
Extended to allow a custom plane, parameters are (0, 1, 0, D=0) where D is the offset D can be specified in the third argument (if all the bools are false) or in the seventh (as shown). Intersection coordinates are returned in t[4],t[5],t[6] when the ray goes offmap and includeSky is true), or when no unit or feature is hit (or onlyCoords is true). This will only work for units & objects with the default collission sphere. Per Piece collission and custom collission objects are not supported. The unit must be selectable, to appear to a screen trace ray.
Parameters:
-
screenX
number position on x axis in mouse coordinates (origin on left border of view) -
screenY
number position on y axis in mouse coordinates (origin on top border of view) -
onlyCoords
bool return only description (1st return value) and coordinates (2nd return value) (default false) -
useMinimap
bool if position arguments are contained by minimap, use the minimap corresponding world position (default false) -
includeSky
bool (default false) -
ignoreWater
bool (default false) -
heightOffset
number (default 0)
Returns:
Spring.GetPixelDir(x, y)
Parameters:
-
x
number -
y
number
Returns:
- dirX
- dirY
- dirZ
Spring.GetTeamColor(teamID)
Parameters:
-
teamID
number
Returns:
- nil or number r factor from 0 to 1
- nil or number g factor from 0 to 1
- nil or number b factor from 0 to 1
- nil or number a factor from 0 to 1
Spring.GetTeamOrigColor(teamID)
Parameters:
-
teamID
number
Returns:
- nil or number r factor from 0 to 1
- nil or number g factor from 0 to 1
- nil or number b factor from 0 to 1
- nil or number a factor from 0 to 1
Spring.GetDrawSeconds()
Returns:
- time in seconds
Sound
Spring.GetSoundStreamTime()
Returns:
- number playTime
- number time
Spring.GetSoundEffectParams()
Game Speed
Spring.GetFPS()
Returns:
- number fps
Spring.GetGameSpeed()
Returns:
- number wantedSpeedFactor
- number speedFactor
- bool paused
Spring.GetGameState([maxLatency=500])
Parameters:
-
maxLatency
number used forisSimLagging
return parameter (default 500)
Returns:
- bool doneLoading
- bool isSavedGame
- bool isClientPaused
- bool isSimLagging
Commands
Spring.GetActiveCommand()
Returns:
- nil or number cmdIndex
- nil or number cmdID
- nil or number cmdType
- nil or string cmdName
Spring.GetDefaultCommand()
Returns:
- nil or number cmdIndex
- nil or number cmdID
- nil or number cmdType
- nil or string cmdName
cmdDesc
Command Description
Contains data about a command
Fields:
Spring.GetActiveCmdDescs()
Returns:
- {[cmdDesc],...} cmdDescs
Spring.GetActiveCmdDesc(cmdIndex)
Spring.GetCmdDescIndex(cmdID)
Parameters:
-
cmdID
number
Returns:
- nil or number cmdDescIndex
Spring.GetBuildFacing()
Returns:
- number buildFacing
Spring.GetBuildSpacing()
Returns:
- number buildSpacing
Spring.GetGatherMode()
Returns:
- number gatherMode
Spring.GetActivePage()
Returns:
- number activePage
- number maxPage
Mouse State
Spring.GetMouseState()
Returns:
- number x
- number y
- number lmbPressed left mouse button pressed
- number mmbPressed middle mouse button pressed
- number rmbPressed right mouse button pressed
- bool offscreen
- bool mmbScroll
Spring.GetMouseCursor()
Returns:
- string cursorName
- number cursorScale
Spring.GetMouseStartPosition(button)
Parameters:
-
button
number
Returns:
- number x
- number y
- number camPosX
- number camPosY
- number camPosZ
- number dirX
- number dirY
- number dirZ
Text
Spring.GetClipboard()
Returns:
- string text
Spring.IsUserWriting()
Returns:
- bool
Console
Spring.GetLastMessagePositions()
Returns:
- {xyz,...} message positions
Spring.GetConsoleBuffer(maxLines)
Parameters:
-
maxLines
number
Returns:
- nil or {{text=string,priority=number},...} pair array of (text, priority)
Spring.GetCurrentTooltip()
Returns:
- string tooltip
Key Input
Spring.GetKeyFromScanSymbol(scanSymbol)
Spring.GetKeyState(keyCode)
Parameters:
-
keyCode
number
Returns:
- bool pressed
Spring.GetModKeyState()
Returns:
- bool alt
- bool ctrl
- bool meta
- bool shift
Spring.GetPressedKeys()
Returns:
- {[number or string]=true,...} where keys are keyCodes or key names
Spring.GetPressedScans()
Returns:
- {[number or string]=true,...} where keys are scanCodes or scan names
Spring.GetInvertQueueKey()
Returns:
- nil or number queueKey
Spring.GetKeyCode(keySym)
Spring.GetKeySymbol(keyCode)
Parameters:
-
keyCode
number
Returns:
Spring.GetScanSymbol(scanCode)
Parameters:
-
scanCode
number
Returns:
keybindingSpec
Keybinding spec
Spring.GetKeyBindings([keySet1[, keySet2]])
Parameters:
-
keySet1
string filters keybindings bound to this keyset (optional) -
keySet2
string OR bound to this keyset (optional)
Returns:
Spring.GetActionHotKeys(actionName)
Unit Groups
Spring.GetGroupList()
Returns:
- nil or {[number]=number,...} where keys are groupIDs and values are counts
Spring.GetSelectedGroup()
Returns:
- number groupID -1 when no group selected
Spring.GetUnitGroup(unitID)
Parameters:
-
unitID
number
Returns:
- nil or number groupID
Spring.GetGroupUnits(groupID)
Parameters:
-
groupID
number
Returns:
- nil or {[number],...} unitIDs
Spring.GetGroupUnitsSorted(groupID)
Parameters:
-
groupID
number
Returns:
- nil or {[number]={[number],...},...} where keys are unitDefIDs and values are unitIDs
Spring.GetGroupUnitsCounts(groupID)
Parameters:
-
groupID
number
Returns:
- nil or {[number]=number,...} where keys are unitDefIDs and values are counts
Spring.GetGroupUnitsCount(groupID)
Parameters:
-
groupID
number
Returns:
- nil or number groupSize
Team/Player Info
rosterSpec
Roster spec
Contains data about a player
Fields:
-
name
string -
playerID
number -
teamID
number -
allyTeamID
number -
spectator
bool -
cpuUsage
number in order to find the progress, use: cpuUsage&0x1 if it's PC or BO, cpuUsage& 0xFE to get path res, (cpuUsage>>8)*1000 for the progress -
pingTime
number if -1, the player is pathfinding
Spring.GetPlayerRoster([sortType[, showPathingPlayers=false]])
Parameters:
-
sortType
number return unsorted if unspecified. Disabled = 0, Allies = 1, TeamID = 2, PlayerName = 3, PlayerCPU = 4, PlayerPing = 5 (optional) -
showPathingPlayers
bool (default false)
Returns:
- nil or {[rosterSpec],...} playerTable
Spring.GetPlayerTraffic(playerID, packetID)
Parameters:
-
playerID
number -
packetID
number [opt]
Returns:
- number traffic
Spring.GetPlayerStatistics(playerID)
Parameters:
-
playerID
number
Returns:
- nil or number mousePixels nil when invalid playerID
- number mouseClicks
- number keyPresses
- number numCommands
- number unitCommands
Configuration
configSpec
Configuration spec
Contains data about a configuration, only name and type are guaranteed
Fields:
Spring.GetConfigParams()
Returns:
Spring.GetConfigInt(name[, default=0])
Spring.GetConfigFloat(name[, default=0])
Spring.GetConfigString(name[, default=""])
Spring.GetLogSections()
Returns:
- {[string]=number,...} sections where keys are names and loglevel are values. E.g.
{ "KeyBindings" = LOG.INFO, "Font" = LOG.INFO, "Sound" = LOG.WARNING, ... }