API ReferenceGE ExtensionsflowgraphnodesvehicleaiscriptAI
AI Path from File
- **Node Name:** `AI Path from File`
Overview
- Node Name:
AI Path from File - Category:
provider - File:
extensions/flowgraph/nodes/vehicle/ai/scriptAI/pathFromFile.lua
Loads a ScriptAI path from a .track.json file and provides it as output data. Feed the output into "AI Follow Path from Data" to drive a vehicle along the path.
Pin Schema
Output Pins
| Pin | Type | Description |
|---|---|---|
path | table (aiPath) | AI path loaded from the selected file. |
Internals
Key Methods
| Method | Description |
|---|---|
init() | Scans /replays/scriptai/tracks/ for .track.json files. |
work() | Lazily loads the selected file via jsonReadFile() and outputs recording data. |
drawCustomProperties() | Editor UI with a "Refresh Files" button and file combo selector. |
_onSerialize(res) | Saves the selected fileName. |
_onDeserialized(nodeData) | Restores fileName and derives the short display name. |
Constants
| Constant | Value | Description |
|---|---|---|
trackFilePath | /replays/scriptai/tracks/ | Directory for track files. |
trackFileExt | .track.json | File extension for ScriptAI recordings. |
How It Works
- On
init(), scans the tracks directory usingFS:findFiles(). - The editor displays a dropdown of available files (short names without path/extension).
- On first
work()call, lazily loads the JSON file viajsonReadFile(). - Outputs
self.loadedFile.recordingas thepathpin - anaiPathtable with position/time data.
File Format
ScriptAI track files (.track.json) contain:
{
"vehicle": "etk800",
"levelName": "west_coast_usa",
"recording": {
"path": [
{"x": 100.0, "y": 200.0, "z": 50.0, "t": 0.0},
{"x": 101.5, "y": 201.2, "z": 50.1, "t": 0.5}
]
}
}Usage Example
-- Flowgraph chain:
-- [AI Path from File] → path → [AI Follow Path from Data] → flow → [Done]
-- Programmatic equivalent:
local data = jsonReadFile("/replays/scriptai/tracks/myTrack.track.json")
local path = data.recording
veh:queueLuaCommand('ai.startFollowing(' .. serialize(path) .. ')')Key Dependencies
FS:findFiles()- filesystem scan for track filesjsonReadFile()- JSON file loader- ScriptAI recording format (
{path = [{x,y,z,t}, ...]})
See Also
- AI Follow Path from Data (Flowgraph Node) - Related reference
- Stored AI Path (Flowgraph Node) - Related reference
- Play ScriptAI Recording (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide