API ReferenceGE Extensionsflowgraphnodesvehiclespecial
Custom Vehicle Lua
- **Node Name:** `Custom Vehicle Lua`
Overview
- Node Name:
Custom Vehicle Lua - Category:
repeat_p_duration - File:
extensions/flowgraph/nodes/vehicle/special/customVlua.lua
Calls a custom vehicle Lua function on each tick. Sends arbitrary Lua code to a vehicle's Lua environment via queueLuaCommand.
Pin Schema
Input Pins
| Pin | Type | Description |
|---|---|---|
vehId | number | ID of vehicle to send the Lua command to. If empty, uses player vehicle |
func | string | The Lua function/code string to execute in vehicle Lua |
Output Pins
| Pin | Type | Description |
|---|---|---|
flow | flow | Outflow for this node |
vehId | number (hidden) | The vehicle ID this command was sent to |
Legacy Pin Mapping
in.vehicleId→vehIdout.vehicleId→vehId
Internals
Key Methods
| Method | Description |
|---|---|
work() | Resolves vehicle and sends the Lua command via queueLuaCommand |
drawMiddle() | Empty middle display |
_onDeserialized(data) | Migrates legacy data.func to hardcoded pin value |
Deserialization Migration
If the node was serialized with data.func (legacy format), it migrates the value to a hardcoded pin:
data.hardcodedPins = {
func = { value = data.data.func, type = 'string' }
}How It Works
- On each tick, resolves the vehicle by
vehIdor falls back togetPlayerVehicle(0). - If both vehicle and
funcare valid, callsveh:queueLuaCommand(func). - The Lua string is executed in the vehicle's Lua environment on the next frame.
- Outputs the vehicle ID on
vehId.
Usage Example
-- In a flowgraph - activate hazard lights on a vehicle:
-- [Vehicle ID] → [Custom Vehicle Lua].vehId
-- [String: "electrics.setLightsState({hazard_enabled = 1})"] → [Custom Vehicle Lua].func
-- In a flowgraph - lock the parking brake:
-- [String: "input.event('parkingbrake', 1, 1)"] → [Custom Vehicle Lua].func
-- Direct Lua equivalent:
local veh = getPlayerVehicle(0)
veh:queueLuaCommand("electrics.setLightsState({hazard_enabled = 1})")Key Dependencies
veh:queueLuaCommand(luaString)- sends arbitrary Lua to the vehicle environmentscenetree.findObjectById()- resolves vehicle by IDgetPlayerVehicle(0)- gets the current player vehicle
See Also
- Get Custom Vehicle Value (Flowgraph Node) - Related reference
- Custom vlua - Deprecated (Flowgraph Node) - Related reference
- Vehicle Action (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide