Lua_UnsyncedRead - beyond-all-reason/springrts_engine_wiki_mirror GitHub Wiki

Development < Lua Scripting <

Unsynced Read

Replay/Spectating

Game/Menu Name

ModUI

MyInfo

Local Player,Team,Ally

Redundant same as the GetMyXYZ functions!

Team/Player Info

playerTable = {
            [1] = {
              string  name,
              number  playerID,
              number  teamID,
              number  allyTeamID,
              boolean spectator,
              number  cpuUsage,
              number  pingTime
            },
            etc...
          }

   if pingTime == -1, the player is pathfinding, 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
  Sort codes:
     1 = Sort by allies  (the default)
     2 = Sort by teamID
     3 = Sort by playerName
     4 = Sort by CPU usage
     5 = Sort by ping time

Sound

Camera

vectorTable = {
    forward   = { [1] = number x, [2] = number y, [3] = number z },
    up        = { [1] = number x, [2] = number y, [3] = number z },
    right     = { [1] = number x, [2] = number y, [3] = number z },
    top       = { [1] = number x, [2] = number y, [3] = number z },
    bottom    = { [1] = number x, [2] = number y, [3] = number z },
    leftside  = { [1] = number x, [2] = number y, [3] = number z },
    rightside = { [1] = number x, [2] = number y, [3] = number z }
  }

Inview

Screen Trace

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.

To get map coordinates under mouse cursor: input mouse coordinates obtained via GetMouseState() and pass true for the onlyCoords parameter. Be careful as going off map will result in nil:
   local mouseX, mouseY = Spring.GetMouseState()
   print ("Mouse coordinates: (" .. mouseX .. ", " .. mouseY .. ")")
   local desc, args = Spring.TraceScreenRay(mouseX, mouseY, true)
   if nil == desc then return end -- off map
   local x = args[1]
   local y = args[2]
   local z = args[3]
   print ("World coordinates: (" .. x .. ", " .. y .. ", " .. z .. ")")

Screen & Window Geometry

Unit

Selected Units

Unit Groups

Feature

Projectiles

UI

GUI Settings

  mode numbers:
      0 - basic
      1 - reflective
      2 - dynamic
      3 - refractive
      4 - bumpwater
      default - unknown

Unit & Feature GUI States

Minimap

(Build-)Menu

cmdDesc = {
    [1] = {
      id=number,
      type=number,
      name=string,
      action=string,
      tooltip=string,
      texture=string,
      cursor=string,
      hidden=boolean,
      disabled=boolean,
      showUnique=boolean,
      onlyTexture=boolean,
      params = { [1] = string, .. }
    }, ...
  }

cmdDesc = {
      id=number,
      type=number,
      name=string,
      action=string,
      tooltip=string,
      texture=string,
      cursor=string,
      hidden=boolean,
      disabled=boolean,
      showUnique=boolean,
      onlyTexture=boolean,
      params = { [1] = string, .. }
  }

Build Facing

GatherMode & InvertQueueKey

Mouse States

(Hot-)Keys

keyBindings = {
    [1] = {
      [string actionCmd] = string actionExtra,
      command   = string actionCmd,    {{new|97}}
      boundWith = string boundWith,    {{new|97}}
      extra     = string actionExtra,  {{new|97}}
    }, ...
  }

Console

LOS Colors

Config

configParams = {
    {
      name = string,
      type = string,
      [ description = string, ]
      [ defaultValue = string, ]
      [ minimumValue = string, ]
      [ maximumValue = string, ]
      [ safemodeValue = string, ]
      [ declarationFile = string, ]
      [ declarationLine = number, ]
      [ readOnly = bool, ]
    },
    ...
  }

FPS & GetDrawFrame

Time

Rendering

Logging

Misc

category: Lua

⚠️ **GitHub.com Fallback** ⚠️