Online
Online services client. Manages authentication sessions, API calls to BeamNG servers, file downloads with progress tracking, and server-pushed instructions (messages, mod updates).
Online services client. Manages authentication sessions, API calls to BeamNG servers, file downloads with progress tracking, and server-pushed instructions (messages, mod updates).
Public Functions
| Function | Signature | Description |
|---|---|---|
M.openSession | () | Initiates authentication with the online service |
M.apiCall | (uri, callback, postData, outfile, reqType, progressCb, postFile, authHeader) | Makes a JSON API call to BeamNG servers |
M.download | (uri, callback, postData, outfile, reqType, progressCb) | Downloads a file (non-JSON) |
M.requestState | () | Sends online/Steam state to UI |
M.getRequestsUI | () | Sends active request states to UI |
M.clearRequest | (id) | Removes a completed request from tracking |
M.onSettingsChanged | () | Enables/disables online features based on settings |
M.onExtensionLoaded | () | Initializes based on current settings |
M.onOnlineStateChanged | (connected) | Sends connection state + provider info to UI |
M.onUIOnlineMessageReady | () | UI signals readiness to display messages |
M.onUIOnlineMessageHide | (uid) | Persistently hides a message by UID |
M.onInstructions | (data) | Processes server-pushed commands (messages, mod updates) |
M.callbackSecureCommCpp | (id, ...) | C++ callback for completed requests (do not remove) |
M.callbackSecureCommCppProgress | (id, ...) | C++ callback for download progress (do not remove) |
M.requestSubscriptions() | Requests online subscription data. | |
M.testWebsocket() | Tests the websocket connection. |
API Call Example
-- Simple API call with callback
core_online.apiCall("s1/v4/getMods", function(request)
if request.responseData then
local mods = request.responseData.data
for _, mod in pairs(mods) do
print(mod.title)
end
end
end, {query = "drift", page = 0})
-- Download a file
core_online.download("s1/v4/download/mods/ABC123", function(r)
print("Downloaded to: " .. r.outfile)
end, nil, "/mods/repo/mymod.zip")Request Object (Public)
| Field | Type | Description |
|---|---|---|
id | number | Unique request identifier |
state | string | "working" or "finished" |
responseCode | number | HTTP status code |
responseData | table | Parsed JSON response |
responseBuffer | string | Raw response text |
outfile | string | Output file path (for downloads) |
dlnow / dltotal | number | Download progress bytes |
ulnow / ultotal | number | Upload progress bytes |
dlspeed / ulspeed | number | Transfer speeds |
error | string | Error message if failed |
Server Instructions
The onInstructions handler processes commands from gameauth:
| Command Type | Action |
|---|---|
message | Displays a message in the UI |
modUpdateAvailable | Triggers mod update check |
repomsg | Sets repository message |
repocmd | Sets repository command |
automationmsg | Sets Automation integration message |
Module State
| Variable | Type | Default |
|---|---|---|
sessionReqested | boolean | true |
requestSubscriptions | varies | requestSubscriptions |
testWebsocket | varies | testWebsocket |
Notes
- Online features are gated by
settings.getValue('onlineFeatures') == 'enable'. - Uses
SecureComm.apiCallfor authenticated HTTPS communication. - Hidden message IDs are persisted in settings as
OnlineHiddenMessageIDs. - Full JSON encoder (
lunajson) is used for POST data (not the fast/lossy one). - Session opens only once per game launch.
See Also
- repository - Mod repository using online API
- modmanager - Mod management and updates
Multi Spawn
Spawns groups of vehicles in configurable formations (road, grid, line). Handles vehicle selection from installed data with population-weighted randomization, paint assignment, and formation placement
Paths (Camera Paths)
Camera path system for cinematic playback. Creates, loads, saves, and plays spline-based camera paths with markers defining position, rotation, FOV, and timing.