Lua System

From Spring
Revision as of 04:40, 5 January 2011 by Jk (talk | contribs)
Jump to navigationJump to search

Development < Lua Scripting < Lua System

All Lua Contexts

Script.Kill

 ( ) -> nil

Script.GetName

 ( ) -> string luaInstanceName (e.g. "LuaUI", "LuaRules", "LuaGaia", ...)

Script.GetSynced

 ( ) -> boolean is_synced

Script.GetFullCtrl

 ( ) -> boolean has_fullctrl

Script.GetFullRead

 ( ) -> boolean has_fullread

Script.GetCtrlTeam

 ( ) -> number ctrl_teamID

Script.GetReadTeam

 ( ) -> number read_teamID

Script.GetReadAllyTeam

 ( ) -> number read_allyTeamID

Script.GetSelectTeam

 ( ) -> number select_teamID (defines which teamunits can be selected via 
Spring.SelectUnitMap/Spring.SelectUnitArray)

Script.GetGlobal

 ( ) -> nil | table globalEnv (returns nil if not in dev-mode)

Script.GetRegistry

 ( ) -> nil | table registryEnv (returns nil if not in dev-mode)

Script.GetCallInList

 ( ) -> table known_callins
 known_callins = {
   ["CallInName"] = { unsynced = boolean, controller = boolean }, (`controller` is true for all CallIns
which's return values are used by the engine for synced code, e.g. "AllowUnitCreation" is a controller) ... }

special team constants

number Script.NO_ACCESS_TEAM

number Script.ALL_ACCESS_TEAM

LuaUI only

Spring.SetShockFrontFactors

 ( [number minArea], [number minPower], [number distAdj] ) -> nil

Script.UpdateCallIn

 ( string callin_name ) -> nil


LuaGadgets only

Synced

number COBSCALE

Script.AddActionFallback

 ( string command, string help ) -> nil | boolean

Script.RemoveActionFallback

 ( string command ) -> nil | boolean

Script.UpdateCallIn

 ( string callin_name ) -> nil

Script.SetWatchWeapon Enables the `Explosion` callin for a specific WeaponDef.

 ( number weaponDefID, boolean enable ) -> nil

Script.GetWatchWeapon

 ( number weaponDefID ) -> nil | boolean enabled

SendToUnsynced

 ( arg1, arg2, ... ) -> nil
 Just nil, number, string and boolean datatypes are allowed as arguments! NO tables, userdatas, ...

CallAsTeam LOS checking depends on the `selected` team, this functions allows to select another one

 ( number teamID, lua_function f, arg1, arg2, ... ) -> nil
 ( table access, lua_function f, arg1, arg2, ... ) -> nil
 access = {
   [ctrl = number teamID,]
   [read = number teamID,]
   [select = number teamID,]
 }

Unsynced

Script.UpdateCallIn

 ( string callin_name ) -> nil

CallAsTeam LOS checking depends on the `selected` team, this functions allows to select another one

 ( number teamID, lua_function f, arg1, arg2, ... ) -> nil
 ( table access, lua_function f, arg1, arg2, ... ) -> nil
 access = {
   [ctrl = number teamID,]
   [read = number teamID,]
   [select = number teamID,]
 }

LuaRules only

Synced

Script.PermitHelperAIs

 ( boolean permit ) -> nil

Spring.SetUnitRulesParam

 ( number unitID, string paramName, number paramValue, table losAccess ) -> nil
  possible values for the losAccess table are:
   `private` : only readable by the ally (default)
   `allied`  : readable by ally + ingame allied
   `inlos`   : readable if the unit is in LOS
   `inradar` : readable if the unit is in AirLOS
   `public`  : readable by all
  note: if one condition is fulfilled all beneath it are too (e.g. if an unit is in LOS it can read params with `inradar=true` even if the param has `inlos=false`)
  note2: all GameRulesParam are public, TeamRulesParams can just be `private`,`allied` and/or `public`

Spring.SetTeamRulesParam

 ( number teamID, string paramName, number paramValue, table losAccess ) -> nil
  see above for further documentation of losAccess

Spring.SetGameRulesParam

 ( string paramName, number paramValue, table losAccess ) -> nil
  see above for further documentation of losAccess