Flowgraph Mission Module
Manages mission-specific vehicle handling, traffic control, and mission lifecycle events for flowgraph projects. Coordinates between the flowgraph execution and the mission system.
Manages mission-specific vehicle handling, traffic control, and mission lifecycle events for flowgraph projects. Coordinates between the flowgraph execution and the mission system.
No public module exports - created via _flowgraph_createModule(C).
Purpose
When a mission runs via flowgraph, this module handles:
- Processing vehicle visibility (player vehicle, traffic) based on mission parameters
- Preparing vehicles (e.g., setting headlights based on time of day)
- Tracking the original player vehicle for stash/restore
- Removing stashed vehicles if needed
- Firing mission lifecycle hooks and stopping missions on execution end
Key Methods
| Method | Signature | Description |
|---|---|---|
init | () | Calls clear(). |
clear | () | Resets the processed flag. |
processVehicles | (params) | Applies vehicle visibility settings: keepPlayer shows/hides the original player vehicle, keepTraffic unfreezes/freezes traffic. Only runs once per execution. |
prepareVehicle | (id) | Prepares a vehicle for mission play (e.g., turns on headlights if it's nighttime). Defaults to player vehicle 0. |
getOriginalPlayerId | () | Returns the vehicle ID from activity._startingInfo.vehId. |
removeStashedPlayerVehicle | () | Permanently deletes the stashed original player vehicle (won't be restored after mission). |
missionHook | (name, data) | Fires a custom event on the mission activity object and logs it. |
executionStopped | () | Stops the mission if it's still ongoing via gameplay_missions_missionManager.stop(), fires onMissionFinished hook, re-evaluates hotlapping controls. |
onClear | () | No-op placeholder. |
executionStarted | () | Re-evaluates hotlapping controls, calls clear(). |
Vehicle Processing Parameters
| Parameter | Type | Effect |
|---|---|---|
keepPlayer | bool | true: activates original player vehicle. false: hides it via setActive(0). |
keepTraffic | bool | true: unfreezes stored traffic state. false: keeps traffic frozen. |
Vehicle Preparation
-- Automatically sets headlights based on time of day:
local tod = core_environment.getTimeOfDay()
if tod and tod.time >= 0.225 and tod.time <= 0.775 then
obj:queueLuaCommand("electrics.setLightsState(2)")
end
-- Range 0.225-0.775 = daytime (no lights needed... but logic is inverted?)
-- Actually sets lights ON during daytime - likely a night-check rangeProperties
| Property | Default | Description |
|---|---|---|
moduleOrder | -100 | Early priority (vehicle setup before other modules). |
processed | false | Guard flag to prevent double-processing vehicles. |
Mission Lifecycle
executionStarted()
│
├── processVehicles({ keepPlayer = false, keepTraffic = false })
│ └── Hides player vehicle, freezes traffic
│
├── prepareVehicle() → headlights based on ToD
│
│ ... mission runs ...
│
└── executionStopped()
├── gameplay_missions_missionManager.stop(mission)
├── extensions.hook("onMissionFinished")
└── guihooks.trigger('hotlappingReevaluateControlsEnabled')Usage from Nodes
-- Process vehicles at mission start:
local missionModule = self.mgr:getModule("mission")
missionModule:processVehicles({ keepPlayer = true, keepTraffic = false })
-- Get original player vehicle:
local origId = missionModule:getOriginalPlayerId()
-- Fire custom mission event:
missionModule:missionHook("checkpointReached", { index = 3 })See Also
- Flowgraph Action Module - Related reference
- Flowgraph AI Recording Module - Related reference
- Flowgraph Button Module - Related reference
- FlowGraph Guide - Guide
Flowgraph Level Module
Manages level-loading coordination for flowgraph projects. Handles deferred function execution during level loads, prefab registration, and collision reload scheduling.
Mission Replay Module
Flowgraph module that manages mission replay recording and playback. Handles automatic recording during mission attempts, replay file management (deletion by count or size), metadata generation, and c