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
cosimulationNames Referencetech/ - Co-simulation & Technical Interface ModulespcdLib ReferencetechCommunication ReferencetechUtils 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 Referencecommontech

techCommunication Reference

Module defined in `lua/common/tech/techCommunication.lua`. TCP socket communication layer for BeamNG's tech/co-simulation interface. Handles client connections, MessagePack-encoded message exchange, a

Module defined in lua/common/tech/techCommunication.lua. TCP socket communication layer for BeamNG's tech/co-simulation interface. Handles client connections, MessagePack-encoded message exchange, and request routing.


Exports

Functions

M.openServer(port, ip)

Open a TCP server on the given port and IP.

  • Parameters:
    • port - number - TCP port to listen on
    • ip - string|nil - Bind IP address (default: all interfaces)
  • Returns: table - Server object with socket handle

M.checkForClients(servers)

Accept pending client connections on server sockets.

  • Parameters:
    • servers - table - Array of server objects
  • Returns: table - Newly connected client sockets

M.receive(skt)

Receive a complete message from a socket (length-prefixed protocol).

  • Parameters:
    • skt - socket - Connected TCP socket
  • Returns: string, nil - Received data and error (nil on success)

M.checkMessages(E, clients)

Poll all client sockets for incoming messages, decode via MessagePack, and dispatch to request handlers.

  • Parameters:
    • E - table - Extension/environment with request handlers
    • clients - table - Array of connected client sockets
  • Returns: boolean - false if no messages processed

M.callRequestHandler(E, request)

Route a decoded request to the appropriate handler function on E.

  • Parameters:
    • E - table - Extension table with handler functions
    • request - table - Decoded request with type field
  • Returns: boolean - false if handler not found

M.sendMessage(skt, message)

Encode and send a MessagePack message with length prefix.

  • Parameters:
    • skt - socket - Target socket
    • message - table - Message to encode and send

M.sendLegacyError(skt, error)

Send a legacy-format error message.

  • Parameters:
    • skt - socket - Target socket
    • error - string - Error message

M.sanitizeTable(tab)

Recursively sanitize a table for MessagePack serialization (remove unsupported types).

  • Parameters:
    • tab - table - Input table
  • Returns: table - Sanitized copy

M.newSet()

Create a simple set data structure (from LuaSocket samples).

  • Returns: table - Set with insert/remove via metamethods

M.enableDebug()

Enable debug logging for communication.

M.disableDebug()

Disable debug logging.

Variables

M.protocolVersion

  • Type: string
  • Description: Current protocol version string ('v1.26')

Internal Notes

  • Wire protocol: 4-byte big-endian unsigned length prefix + MessagePack payload
  • Uses LuaSocket for TCP networking
  • Uses FFI for packUnsignedInt32Network / unpackUnsignedInt32Network
  • Request handlers are methods on the extension table E matching request type names
  • Supports recording mode integration via checkIfRecording

pcdLib Reference

Module defined in `lua/common/tech/pcdLib.lua`. Creates PCD (Point Cloud Data) files - the standard format for lidar, radar, and other point cloud sensor data.

techUtils Reference

Module defined in `lua/common/tech/techUtils.lua`. Utility functions for the tech/co-simulation layer - surface height queries and table-to-vector conversions.

On this page

ExportsFunctionsM.openServer(port, ip)M.checkForClients(servers)M.receive(skt)M.checkMessages(E, clients)M.callRequestHandler(E, request)M.sendMessage(skt, message)M.sendLegacyError(skt, error)M.sanitizeTable(tab)M.newSet()M.enableDebug()M.disableDebug()VariablesM.protocolVersionInternal Notes