Flowgraph AI Recording Module
Handles recording and replaying AI vehicle scripts during mission execution. Used for mission testing - records the player's driving as an AI path, then saves it alongside mission test data.
Handles recording and replaying AI vehicle scripts during mission execution. Used for mission testing - records the player's driving as an AI path, then saves it alongside mission test data.
No public module exports - created via _flowgraph_createModule(C).
Purpose
When enabled, this module records the player vehicle's movement as an AI script path. On mission completion, the recording is saved to the mission's tests/ folder as a .missionTestData.json file for automated replay testing.
Key Methods
| Method | Signature | Description |
|---|---|---|
init | () | Initializes AI recording state. |
startAiRecording | () | Sends ai.startRecording() to the player vehicle's Lua VM. |
stopAiRecording | (attempt, totalChange) | Sends ai.stopRecording() to the vehicle, which submits the recording back via hook. |
startAiReplay | () | Replays a stored AI path from activity.startingOptions.aiPath using ai.startFollowing(). |
stopAiReplay | () | Stops AI script replay via ai:scriptStop(). |
onVehicleSubmitRecordingForMission | (vehId, aiPath) | Hook callback: receives the recorded AI path from the vehicle, packages it with vehicle/mission data, and saves to JSON. |
setenabled | (newEnabled) | Toggles recording capability on/off. |
isRecordingScriptAi | () | Returns whether recording is enabled. |
executionStopped | () | Stops any active recording. |
Hooks
| Hook | Description |
|---|---|
onVehicleSubmitRecordingForMission | Receives AI path data from vehicle Lua after recording stops. |
Saved Test Data Format
-- Saved to: mission.missionFolder/tests/recording_YYYY-MM-DD HH_MM_SS.missionTestData.json
{
aiPath = { path = { {t=0, ...}, {t=1.5, ...}, ... } },
userSettings = { ... },
vehicle = {
model = "etk800",
config = "police",
isConfigFile = true,
licensePlate = "BNG 001",
},
attemptData = { ... },
attemptStars = { ... },
aiDuration = 45.2, -- seconds
}Properties
| Property | Default | Description |
|---|---|---|
moduleOrder | 1 | Runs after missionReplayModule. |
hooks | {"onVehicleSubmitRecordingForMission"} | Subscribed hooks. |
Vehicle Communication
-- Recording uses a round-trip through vehicle Lua:
-- GE → Vehicle: ai.startRecording() / ai.stopRecording()
-- Vehicle → GE: extensions.hook("onVehicleSubmitRecordingForMission", objectId, aiPath)
veh:queueLuaCommand('obj:queueGameEngineLua("extensions.hook(...)")')Additional Exports
executionStarted()
getVehicleStates()
- Returns:
any
See Also
- Flowgraph Action Module - Related reference
- Flowgraph Button Module - Related reference
- Flowgraph Camera Module - Related reference
- FlowGraph Guide - Guide
Flowgraph Action Module
Manages input action filtering for flowgraph projects. Allows nodes to block or allow specific player input actions during flowgraph execution (e.g., disabling certain controls during a mission cutsce
Flowgraph Button Module
Manages custom UI buttons displayed during flowgraph execution. Nodes can create, configure, and respond to button clicks through this module. Button state is sent to the UI via `guihooks.trigger('Cus