You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Connecting Vehicle Scripts, the Game Script and HTML UI
Batuhan Fatih Dilli edited this page Nov 2, 2026
·
30 revisions
This page explains how the three script layers of Transport Minigame talk to each other, using the fuel system as a worked example. Read it if you want to:
understand how Outerra engine connects script layers,
make your own vehicle work with the fuel system,
add a new HTML window that reads or changes game state,
understand where a value shown in the UI actually comes from.
1. Layer 1: Vehicle script → Game script
1.1 Exposing a function from a vehicle
Vehicle scripts have two init hooks. Pick the right one:
Hook | Runs | Use it for
init_chassis(param) | Once per model (shared by every copy of the vehicle) | Wheels, sounds, lights, input axes
init_vehicle() | Once per instance (each spawned vehicle) | Per-vehicle state and functions you want to expose
Fuel is per vehicle (two jeeps have two tanks), so it lives in init_vehicle():
function init_vehicle() {
// ...
this.remaining_fuel = 57.0; // litres, should match fuel_capacity in the DB
this.last_fuel_pos = null;
this.get_remaining_fuel = function () {
return this.remaining_fuel;
};
this.set_remaining_fuel = function (amount) {
this.remaining_fuel = amount;
};
}