Freeroam Facilities Fuel Price
Manages fuel price display on gas station 7-segment signs. Reads price configuration from facility data, applies randomness, and renders prices via TSStatic shape swapping.
Manages fuel price display on gas station 7-segment signs. Reads price configuration from facility data, applies randomness, and renders prices via TSStatic shape swapping.
Public API
| Function | Signature | Returns | Description |
|---|---|---|---|
M.setDisplayPrices | () | boolean | Reads facility data and updates all gas station price displays |
M.getFuelPrice | (stationId, fuelType) | number|nil | Returns cached metric fuel price for a station/fuel type |
M.restoreSign | (hide?) | nil | Restores original display objects (debug helper) |
Hooks
| Hook | Purpose |
|---|---|
M.onClientStartMission | Initializes price displays on level load |
M.onSerialize | Saves cached price data |
M.onDeserialized | Restores cached prices or recalculates |
How It Works
- On level start, reads all gas station facility data from
freeroam_facilities - For each fuel type at each station, calculates price:
baseline + randomnessGain * (random - bias) - Converts to US gallons if level uses
gallonUSunits - Formats price as 4-digit string and updates TSStatic display objects by swapping DAE shapes
- Original display objects are hidden; cloned objects with correct shapes are created in a
SimGroup - Disabled fuel types show dashes (
-)
Display Object System
Each gas station defines displayObjects per fuel type - an array of arrays mapping digit positions to scene object names:
{
"prices": {
"gasoline": {
"priceBaseline": 1.459,
"priceRandomnessGain": 0.1,
"priceRandomnessBias": 0.5,
"us_9_10_tax": true,
"displayObjects": [
["sign_digit1_a", "sign_digit1_b"],
["sign_digit2_a"],
["sign_digit3_a"],
["sign_digit4_a"]
]
}
}
}Usage Examples
-- Get fuel price at a station (metric units)
local price = freeroam_facilities_fuelPrice.getFuelPrice("gas_station_01", "gasoline")
-- Force refresh displays
freeroam_facilities_fuelPrice.setDisplayPrices()
-- Debug: restore original sign shapes
freeroam_facilities_fuelPrice.restoreSign()Notes
- US stations force digit 4 to
9whenus_9_10_taxis set (9/10 cent convention) - Cloned display objects are stored in
fuelPrice_localCopiesSimGroup (non-saveable) - Extension auto-unloads if no price data is found
- Serialization preserves prices across Lua reloads on the same level
Additional Exports
M.onExtensionLoaded- (undocumented)M.onExtensionUnloaded- (undocumented)
See Also
- Freeroam Guide - Guide
Freeroam Configurator Options
Provides default freeroam configuration options for traffic and time-of-day settings. Responds to the freeroam configurator's option gathering and application hooks.
Gameplay Achievement
Tracks the "Kilometer Kickoff" Steam/platform achievement - unlocked when total vehicle odometer exceeds 1,000 km (1,000,000 meters).