Guihooks Module Reference
Communication bridge between vehicle Lua and game UI (JavaScript). This module handles event triggers, high-frequency data streams, and UI notifications.
Communication bridge between vehicle Lua and game UI (JavaScript). This module handles event triggers, high-frequency data streams, and UI notifications.
See Also
- Communication: Inter-VM logic overview.
- Streams: High-frequency UI data categories.
Common UI Events
AIStateChange: Refresh AI app state.VehicleSkeleton: Send physical node/beam layout.HydrosUpdate: Update UI with hydraulic states.appMessage: Send a generic message to UI apps.VehicleChange: Notification when the vehicle object changes.VehicleReset: Notification when the vehicle is reset.
State Fields
| Variable | Description |
|---|---|
updateStreams | Boolean flag that controls whether queueStream actually caches data. Automatically managed by the engine based on whether UI apps are listening. |
Public API - UI Data Streams
| Function | Signature | Description |
|---|---|---|
guihooks.queueStream | (key, value) / send(key, value) | Queues data for the next UI sync step. Data is only cached if updateStreams is true. |
guihooks.triggerStream | (streamName, data) | Immediately transmits stream data to the UI, bypassing the sync cache. |
guihooks.sendStreams | () | Transmits all cached stream data to the UI. Automatically called by the engine during onGraphicsStep. |
Usage Example
guihooks.queueStream("custom_telemetry", {speed = 100})Public API - Event Triggering
| Function | Signature | Description |
|---|---|---|
guihooks.trigger | (hookName, ...) | Triggers a generic UI event hook. |
guihooks.triggerClient | (id, hookName, ...) | Sends an event to a specific UI instance. |
guihooks.triggerRawJS | (hookName, rawJs) | Sends a raw JS string to the UI context. |
Usage Example
guihooks.trigger("MyCustomEvent", "Hello UI", 42)Public API - UI Notifications
| Function | Signature | Description |
|---|---|---|
guihooks.message | (msg, ttl, category, icon) | Displays a notification toast in the UI. |
Usage Example
guihooks.message("Engine Overheating!", 5, "engine", "warning")Public API - Graphing Utilities
| Function | Signature | Description |
|---|---|---|
guihooks.graph | (a, ...) | Sends data to the "Simple Graph" UI app. |
guihooks.graphWithCSV | (filename, ...) | Similar to graph, but also logs the data points to an internal CSV buffer. |
guihooks.graphWithCSVWrite | () | Writes the current CSV buffer to a file on disk. |
Public API - Lifecycle
| Function | Signature | Description |
|---|---|---|
guihooks.reset | () | Clears the stream cache and resets the updateStreams flag. |
Vehicle Engine True Globals
Global variables and functions available in the BeamNG vehicle Lua VM (VE context). These globals provide access to vehicle physics, data, UI communication, and inter-VM bridging to the Game Engine (G
GUI Streams Module Reference
Module defined in `lua/vehicle/guistreams.lua`. Manages the registration and dispatch of high-frequency data streams from the vehicle to UI apps. UI apps subscribe to specific stream categories, and this module ensures only requested data is computed and transmitted each frame.