Development < Lua Scripting < Lua System
Contents |
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.SetWatchFeature Enables the `UnitFeatureCollision` callin for a specific FeatureDef.
( number featureDefID, boolean enable ) -> nil
Script.GetWatchFeature
( number featureDefID ) -> nil | boolean enabled
Script.SetWatchUnit Enables the `UnitUnitCollision`, `UnitFeatureCollision` and `UnitMoveFailed` callins for a specific UnitDef.
( number unitDefID, boolean enable ) -> nil
Script.GetWatchUnit
( number unitDefID ) -> nil | boolean enabled
Script.SetWatchWeapon Enables the `Explosion` and (as of 0.83+) `ProjectileCreated` and `ProjectileDestroyed` callins 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,] (limits Spring.GiveOrderXYZ) [read = number teamID,] (limits reading of unit params, e.g. Spring.GetUnitLosState) [select = number teamID,] (limits Spring.SelectUnitXYZ) }
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` note3: You can read RulesParams from any Lua enviroments! With those losAccess
policies you can limit their access.
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