-
-
Notifications
You must be signed in to change notification settings - Fork 11
Lua Support Script Attributes
Markers can interface with actively loaded Lua scripts by specifying a Lua function in an attribute. These functions can include arguments that potentially adjust the behavior of the execution for that marker.
The support attributes are:
- script-tick - Code that is executed in the same way that OnTick code is, but with the context of a specific marker.
- script-focus - Code that is executed when a marker is focused (player is within triggerRange).
- script-trigger - Code that is executed when a marker is triggered (player is within triggerRange and autoTrigger is on or the player has pressed their interact key).
- script-filter - Code that is executed every frame which returns if the marker should be visible.
- script-once - Code that is triggered once with the context of the specific marker.
For example, you may wish to provide a generic feature that moves a marker when it is interacted with. You may even wish for the adjusted height to vary marker to marker.
<marker ... script-trigger="MoveOutOfTheWay(0, 10, 0)" />
<marker ... script-trigger="MoveOutOfTheWay(1, 0, 0)" />
Then within your pack.lua
:
function MoveOutOfTheWay(marker, autoTriggered, x, y, z)
marker:SetPosition(marker.Position.X + x, marker.Position.Y + y, marker.Position.Z + Z);
end
All attribute-based functions will have a set of parameters that are required. You can define additional parameters however you would like which then will be passed based on what you've specified in the attribute value when calling the function.
script-once
:
-
marker
- A reference to the marker itself.
script-focus
:
-
marker
- A reference to the marker itself. -
isFocused
- Indicates if the marker was just focused (true
) or unfocused (false
).
script-trigger
:
-
marker
- A reference to the marker itself. -
isAutoTrigger
- Indicates if the player manually triggered (via interact) (false
) or if the trigger was automatic when the marker was focused via the autoTrigger attribute (true
).
script-filter
:
-
marker
- A reference to the marker itself. Returningtrue
will hide the marker.
script-tick
:
-
marker
- A reference to the marker itself. -
gameTime
- A reference to the current gameTime object.
Beyond the base parameters, you may provide any additional parameters that you wish. When providing a function in an attribute, if you wish to include arguments, you only must include the custom ones. The base arguments are provided by the module at the time of execution. If you do not wish to include custom attributes, you can provide the Lua function name without the rest of the argument syntax. For example:
<marker ... script-tick="MoveShadow" />
function MoveShadow(marker, gameTime)
-- move the shadow
end
As you can see, no argument syntax is required.
Arguments you provide in functions can be one of the following types:
-
nil - Indicated by as nil (
exampleFunction(nil)
). -
float - Indicated by a number with decimal (
exampleFunction(5.3)
). -
int - Indicated by a number without decimal (
exampleFunction(7)
). -
bool - Indicated by either
true
orfalse
(exampleFunction(false)
). -
string - Indicated by surrounding the string in double quotes (
exampleFunction("this is a string")
).