Questions about g-forces and UI apps.

Discussion in 'Programming' started by NaxNir, Mar 21, 2015.

  1. NaxNir

    NaxNir
    Expand Collapse

    Joined:
    Jan 28, 2014
    Messages:
    618
    Is it possible to have a variable that is the g-forces acting on the car. Is this right?
    Code:
    MyAppsName.prototype.update = function(streams){
        //convert to G
        var gForces = {};
        $.each(streams.sensors, function(index, val) {
            gForces[index] = val / 9.81;
        });
    and would the variable be: gForces


    The second question is how is it possible if that variable is greater than, say, 1 it will print out "Crashed"? Is this right?
    Code:
    if ('gForces' > 1) {
        $("<h1>Crashed</h1>").appendTo(this.rootElement);
    }
    and have it stay like that until the car is reset. I have a thing earlier in the app that will say "Alive" can I make it loop back to the begging once the car is reset.

    Copied from Some-questions-about-app-development Please delete that other thread, as this is the correct section.
     
  2. Funky7Monkey

    Funky7Monkey
    Expand Collapse

    Joined:
    Oct 12, 2014
    Messages:
    977
    Among the built-in apps is a g-meter. The variable you need is used in that. Just open it up and find it. I'd find it for you, but I'm a bit busy ATM and don't have BeamNG installed on this machine.
     
  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