This folder contains lua script files which will be referenced by both TE and TEN to work with node trigger system.
TE uses metadata from comments in these files to build UI, while TEN uses actual functions to execute node scripts.
On level compile, all files from this directory are copied to TEN Scripts\NodeCatalogs
folder and executed on level start-up, given that level contains any volumes. Therefore, NodeFunctions.lua file in TENScripts\NodeCatalogs
folder should never be modified.
Lua node scripts should follow this convention: several metadata signatures should be followed by actual function
body which should start with conventional LevelFuncs.Engine.Node. prefix. Amount of argument metadata
signatures should be the same as actual function arguments, and should be listed in the same order.
Comment metadata signature reference (metadata block is indicated by a keyword which starts with !):
\n
symbol to begin from a_System.lua
Metadata blocks can appear in any order.
Metadata parsing happens until real function block starts (which should start with LevelFuncs.Engine.Node.
prefix).
Conditional node functions (those with !Conditional = “True” specified) must return boolean value, otherwise
their behaviour is undefined.
ARGDESC parameters can appear in any order, e.g. !Argument "Foo, Numerical, 20"
is equal to!Argument "Numerical, 20, Foo"
.
There could be several !Argument blocks, which will append arguments to previously parsed ones.
There could be several !Description blocks, which will append as a new line to previous description block.
ENUMDESC parameters should NOT be quoted, or else parsing will fail miserably.
true
or false
. Appears as a checkbox with argument description\n
Objects.ObjID.
lua enumeration which is identical to TE/TEN object slot enumeration.LevelFuncs.CompareValue
helper functionLevelFuncs.CompareValue(operand, reference, operator)
.-- !Name "Check moveable health"
-- !Description "Compares selected moveable health with given value."
-- !Conditional "True"
-- !Arguments "NewLine, Moveables, Moveable to check" "NewLine, CompareOperator, 70, Kind of check"
-- !Arguments "Numerical, 30, [ 0 | 1000 | 0 ], Hit points value"
LevelFuncs.CheckEntityHealth = function(moveableName, operator, value)
local health = TEN.Objects.GetMoveableByName(entityName):GetHP()
return LevelFuncs.CompareValue(health, value, operator)
end
Here, !Arguments signature lists 3 parameters, which will be called “Moveable to check”, “Kind of check”
and “Hit points value” respectively. First argument, “Moveable to check”, will occupy whole second line of a
node UI, because width is not explicitly stated for it. Next two arguments, “Kind of check” and “Hit points
value”, both will occupy same next line, because NewLine keyword is not specified for third argument.
Second argument, “Kind of check”, will occupy 70 percent of line width, while “Hit points value” will occupy
30 percent. Note that arguments sitting on the same line should sum to 100 percent width, otherwise
UI symmetry is not guaranteed.
Also note that “Hit points value” argument is placed on separate !Arguments block, and this is correct,
since it will appear after previous argument block. Also, being numerical argument, it will allow user to
only define values between 0 and 1000. All other values will be clamped. Decimal places for a value won’t
show, as third parameter in square brackets is set to 0.
LevelFuncs.CheckEntityHealth function declaration should contain same amount of arguments and in the same
order as metadata argument signature. Therefore, moveableName will be read from “Moveable to check”
UI argument, operator will be read from “Kind of check”, and so on.