API ReferenceGE ExtensionsflowgraphnodesvehicleaiscriptAI
Play ScriptAI Recording
- **Node Name:** `Play ScriptAI Recording`
Overview
- Node Name:
Play ScriptAI Recording - Category:
repeat_p_duration - File:
extensions/flowgraph/nodes/vehicle/ai/scriptAI/playRecording.lua
Plays a ScriptAI recording from a file. Supports start/stop impulse control and loop count. Unlike "AI Follow Path from Data", this node loads the file directly by name.
Pin Schema
Input Pins
| Pin | Type | Description |
|---|---|---|
start | flow (impulse) | Starts playing the recording. |
stop | flow (impulse) | Stops the recording. |
fileName | string | Path to the .track.json file to load. |
vehId | number | Vehicle to play recording on. Uses player vehicle if empty. |
loopCount | number | Number of loops (-1 = infinite). |
Internals
Key Methods
| Method | Description |
|---|---|
init() | Initializes with no recording, not running. |
postInit() | Configures the fileName pin to accept .track.json files in the file browser. |
play() | Loads the recording, sets loop count/type, sends ai.startFollowing(). |
stop() | Sends ai.stopFollowing() and marks not running. |
loadRecording() | Attempts multiple path resolutions for the file (relative, tracks dir, with/without extension). |
work() | Dispatches start and stop impulses. |
drawMiddle() | Shows recording info: vehicle, level, path count, duration, and optional debug path rendering. |
Data Properties
| Property | Default | Description |
|---|---|---|
renderDebug | false | Draw path points and prisms in 3D viewport. |
File Resolution Order
The node tries to load the file in this order:
- Relative path from flowgraph manager
- Relative path with
.track.jsonextension appended /replays/scriptai/tracks/+ filename/replays/scriptai/tracks/+ filename +.track.json
How It Works
- When
startimpulse fires,play()loads the recording JSON. - Sets
loopCountandloopType = "firstOnlyTeleport"on the recording data. - Sends
ai.startFollowing(recording)to the vehicle. - When
stopimpulse fires, sendsai.stopFollowing()to halt playback.
Usage Example
-- Flowgraph:
-- [Button Press] → start → [Play ScriptAI Recording (fileName="myTrack", loopCount=3)]
-- [Another Event] → stop ↗
-- Equivalent vehicle commands:
local data = jsonReadFile("/replays/scriptai/tracks/myTrack.track.json")
data.recording.loopCount = 3
data.recording.loopType = "firstOnlyTeleport"
veh:queueLuaCommand('ai.startFollowing(' .. serialize(data.recording) .. ')')
-- To stop:
veh:queueLuaCommand('ai.stopFollowing()')Key Dependencies
ai.startFollowing()/ai.stopFollowing()- vehicle-side ScriptAI controljsonReadFile()- JSON file loader.track.jsonformat - ScriptAI recording files
See Also
- AI Follow Path from Data (Flowgraph Node) - Related reference
- AI Path from File (Flowgraph Node) - Related reference
- Stored AI Path (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide