RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

cdefDebugDraw ReferencecdefGpuMesh ReferencecdefImgui ReferencecdefMath Referencecdefs ReferencecontrolSystems Referencecsvlib ReferencedelayLine Referencedequeue ReferencedevUtils ReferenceEvent Referenceextensions Referencefilters Referencegraphpath Referenceguihooks ReferenceinputFilters ReferenceinterpolatedMap Referenceintrospection ReferencejbeamWriter Referencejson-ast Referencejson ReferencejsonDebug ReferencejsonPrettyEncoderCustom Referencekdtreebox2d Referencekdtreebox3d Referencekdtreepoint3d Referencelpack ReferenceluaBinding ReferenceluaCore ReferenceluaProfiler Referencemathlib Referenceparticles Referencequadtree Referencesettings ReferencetcpServer ReferencetimeEvents Referenceutils Reference

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API Referencecommon

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 fun is not a function

Event:remove(fun)

Unsubscribes a function from this event.

  • Parameters:
    • fun - function - The callback to unregister
  • Throws: Error if fun is 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 __call metamethod is set to Event.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

On this page

ExportsFunctionsEvent.new()Event:add(fun)Event:remove(fun)Event:clear()Event:call(...)Internal Notes