Timed Trigger (Flowgraph Node)
- **Node Name:** `Timed Trigger`
Overview
- Node Name:
Timed Trigger - Category:
logic - Behaviour:
{once = true, duration = true} - File:
extensions/flowgraph/nodes/logic/timedTrigger.lua
Requires continuous input on the charge pin for a specified duration before triggering. Resets if charging stops for too long.
Pin Schema
Input Pins
| Pin | Type | Description |
|---|---|---|
flow | flow | Inflow for this node |
charge | flow | Timer charges while this pin has flow |
Output Pins
| Pin | Type | Description |
|---|---|---|
flow | flow | Continuous flow once charge duration is met |
complete | flow | One-shot impulse when charge completes |
Data Properties
| Property | Type | Default | Description |
|---|---|---|---|
duration | number | 3 | Seconds of charging required to trigger |
resetTimer | number | 1 | Seconds without charge before the timer resets |
Behavior
init(mgr, ...)- Sets defaults: duration=3, resetTimer=1, timer=0.work(args)- Updates charge state each frame. Whilechargehas flow, increments timer bydtSim. When timer reachesduration, firescompleteimpulse once and keepsflowactive. When charge stops, increments reset counter; if reset counter reachesresetTimer, the charge timer resets to 0._executionStopped()- Resets all state.drawMiddle()- Shows two progress bars: charge progress and reset countdown.
How It Works
Think of this as a "hold to activate" mechanism. The player (or system) must sustain flow on the charge pin for the full duration. If charging is interrupted, a grace period (resetTimer) begins counting. If charging resumes before the grace period expires, progress is preserved. If the grace period expires, all progress is lost.
The complete pin fires exactly once when the charge first reaches the threshold. The flow pin remains active continuously after completion.
Example Usage
-- "Hold button for 3 seconds to confirm":
-- duration = 3, resetTimer = 1
-- charge = button held flow
-- complete → execute the confirmation action
-- If player releases for < 1 second, progress is kept
-- If released for > 1 second, starts overAdditional Methods
C:_onDeserialized(res)
Called after the node is deserialized (loaded from file). Restores runtime state from saved data.
Parameters:
res
C:_onSerialize(res)
Called when the node is serialized (saved to file). Returns data to persist.
Parameters:
res
C:updateCharge()
Node method.
See Also
- And (Flowgraph Node) - Related reference
- Boolean Expression (Flowgraph Node) - Related reference
- Branch (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide