Skip to content

EMN-CSharp/RoROdometer

Repository files navigation

RoROdometer

Keep track of your vehicle's mileage in Rigs of Rods!

RoROdometer UI

What is this?

It's a set of scripts to record the distance traveled by your vehicles in Rigs of Rods.

Features

  • Main and trip odometer
  • Mileage shown in kilometres or miles depending on the "Imperial units" RoR setting
  • Works with any vehicle (cars, aircraft, boats, etc.)
  • Odometers are registered automatically as soon as a new vehicle is spawned.
  • Provides a simple API for other scripts to get access to the odometers.

Requirements

  • RoR 2025.03 RC1 or later

Installation

  • Download RoROdometer.zip from the Rigs of Rods repository and unzip the contents in your scripts folder (path to Rigs of Rods/scripts).
  • Open RoR and load any terrain
  • Go to the upper menu > Tools > Show console
  • Go to the prompt under "Press Ctrl+G to spawn a new vehicle" and type loadscript RoROdometerManager.as.
  • Go to the Script Monitor menu and make sure "Autoload" is ticked for RoROdometerManager.as.
  • Go back to the console and type loadscript RoROdoUI.as to start managing odometers for your vehicles. This is done once, then you can start RoROdoUI again from the Script Monitor.
  • You can also download the gadget for RoROdometer UI (RoROdometerUI.zip) and copy it to your mods folder. That way you can start RoROdoUI.as from the gadgets menu instead of using the console.

Scripting

Example script to query the odometer values for the current vehicle:

#include "RoROdometer.as"

void main()
{
  // Gets an instance of RoROdometer::OdometerHelper. This is the access point
  // to all the odometers managed by RoROdometer.
  RoROdometer::OdometerHelper@ odoHelper = RoROdometer::GetOdometerHelper();
  BeamClass@ currentTruck = game.getCurrentTruck();

  // ALWAYS check if odoHelper is not null! OdometerHelper might not be available when RoR
  // is closing or if RoROdometerManager.as wasn't loaded.
  if (@odoHelper != null && @currentTruck != null)
  {
    RoROdometer::Odometer@ odometer = odoHelper.TryGetOdometerByActor(currentTruck);
    // Also check if "odometer" is not null!
    if (@odometer != null)
    {
      log("Odometers for " + currentTruck.getTruckName() + ":");
      log("Main Odometer: " + odometer.GetMainOdometer() + " km");
      log("Trip Odometer: " + odometer.GetTripOdometer() + " km");
    }
  }
}

Note: If you want to include RoROdometer.as in your mod scripts, don't copy it to your mod folder since it is already installed in the scripts folder.

About

Keep track of your vehicle's mileage in Rigs of Rods!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors