TechCore Module Reference
Extension defined in `lua/vehicle/extensions/tech/techCore.lua`. This is the **vehicle-side socket server** for BeamNG.tech's external research API. It opens a TCP connection that allows external tool
Extension defined in lua/vehicle/extensions/tech/techCore.lua. This is the vehicle-side socket server for BeamNG.tech's external research API. It opens a TCP connection that allows external tools (Python BeamNGpy, MATLAB, etc.) to control the vehicle and poll sensor data via a request/response protocol.
See Also
- TechVehicleUtils: Helper functions for sensor data collection.
- AdvancedIMU: IMU sensor polled through this API.
- GPS: GPS sensor polled through this API.
Exports
Connection Management
requestVehicleInfo()
- Description: Sends the vehicle's connection port and object ID back to the game engine via
onVehicleInfoReadyhook.
startConnection(ip, skipServer)
- Arguments:
ip(string): IP address to bind the server socket.skipServer(boolean): If true, skips server creation (for reconnection scenarios).
- Description: Opens a TCP server socket for external tool connections and begins the client polling loop.
onSerialize() / onDeserialized(data)
- Description: Saves and restores the connection IP across vehicle reloads.
onDebugDraw()
- Description: Polls for incoming client connections and processes queued requests from connected clients. This is the main network tick, called every graphics frame.
Protocol Handlers
All handlers receive a request table with protocol-specific fields and respond via request:sendResponse() or request:sendACK().
handleHello(request)
- Description: Responds with the protocol version for handshake validation.
handleControl(request)
- Description: Applies throttle, steering, brake, parkingbrake, clutch inputs and optional gear shift. Supports ADAS input routing.
handleSetShiftMode(request)
- Description: Sets the gearbox shift mode (manual/autoclutch/arcade/automatic).
handleCycleESCMode(request) / handleSetESCMode(request) / handleGetESCMode(request)
- Description: Cycles through, sets, or queries the current ESC/drive mode.
handleSensorRequest(request)
- Description: Batch-polls registered sensor handlers (IMU, GPS, electrics, etc.) and returns collected data.
handleSetColor(request)
- Description: Changes the vehicle's paint color via RGBA values.
handleSetVelocity(request)
- Description: Applies an instantaneous velocity in the vehicle's forward direction using thrusters.
handleSetAiMode(request) / handleSetAiLine(request) / handleSetAiScript(request) / handleSetAiSpeed(request) / handleSetAiTarget(request) / handleSetAiWaypoint(request) / handleDriveUsingPath(request) / handleSetAiSpan(request) / handleSetAiAggression(request)
- Description: AI control handlers - set mode, define waypoint paths or scripted trajectories, configure speed/aggression. Maps to the AI module API.
handleExecuteScript(request)
- Description: Executes arbitrary Lua code in the vehicle environment. Security-sensitive.
handleGetInitialSpawnPositionOrientation(request)
- Description: Returns the vehicle's original spawn position and rotation quaternion.
handleStartRecording(request) / handleStopRecording(request)
- Description: Controls recording of vehicle state data to file via the recorders subsystem.
handleSetDriveInLane(request)
- Description: Toggles AI lane-keeping behavior.
handleSetLights(request)
- Description: Controls all vehicle lighting states: headlights, signals, fog, lightbar, hazards. Accepts individual light keys.
handleQueueLuaCommandVE(request)
- Description: Queues a Lua command string for execution in the vehicle Lua environment. Returns the serialized result.
handleAddIMUPosition(request) / handleAddIMUNode(request) / handleRemoveIMU(request)
- Description: Manages IMU sensor instances - add at world position, add at JBeam node, or remove by name.
handleApplyVSLSettingsFromJSON(request) / handleWriteVSLSettingsToJSON(request) / handleStartVSLLogging(request) / handleStopVSLLogging(request)
- Description: Vehicle Systems Logger (VSL) control - apply settings, save settings, start/stop data logging.
handlePollAdvancedImuVE(request) / handlePollGPSVE(request) / handlePollPowertrainVE(request) / handlePollMeshVE(request) / handlePollIdealRADARVE(request) / handlePollRoadsSensorVE(request)
- Description: Direct sensor polling handlers. Each collects data from the corresponding sensor extension and returns it.
handleRecover(request)
- Description: Triggers vehicle recovery (respawn at last safe position).
handleGetCenterOfGravity(request)
- Description: Returns the vehicle's current center of gravity position.
handleDeflateTire(request)
- Description: Deflates a specific tire by wheel index.
handleBreakHinges(request) / handleBreakAllBreakgroups(request)
- Description: Triggers structural breakage for hinges or all breakgroups.
handleSetPartCondition(request) / handleGetPartCondition(request)
- Description: Gets or sets individual part condition data (integrity, visual damage) via beamstate.
handleTriggerCommand(request)
- Description: Invokes a named vehicle action (e.g., horn, lights toggle) by command string.
handleGetNodePositions(request) / handleGetNodeForces(request)
- Description: Returns physics node positions or force vectors for mesh/structural analysis.
Roads Sensor
Provides information about nearby road segments including lane positions, road edges, speed limits, and surface types. Used for autonomous driving research.
Trail Sim
Automated vehicle maneuver simulation for trailer stability testing. Drives the vehicle at a set speed with configurable steering inputs to test trailer sway characteristics.