Game/Scripts/common.lua
Game/Scripts/main.lua
The following globals should be used to avoid temporary Lua memory allocations:
Global Name | Description |
---|---|
g_SignalData_point | Basic 3D vector value used by g_SignalData. |
g_SignalData_point2 | Basic 3D vector value used by g_SignalData. |
g_SignalData | Used for passing signal data in the AI behavior scripts (see: AI.Signal). |
g_StringTemp1 | Commonly used for temporary strings inside Lua functions. |
g_HitTable | Commonly used by the Physics.RayWorldIntersection function within the Lua scripts as the last parameter. |
The g_HitTable content after a Physics.RayWorldIntersection call:
Parameter name | Description |
---|---|
pos | 3D vector world coordinates of the ray hit. |
normal | 3D normal vector of the ray hit. |
dist | hit distance of the ray hit. |
surface | surface type identifier of the surface that was hit. |
entity | if an entity was hit, this contains the scripttable of the entity. |
renderNode | contains a scripthandle to a foliage or static render node. |
The g_SignalData table can contain the following parameter types:
Parameter type | Description |
---|---|
Vec3 | Possible 3D vector you need to pass along. |
Vec3 | Possible 3D vector you need to pass along. |
ScriptHandle | Normally used to pass along an entity identifier (EnityId). |
Floating Point | Possible floating point value you need to pass along. |
Integer | Possible integer or number value you need to pass along. |
Integer | Possible integer or number value you need to pass along. |
String | Possible string value you need to pass along. |
String | Possible string value you need to pass along. |
Reloads the aiconfig.lua Lua script (Game/Scripts/AI/).
Toggles the ai_DebugDraw console variable on and off.
Logs the current system time to console. Formatting is like the following: Day/Month/Year, Hours:Minutes
Returns the amount of key-value pairs of a given table.
Parameters | Description |
---|---|
_tbl | table to get the amount of key-value pairs from. |
Creates a new table based on the given one in the parameter _obj. Commonly used for creating a local table based on an entity parameter table.
Parameters | Description |
---|---|
_obj | base table you want to create a new one from. |
norecurse | if set to true it avoids recursive recreation of all sub-tables. |
Used to partly merge 2 tables without merging the functions from the source table.
Parameters | Description |
---|---|
dst | destination table to merge to. |
src | source table to get the table information from. |
recurse | recursive merging of all sub-tables. |
Used to completly merge 2 tables with all functions of the source table.
Parameters | Description |
---|---|
dst | destination table to merge to |
src | source table to get the table information from |
recursive | recursive merging of all subtables |
Used to convert a 3D vector table into a string and returns it as follows: (x: X.XXX y: Y.YYY z: Z.ZZZ)
Parameter | Description |
---|---|
vec | vector table e.g:
|
Used to log an error message to the console and the log file. The text color is set to red in the console.
Parameters | Description |
---|---|
fmt | formatted string message |
... | possible argument list e.g:
|
Used to log a warning message to the console and the log file. The text color is set to yellow in the console.
Parameters | Description |
---|---|
fmt | formatted string message |
... | possible argument list e.g:
|
Used to log a message to the console and the log file. Commonly used for debugging purposes.
Parameters | Description |
---|---|
fmt | formatted string message |
... | possible argument list e.g:
|
Dumps the table information to console.
Parameters | Description |
---|---|
_class | table you want to dump to console (e.g: g_localActor) |
no_func | if set to true it won't dump the table functions |
depth | defines the table tree depth you are interested in |
Checks whether a given string is set and it's length is greater than zero and returns true if so.
Parameter | Description |
---|---|
str | string to check if it is an empty string |
Checks whether a number value is true or false. In this case true means the number is not equal to 0.
Parameter | Description |
---|---|
n | number to check |
Returns the name of the given entity table or the entity identifier or an empty string if the entity doesn't exist.
Parameter | Description |
---|---|
entity | entity table or entity identifier (EntityId) |
Returns true if an entity with the given name exists in the entity system. Commonly used for debugging.
Parameter | Description |
---|---|
name | name of the entity to check |
Checks if a subtable with a given name exists in the given table and returns it, otherwise it returns nil.
Parameters | Description |
---|---|
table | base table to check for the subtable |
name | name of the subtable |