util/worker - Batch Job Worker
Reference for `extensions/util/worker.lua`. Processes batch work items from a JSON file (`/work.json`) for automated tasks like mesh compilation, imposter generation, mod testing, and vehicle previews
Reference for extensions/util/worker.lua. Processes batch work items from a JSON file (/work.json) for automated tasks like mesh compilation, imposter generation, mod testing, and vehicle previews.
Exports
| Key | Signature | Description |
|---|---|---|
onExtensionLoaded | () | Loads work items from /work.json on startup |
onJobDone | (job, totalRunning) | Callback: shuts down when all jobs complete |
onPreRender | (dt) | Processes work items after 120 frame warmup |
Work Item Types
| Type | Fields | Description |
|---|---|---|
compileMesh | filename | Compiles a .dae file to .cdae |
testImage | filename | Tests an image file (stub) |
compileImposters | levels | Compiles imposters for specified levels |
testMod | tagid, resource_version_id, disableSpinScr | Tests a mod package |
renderVehiclePreview | vehicles | Renders vehicle preview images |
testVehiclesPerformances | pcFile, vehicle | Saves dynamic performance data |
calibrateESC | pcFile, vehicle | Calibrates ESC for a vehicle |
Internals
- Startup: Loads helper extensions (
test/renderVehiclePreview,util/saveDynamicData,util/calibrateESC,util/compileImposters). - 120-frame warmup: Waits 120 frames before processing to ensure the engine is fully initialized.
- Mesh compilation:
compileDae(daePath)callscompileCollada()to convert DAE → CDAE with optional validation. - Material loading:
loadMaterialsInPath(path)finds and loads both.csand.jsonmaterial files. - Auto-shutdown: After all work items are processed and all jobs complete, calls
shutdown(0). - Designed for headless/CLI usage:
-lua extensions.load('util_worker') -console -nouserpath.
How It Works
- Engine starts with
util_workerextension loaded. - On load, reads
/work.jsoncontaining an array of work items. - After 120 frames, iterates all items and dispatches to handler functions.
- Handlers may queue async jobs via
core_jobsystem. - Once all jobs complete, the process exits cleanly.
// Example /work.json
[
{"type": "compileMesh", "filename": "vehicles/etk800/etk800.dae"},
{"type": "compileImposters", "levels": ["west_coast_usa", "italy"]}
]Additional Exports
M.onExtensionLoaded- (undocumented)M.onJobDone- (undocumented)M.onPreRender- (undocumented)
util/vehicleRopeDebug - Rope Physics Debug UI
Reference for `extensions/util/vehicleRopeDebug.lua`. Provides an ImGui debug sandbox for visualizing and editing rope physics parameters on the current vehicle.
util/wsTest - WebSocket Test Server
Reference for `extensions/util/wsTest.lua`. Runs a local WebSocket server for testing GE Lua execution, reloads, and bandwidth measurements from a browser.