1. Trouble with the game?
    Try the troubleshooter!

    Dismiss Notice
  2. Issues with the game?
    Check the Known Issues list before reporting!

    Dismiss Notice

Where did the trip computer go?

Discussion in 'General Discussion' started by Quotex, Nov 19, 2015.

  1. Quotex

    Quotex
    Expand Collapse

    Joined:
    Mar 3, 2014
    Messages:
    223
    Kind of self-explainatory title, I'm working on a table for fuel consumptions, but i can't seem to find the trip computer anymore in the HUD apps.

    Was it outdated? If a new one is in the making, could it be possible to give it a Liter/hour or Gallon/hour when idling in neutral?

    My current primitive system of timing with a stop watch how long it takes for 0.01 L with to dissapear is kind of error-prone.
     
  2. Zappymouse

    Zappymouse
    Expand Collapse

    Joined:
    Jun 18, 2013
    Messages:
    1,059
    Looking for this?



    The app is called 'Engine Debug'.
     
  3. Quotex

    Quotex
    Expand Collapse

    Joined:
    Mar 3, 2014
    Messages:
    223
    Nah, there actually was a working trip computer that calculated the distance you'd driven, and the average fuel consumption over that distance etc.
    It used to be in there but it's gone now.

    I prefered that one because it's less "fluxating" as the one in the debug constantly changes every second and doesn't actually give an average.
     
  4. Quotex

    Quotex
    Expand Collapse

    Joined:
    Mar 3, 2014
    Messages:
    223
    Ok, so after some digging i found the code for the application, the problem seems to be that it uses an outdated version of coding that's no longer supported by the game. And that's why it doesn't show up in the game anymore.

    The app is called SimpleTrip and can still be found in the same folder as where the other apps are located.

    Code:
    function SimpleTrip() {}
    
    SimpleTrip.prototype.initialize = function () {
      this.dataDiv = $('<div></div>').appendTo(this.rootElement).addClass('dataDiv');
      this.unitDiv = $('<div></div>').appendTo(this.rootElement).addClass('unitDiv');
      this.labelDiv = $('<div></div>').appendTo(this.rootElement).addClass('labelDiv');
    
      this.loaded = false;
    
      var self = this;
      this.labelDiv.click(function(){self.toggleMode();});
    
      this.unitSystem = 'metric';
    
      /* Initialize mode.
      0 = distance
      1 = avg speed
      2 = avg mpg
      3 = current mpg
      4 = range
      */
    
      if (isNaN(this.persistance.mode)) this.persistance.mode = 0;
    
      this.timer  = 0;
      this.prevTime = 0;
      this.curTime  = 0;
    
      this.count  = 0;
      this.totalDistance = 0;
      this.avgSpeed  = 0;
      this.range  = 0;
    
      this.fuelConsumptionRate  = 0;
      this.avgFuelConsumptionRate  = 0;
      this.previousFuel  = 0;
    };
    
    SimpleTrip.prototype.toggleMode = function(){
      //Toggle between MPH and km/h, save the option to persistance system
      this.persistance.mode++;
      if(this.persistance.mode > 4) this.persistance.mode = 0;
      this.save();
    };
    
    SimpleTrip.prototype.update = function (streams) {
    
      var wheelspeed = streams.electrics.wheelspeed;
    
      this.prevTime = this.curTime;
      this.curTime  = performance.now();
      var dt = (this.curTime - this.prevTime)/1000;
    
      this.timer -= dt;
      if(this.timer < 0) {
      this.totalDistance += ((1 - this.timer) * wheelspeed);
    
      this.count++;
    
      this.avgSpeed += (wheelspeed - this.avgSpeed) / this.count;
    
      if (this.previousFuel > streams.engineInfo[11]) {
      this.fuelConsumptionRate = (1 - this.timer) * wheelspeed / (this.previousFuel - streams.engineInfo[11]); // In m/l
      } else {
      this.fuelConsumptionRate = 0;
      }
      this.previousFuel = streams.engineInfo[11];
    
      this.range = this.fuelConsumptionRate * streams.engineInfo[11] / 1000;
    
      this.avgFuelConsumptionRate += (this.fuelConsumptionRate - this.avgFuelConsumptionRate) / this.count;
    
      this.timer = 1;
      }
    
      var value;
      var unit;
      var display;
    
      switch (this.persistance.mode) {
      case 0:
      if (this.unitSystem == "metric") {
      value = (this.totalDistance/1000).toFixed(1);
      unit = "km";
      } else if (this.unitSystem == "imperial") {
      value = (this.totalDistance/1609).toFixed(1);
      unit = "mi";
      }
      display = "Total Distance";
      break;
      case 1:
      if (this.unitSystem == "metric") {
      value = (this.avgSpeed*3.6).toFixed(1);
      unit = "km/h";
      } else if (this.unitSystem == "imperial") {
      value = (this.avgSpeed*3.6/1.60934).toFixed(1);
      unit = "MPH";
      }
      display = "AVG Speed";
      break;
      case 2:
      if (this.unitSystem == "metric") {
      value = (100000/this.avgFuelConsumptionRate).toFixed(1);
      unit = "L/100km";
      } else if (this.unitSystem == "imperial") {
      value = (this.avgFuelConsumptionRate * 0.00235214583).toFixed(1);
      unit = "MPG (US)";
      }
      display = "AVG Fuel Consu.";
      break;
      case 3:
      if (this.unitSystem == "metric") {
      value = (100000/this.fuelConsumptionRate).toFixed(1);
      unit = "L/100km";
      } else if (this.unitSystem == "imperial") {
      value = (this.fuelConsumptionRate * 0.00235214583).toFixed(1);
      unit = "MPG (US)";
      }
      display = "Fuel Consumption";
      break;
      case 4:
      if (this.unitSystem == "metric") {
      value = (this.range).toFixed(1);
      unit = "km";
      } else if (this.unitSystem == "imperial") {
      value = (this.range / 1.609).toFixed(1);
      unit = "mi";
      }
      display = "Range";
      break;
      }
    
      this.dataDiv.html(value);
      this.unitDiv.html(unit);
      this.labelDiv.html(display);
    };
    
    SimpleTrip.prototype.onSettingsChanged = function(data) {
      this.unitSystem = data.values.uiUnits;
    };
    
    
    Hopefully someone knows how to make it so that it does work in the game, i kinda liked this app :/
    I have absolutely no idea how to do this though
     
  5. tdev

    tdev
    Expand Collapse
    Developer
    BeamNG Team

    Joined:
    Aug 3, 2012
    Messages:
    3,031
    I think we readded it properly, we'll see if we can get it working in the next update.
     
  6. Quotex

    Quotex
    Expand Collapse

    Joined:
    Mar 3, 2014
    Messages:
    223
    That's great, thanks for the info :)
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice