Lua System: Difference between revisions

From Spring
Jump to navigationJump to search
Jk (talk | contribs)
Documents functions added by the Lua context itself
 
Applied LuaConstant template to constant numbers.
 
(29 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Engine_Development|Development]] < [[Lua_Scripting|Lua Scripting]] < {{FULLPAGENAME}}
=All Lua Contexts=
=All Lua Contexts=
'''Script.Kill'''
{{LuaCallout
  ( ) -> nil
|prefix = Script.
|name = Kill
|arg1 =
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}
 
 
{{LuaCallout
|prefix = Script.
|name = GetName
|arg1 =
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|string}} luaInstanceName
|info = Returns the luaInstanceName (e.g. "LuaUI", "LuaRules", "LuaGaia", ...).
}}
 
 
{{LuaCallout
|prefix = Script.
|name = GetSynced
|arg1 =
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|bool}} is_synced
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}
 
 
{{LuaCallout
|prefix = Script.
|name = GetFullCtrl
|arg1 =
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|bool}} has_fullctrl
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}
 
 
{{LuaCallout
|prefix = Script.
|name = GetFullRead
|arg1 =
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|bool}} has_fullread
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}
 


'''Script.GetName'''
{{LuaCallout
  ( ) -> string luaInstanceName <span class=note>(e.g. "LuaUI", "LuaRules", "LuaGaia", ...)</span>
|prefix = Script.
|name = GetCtrlTeam
|arg1 =
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|number}} ctrl_teamID
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}


'''Script.GetSynced'''
  ( ) -> boolean is_synced


'''Script.GetFullCtrl'''
{{LuaCallout
  ( ) -> boolean has_fullctrl
|prefix = Script.
|name = GetReadTeam
|arg1 =
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|number}} read_teamID
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}


'''Script.GetFullRead'''
  ( ) -> boolean has_fullread


'''Script.GetCtrlTeam'''
{{LuaCallout
  ( ) -> number ctrl_teamID
|prefix = Script.
|name = GetReadAllyTeam
|arg1 =
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|number}} read_allyTeamID
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}


'''Script.GetReadTeam'''
  ( ) -> number read_teamID


'''Script.GetReadAllyTeam'''
{{LuaCallout
  ( ) -> number read_allyTeamID
|prefix = Script.
|name = GetSelectTeam
|arg1 =
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|number}} select_teamID
|info = Defines which teamunits can be selected via Spring.SelectUnitMap/Spring.SelectUnitArray.
}}


'''Script.GetSelectTeam'''
  ( ) -> number select_teamID <span class=note>(defines which teamunits can be selected via Spring.SelectUnitMap/Spring.SelectUnitArray)</span>


'''Script.GetGlobal'''
{{LuaCallout
  ( ) -> nil | <span class=warning>table globalEnv (returns nil if not in dev-mode)</span>
|prefix = Script.
|name = GetGlobal
|arg1 =
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|table}} globalEnv
|info = Returns nil if not in dev-mode.
}}


'''Script.GetRegistry'''
  ( ) -> nil | <span class=warning>table registryEnv (returns nil if not in dev-mode)</span>


'''Script.GetCallInList'''
{{LuaCallout
  ( ) -> table <span class=note>known_callins</span>
|prefix = Script.
<span class=note>
|name = GetRegistry
  known_callins = {
|arg1 =
     ["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)
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|table}} registryEnv
|info = Returns nil if not in dev-mode.
}}
 
 
{{LuaCallout
|prefix = Script.
|name = GetCallInList
|arg1 =
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|table}} known_callins
|info = Known CallIns are:
}}
  <span class=note>known_callins = {
     ["CallInName"] = { unsynced = boolean, controller = boolean }, (`controller` is true for<br>      all CallIns which's return values are used by the engine for synced code,<br>      e.g. "AllowUnitCreation" is a controller)
     ...
     ...
   }
   }
</span>


==special team constants==
number '''Script.NO_ACCESS_TEAM'''


number '''Script.ALL_ACCESS_TEAM'''
{{LuaCallout
|prefix = Script.
|name = IsEngineMinVersion
|arg1 = major {{bracket}}, minor {{bracket}}, commits {{rbracket}}{{rbracket}}
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|boolean}} isMinVersion
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}


==Special team constants==
{{LuaConstant
|type = number
|name = NO_ACCESS_TEAM
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}
{{LuaConstant
|type = number
|name = ALL_ACCESS_TEAM
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}


=LuaUI only=
=LuaUI only=
'''Spring.SetShockFrontFactors'''
  ( [number minArea], [number minPower], [number distAdj] ) -> nil


'''Script.UpdateCallIn'''
{{LuaCallout
  ( string callin_name ) -> nil
|prefix = Spring.
|name = SetShockFrontFactors
|arg1 = {{type|number}} minArea
|arg2 = {{type|number}} minPower
|arg3 = {{type|number}} distAdj
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}
 


{{LuaCallout
|prefix = Spring.
|name = UpdateCallIn
|arg1 = {{type|string}} callin_name
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}


=LuaGadgets only=
=LuaGadgets only=
==Synced==
==Synced==
number '''COBSCALE'''


'''Script.AddActionFallback'''
{{LuaConstant
  ( string command, string help ) -> nil | boolean
|type = number
|name = COBSCALE
|info =Number containing the cobscale factor, which is applied to transform the variables assigned via unit cob animation scripts for use inside the engine (default: 65536).
}}
 


'''Script.RemoveActionFallback'''
{{LuaCallout
  ( string command ) -> nil | boolean
|prefix = Script.
|name = AddActionFallback
|arg1 = {{type|string}} command
|arg2 = {{type|string}} help
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|boolean}} ???
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}


'''Script.UpdateCallIn'''
  ( string callin_name ) -> nil


'''Script.SetWatchWeapon''' <span class=note>Enables the `Explosion` callin for a specific WeaponDef.</span>
{{LuaCallout
  ( number weaponDefID, boolean enable ) -> nil
|prefix = Script.
|name = RemoveActionFallback
|arg1 = {{type|string}} command
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|boolean}} ???
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}


'''Script.GetWatchWeapon'''
  ( number weaponDefID ) -> nil | boolean enabled


'''SendToUnsynced'''
{{LuaCallout
  ( arg1, arg2, ... ) -> nil
|prefix = Script.
  <span class=warning>Just nil, number, string and boolean datatypes are allowed as arguments! NO tables, userdatas, ...</span>
|name = UpdateCallIn
|arg1 = {{type|string}} callin_name
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}


'''CallAsTeam'''
  ( ) -> nil


{{LuaCallout
|prefix = Script.
|name = SetWatchFeature
|arg1 = {{type|number}} featureDefID
|arg2 = {{type|boolean}} enable
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = Enables the `UnitFeatureCollision` callin for a specific [[Gamedev:FeatureDefs|FeatureDef]].
}}
{{LuaCallout
|prefix = Script.
|name = GetWatchFeature
|arg1 = {{type|number}} featureDefID
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|boolean}} enabled
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}
{{LuaCallout
|prefix = Script.
|name = SetWatchUnit
|arg1 = {{type|number}} unitDefID
|arg2 = {{type|boolean}} enable
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = Enables the `UnitUnitCollision`, `UnitFeatureCollision` and `UnitMoveFailed` callins for a specific [[Gamedev:UnitDefs|UnitDef]].
}}
{{LuaCallout
|prefix = Script.
|name = GetWatchUnit
|arg1 = {{type|number}} unitDefID
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|boolean}} enabled
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}
{{LuaCallout
|prefix = Script.
|name = SetWatchWeapon
|arg1 = {{type|number}} weaponDefID
|arg2 = {{type|boolean}} enable
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = Enables the `Explosion` and (as of 0.83+) `ProjectileCreated` and `ProjectileDestroyed` callins for a specific WeaponDef.
}}
{{LuaCallout
|prefix = Script.
|name = GetWatchWeapon
|arg1 = {{type|number}} weaponDefID
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|boolean}} enabled
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}
{{LuaCallout
|prefix = Script.
|name = GetWatchWeapon
|arg1 = {{type|number}} weaponDefID
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}} {{pipe}} {{type|boolean}} enabled
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}
{{LuaCallout
|prefix =
|name = SendToUnsynced
|arg1 = arg1
|arg2 = arg2
|arg3 = ...
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = Just nil, number, string and boolean datatypes are allowed as arguments! NO tables, userdatas, ...
}}
{{LuaCallout
|prefix =
|name = CallAsTeam
|arg1 = {{type|number}} teamID
|arg2 = lua_function f
|arg3 = arg1
|arg4 = arg2
|arg5 = ...
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
or <br>
{{LuaCallout
|prefix =
|name = CallAsTeam
|arg1 = {{type|table}} access
|arg2 = lua_function f
|arg3 = arg1
|arg4 = arg2
|arg5 = ...
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = LOS checking depends on the `selected` team, this functions allows to select another one.
}}
  <span class=note>access = {
    [ctrl = number teamID,]
    [read = number teamID,]
    [select = number teamID,]
  }</span>


==Unsynced==
==Unsynced==
'''Script.UpdateCallIn'''
  ( string callin_name ) -> nil


'''CallAsTeam'''
{{LuaCallout
  ( ) -> nil
|prefix = Script.
|name = UpdateCallIn
|arg1 = {{type|string}} callin_name
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}
 


{{LuaCallout
|prefix =
|name = CallAsTeam
|arg1 = {{type|number}} teamID
|arg2 = lua_function f
|arg3 = arg1
|arg4 = arg2
|arg5 = ...
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info =
}}
or <br>
{{LuaCallout
|prefix =
|name = CallAsTeam
|arg1 = {{type|table}} access
|arg2 = lua_function f
|arg3 = arg1
|arg4 = arg2
|arg5 = ...
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = LOS checking depends on the `selected` team, this functions allows to select another one.
}}


  <span class=note>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)
  }</span>


=LuaRules only=
=LuaRules only=
==Synced==
==Synced==
'''Script.PermitHelperAIs'''
  ( boolean permit ) -> nil


'''Spring.SetUnitRulesParam'''
{{LuaCallout
  ( ) -> nil
|prefix = Script.
|name = PermitHelperAIs
|arg1 = {{type|boolean}} permit
|arg2 =
|arg3 =
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{type|nil}}
|info = <font color="maroon" style="font-weight:600">No description available</font>
}}
 


'''Spring.SetTeamRulesParam'''
[[category: Lua]]
  ( ) -> nil


'''Spring.SetGameRulesParam'''
[[category: Lua]]
  ( ) -> nil

Latest revision as of 22:17, 28 February 2021

Development < Lua Scripting < Lua System

All Lua Contexts

Script.Kill ( )
return: nil

No description available


Script.GetName ( )
return: string luaInstanceName

Returns the luaInstanceName (e.g. "LuaUI", "LuaRules", "LuaGaia", ...).


Script.GetSynced ( )
return: bool is_synced

No description available


Script.GetFullCtrl ( )
return: bool has_fullctrl

No description available


Script.GetFullRead ( )
return: bool has_fullread

No description available


Script.GetCtrlTeam ( )
return: number ctrl_teamID

No description available


Script.GetReadTeam ( )
return: number read_teamID

No description available


Script.GetReadAllyTeam ( )
return: number read_allyTeamID

No description available


Script.GetSelectTeam ( )
return: number select_teamID

Defines which teamunits can be selected via Spring.SelectUnitMap/Spring.SelectUnitArray.


Script.GetGlobal ( )
return: nil | table globalEnv

Returns nil if not in dev-mode.


Script.GetRegistry ( )
return: nil | table registryEnv

Returns nil if not in dev-mode.


Script.GetCallInList ( )
return: table known_callins

Known CallIns are:
 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) ... }


Script.IsEngineMinVersion ( major [, minor [, commits ]] )
return: nil | boolean isMinVersion

No description available

Special team constants

number NO_ACCESS_TEAM

No description available


number ALL_ACCESS_TEAM

No description available

LuaUI only

Spring.SetShockFrontFactors ( number minArea, number minPower, number distAdj )
return: nil

No description available


Spring.UpdateCallIn ( string callin_name )
return: nil

No description available

LuaGadgets only

Synced

number COBSCALE

Number containing the cobscale factor, which is applied to transform the variables assigned via unit cob animation scripts for use inside the engine (default: 65536).


Script.AddActionFallback ( string command, string help )
return: nil | boolean ???

No description available


Script.RemoveActionFallback ( string command )
return: nil | boolean ???

No description available


Script.UpdateCallIn ( string callin_name )
return: nil

No description available


Script.SetWatchFeature ( number featureDefID, boolean enable )
return: nil

Enables the `UnitFeatureCollision` callin for a specific FeatureDef.


Script.GetWatchFeature ( number featureDefID )
return: nil | boolean enabled

No description available


Script.SetWatchUnit ( number unitDefID, boolean enable )
return: nil

Enables the `UnitUnitCollision`, `UnitFeatureCollision` and `UnitMoveFailed` callins for a specific UnitDef.


Script.GetWatchUnit ( number unitDefID )
return: nil | boolean enabled

No description available


Script.SetWatchWeapon ( number weaponDefID, boolean enable )
return: nil

Enables the `Explosion` and (as of 0.83+) `ProjectileCreated` and `ProjectileDestroyed` callins for a specific WeaponDef.


Script.GetWatchWeapon ( number weaponDefID )
return: nil | boolean enabled

No description available


Script.GetWatchWeapon ( number weaponDefID )
return: nil | boolean enabled

No description available


SendToUnsynced ( arg1, arg2, ... )
return: nil

Just nil, number, string and boolean datatypes are allowed as arguments! NO tables, userdatas, ...


CallAsTeam ( number teamID, lua_function f, arg1, arg2, ... )
return: nil

or
CallAsTeam ( table access, lua_function f, arg1, arg2, ... )
return: nil

LOS checking depends on the `selected` team, this functions allows to select another one.
 access = {
   [ctrl = number teamID,]
   [read = number teamID,]
   [select = number teamID,]
 }

Unsynced

Script.UpdateCallIn ( string callin_name )
return: nil

No description available


CallAsTeam ( number teamID, lua_function f, arg1, arg2, ... )
return: nil

or
CallAsTeam ( table access, lua_function f, arg1, arg2, ... )
return: nil

LOS checking depends on the `selected` team, this functions allows to select another one.
 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 )
return: nil

No description available