API ReferenceGE Extensionsutil
Precompile Vehicles
M.dependencies = {'freeroam_freeroam', 'core_vehicles'}
Dependencies
M.dependencies = {'freeroam_freeroam', 'core_vehicles'}Iterates through a predefined list of vehicles, spawning each on smallgrid with synchronous shader compilation to warm caches.
Overview
util_precompileVehicles is a build-time utility that spawns every vehicle in a hardcoded list (100+ models) one at a time on the smallgrid level, waits 200 frames for shaders to compile, then moves to the next. Quits when done.
Extension path: lua/ge/extensions/util/precompileVehicles.lua
Dependencies: freeroam_freeroam, core_vehicles
Exports (M)
| Function | Signature | Description |
|---|---|---|
onInit | () | Disables async shaders, filters vehicle list, starts freeroam on smallgrid. |
onVehicleSpawned | (vehicleId) | Marks current vehicle as loaded, starts 200-frame wait. |
onClientStartMission | () | Begins spawning the first vehicle once the level is ready. |
onPreRender | (dt) | Counts down frames, advances to the next vehicle or quits. |
Internals
Vehicle List
A hardcoded table vehiclesToLoad maps ~110 model names (e.g. pickup, etk800, vivace, us_semi) to true. Only models also present in core_vehicles.getModelList() are processed.
Flow
onInit- disables async shaders, builds filtered vehicle list, startssmallgridvia freeroam.onClientStartMission- triggers the firstloadNextVehicle()call.loadNextVehicle- callscore_vehicles.replaceVehicle(model, {}).onVehicleSpawned- setsloaded = true,frames = 200.onPreRender- decrementsframes; when 0, advances to the next vehicle or callsquit().
State Variables
vehicles- filtered array of vehicle model namesvehicleToLoad- current 1-based indexloaded/frames- control the per-vehicle waitfinished- stopsonPreRenderprocessing
How It Works
- Extension loads, starts
smallgridfreeroam. - For each vehicle: spawn → wait 200 frames → next.
- After all vehicles, logs completion and exits.
Lua Examples
-- Typically invoked via CLI, not at runtime:
-- beamng.exe -onLevelLoad_ext "util/precompileVehicles"
extensions.load("util/precompileVehicles")Additional Exports
M.onClientStartMission- (undocumented)M.onInit- (undocumented)M.onPreRender- (undocumented)M.onVehicleSpawned- (undocumented)