API ReferenceGE ExtensionsremoteControl
Remote Control HTTP
Provides a simple HTTP server that exposes REST-style endpoints for remote vehicle control. Registers a virtual input device and emits axis/button events over HTTP.
Provides a simple HTTP server that exposes REST-style endpoints for remote vehicle control. Registers a virtual input device and emits axis/button events over HTTP.
Public API
| Function | Signature | Description |
|---|---|---|
M.onExtensionLoaded | () | Starts HTTP server on 0.0.0.0:8081, registers HTTP route handlers |
M.onExtensionUnloaded | () | Unregisters the virtual input device |
M.onUpdate | (dtReal, dtSim, dtRaw) | Pumps HTTP server, emits a sine-wave axis event each frame |
M.onFirstUpdate | () | (exported but nil - no-op) |
HTTP Endpoints
| Route | Response | Description |
|---|---|---|
/hello/<number> | "hello world: <number>" | Demo endpoint with URL parameter |
/api/getInfo/ | {v, arch, ip, port} | Returns engine version, architecture, listen address |
/api/ping | ["pong"] | Health check |
/api/btn | {} | Toggles virtual button 0 on/off |
Internals
- HTTP server: Uses
utils/simpleHttpServermodule for lightweight request handling - Virtual input device: Registered via
getVirtualInputManager()as typehttpcontrollerv1/ instancebngremotectrlv1with 1 axis and 2 buttons - Axis demo: Continuously emits a sine-wave value
(sin(timer) + 1) / 2on axis 0
How It Works
onExtensionLoadedstarts the HTTP listener and defines route handlersonUpdatecallsws.update()to process incoming HTTP requests- On first update, registers a virtual input device with the engine's VIM
- Each frame emits a sine-wave axis value (demo behavior)
- The
/api/btnendpoint toggles a button state and emits button events onExtensionUnloadedcleans up the virtual device
Usage Examples
-- Load the remote control extension
extensions.load('remoteControl_remoteControl')
-- From a browser or curl:
-- GET http://localhost:8081/api/ping → ["pong"]
-- GET http://localhost:8081/api/getInfo/ → {v: "0.32", arch: "x64", ...}
-- GET http://localhost:8081/api/btn → toggles virtual buttonKey Notes
- Server binds to
0.0.0.0:8081- accessible from any network interface - The sine-wave axis emission is a demo; real usage would map HTTP inputs to vehicle controls
- Virtual device supports 1 axis (index 0) and 2 buttons (index 0)
- Uses
os.clockhp()for high-precision input timestamps
See Also
- Game Engine Overview - Guide
Sorted List
Reference for `gameplay_util_sortedList`, a generic container that manages a list of named, ID-bearing objects with sorted ordering, name-based lookup, and serialization support.
HDR Post-Processing
Initializes the HDR post-processing chain (bright pass, downscale, luminance, combine) on first update. Creates engine-level PostEffect objects if they don't already exist.