RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Debug DrawingGPU Mesh StructsImGui FFIMath Structs (FFI)FFI C DefinitionsPID ControllersCSV LibraryDelay LineDequeDevelopment UtilitiesEvent ReferenceExtension SystemSignal FiltersGraph PathfindingUI BridgeInput Filter Constants2D Bilinear InterpolationIntrospectionJBeam Pretty PrinterJSON AST ParserSJSON ParserJSON Debug ParserJSON Pretty PrinterK-D Tree (2D Boxes)K-D Tree (3D)K-D Tree (3D)Lua SerializerC++/Lua BindingLua CoreLua ProfilerMath LibraryParticlesQuadtreeSettingsTCP ServerTimer SchedulerUtility Library

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)

See Also

  • cdefDebugDraw Reference - Related reference
  • cdefGpuMesh Reference - Related reference
  • cdefImgui Reference - Related reference
  • Common Libraries Overview - Guide

Development Utilities

Module defined in `lua/common/devUtils.lua`. Development utilities for sandboxed Lua execution, module local variable introspection, global state snapshots, and table recursion detection.

Extension System

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 NotesSee Also