Event Reference
Module defined in `lua/common/event.lua`. Implements a simple event/delegate class for publish-subscribe patterns. Subscribers register functions that get called when the event fires.
Module defined in lua/common/event.lua. Implements a simple event/delegate class for publish-subscribe patterns. Subscribers register functions that get called when the event fires.
Exports
Exports a global class Event (not a module table).
Functions
Event.new()
Creates a new Event instance.
- Returns: Event - A new event object with an empty subscriber list
Event:add(fun)
Subscribes a function to this event.
- Parameters:
fun- function - The callback to register
- Throws: Error if
funis not a function
Event:remove(fun)
Unsubscribes a function from this event.
- Parameters:
fun- function - The callback to unregister
- Throws: Error if
funis not a function
Event:clear()
Removes all subscribers from this event.
Event:call(...)
Fires the event, calling all subscribed functions with the provided arguments.
- Parameters:
...- any - Arguments forwarded to all subscribers
Internal Notes
- Uses function references as keys in a set (table with boolean values) for O(1) add/remove
- The
__callmetamethod is set toEvent.call, so events can be invoked directly:myEvent(...) - Subscriber execution order is non-deterministic (iterates via
pairs)
devUtils Reference
Module defined in `lua/common/devUtils.lua`. Development utilities for sandboxed Lua execution, module local variable introspection, global state snapshots, and table recursion detection.
extensions Reference
Module defined in `lua/common/extensions.lua`. The core extension/module management system for BeamNG. Handles loading, unloading, dependency resolution, hook dispatch, serialization, and virtual exte