Portals-specific functions
Function Effect adds Portals helpers on top of the expression language. These are the helpers you use to read your space’s state and make a focused change.
Read state
$TN{Task name}: a task as a number
Use this for every task condition:
$TN{OpenGate} == 1.0
| Result | Meaning |
|---|---|
| 0.0 | Not Active |
| 1.0 | Active |
| 2.0 | Completed |
$N{Value name}: a named value
$N{Coins} >= 25.0
Use a name created in Variable Manager or by a deliberate initialization task. The value’s scope and persistence come from its configuration.
$N{Timer name}: a running timer
$N{RaceTimer} <= 90.0
Start the named timer with the no-code Start Timer effect before using it in a rule. Treat a timer as a timer, not as a general-purpose variable.
Change a task
SetTask('taskName', 'NotActive' | 'Active' | 'Completed', delaySeconds)
Examples:
SetTask('OpenDoor', 'Active', 0.0)
SetTask('ResetRound', 'NotActive', 5.0)
SetTask('AwardBadge', 'Completed', 1.5)
Create the named task first so its scope, effects, and persistence are intentional. The final argument is a delay in seconds.
Change a value
SetVariable('valueName', value, delaySeconds)
Examples:
SetVariable('Coins', 0.0, 0.0)
SetVariable('DoorMessage', 'Unlocked', 0.0)
SetVariable('CooldownReady', 1.0, 3.0)
The third argument is always a delay. It is not an operation type or a persistence setting.
Update a shared numeric value
Use this only for a numeric variable configured as multiplayer:
UpdateMultiplayerNumericVariable('TeamScore', 1.0, 1.0, 0.0)
Its arguments are:
UpdateMultiplayerNumericVariable('variableName', value, operation, delaySeconds)
| Operation | Result |
|---|---|
| 0.0 | Set to value |
| 1.0 | Add value |
| 2.0 | Subtract value |
| 3.0 | Multiply by value |
| 4.0 | Divide by value |
For example, adding one through this helper is safer for a shared score than reading a score, adding one locally, and writing it back.
Re-run when state changes
The Function Effect settings provide two important options:
| Setting | Use it when |
|---|---|
| Trigger On Tasks Change | The expression should be evaluated again when a $TN{...} or $N{...} reference changes. |
| Activate On Start | The expression should run once as the task is prepared. |
Use those settings rather than placing legacy inline change subscriptions inside the expression. Explicit references plus the toggle make the dependency visible and easier to maintain.
Recipe: a delayed reset
After a player completes PuzzleSolved, make PuzzleReset active immediately and set it back after ten seconds:
if(
$TN{PuzzleSolved} == 2.0,
SetTask('PuzzleReset', 'Active', 0.0),
''
)
Put the delayed reset in the PuzzleReset task’s own effect chain:
SetTask('PuzzleReset', 'NotActive', 10.0)
Keeping reset behavior on a named task makes it easier to inspect and test.
See Multiplayer Functions for per-player lists and team logic.
