API ReferenceGE Extensionsflowgraphnodesvehicle
On Cannon Fired
- **Node Name:** `on Cannon Fired`
Overview
- Node Name:
on Cannon Fired - Category:
repeat_instant - File:
extensions/flowgraph/nodes/vehicle/onCannonFired.lua
Detects when a cannon is fired. Outputs an impulse flow signal for one frame when the onCannonFired game event occurs.
Pin Schema
Output Pins
| Pin | Type | Description |
|---|---|---|
cannonFired | flow (impulse) | Fires for one frame when a cannon is fired |
Internals
Key Methods
| Method | Description |
|---|---|
workOnce() | Initializes the flag to false |
work() | Checks if the flag is set; if so, outputs true for one frame and resets the flag |
onCannonFired(id) | Hook callback - sets the internal flag to true when a cannon fires |
How It Works
- The node listens for the
onCannonFiredgame hook, which is called when any cannon is fired in the game world. - When the hook fires,
onCannonFired(id)sets an internalflagtotrue. - On the next
work()call, the node outputscannonFired = truefor exactly one frame (impulse behavior), then resets the flag. - If no cannon was fired, the output stays
false.
Usage Example
-- In a flowgraph:
-- [on Cannon Fired] → (cannonFired) → [Play Sound Effect]
-- → [Increment Score]
-- The node reacts to the engine hook:
-- extensions.hook('onCannonFired', cannonId)Key Dependencies
onCannonFiredhook - engine-level event fired when a cannon weapon is discharged
See Also
- Align for Coupling (Flowgraph Node) - Related reference
- Apply Velocity to Vehicle (Flowgraph Node) - Related reference
- Boost Vehicle (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide