###################
#                 #
#    gmeter.nas   #
#                 #
#    2013 Helijah #
#    2014 Helijah #
# 08/2017 Helijah #
###################
var limit_min = -6;
var limit_max = 10;

var gmeter = func {

  var g    = props.globals.getNode("/accelerations/pilot-g").getValue();
  if ( !g ) {
    g = 0;
  }
  var gmin = props.globals.getNode("/accelerations/g-min").getValue();
  if ( !gmin ) {
    gmin = 0;
  }
  var gmax = props.globals.getNode("/accelerations/g-max").getValue();
  if ( !gmax ) {
    gmax = 0;
  }

  if ( g < gmin ) {
    if ( g > limit_min ) {
      gmin = g;
    } else {
      gmin = limit_min;
    }
  } elsif ( g > gmax ) {
    if ( g < limit_max ) {
      gmax = g;
    } else {
      gmax = limit_max;
    }
  }

  setprop("/accelerations/g-max", gmax);
  setprop("/accelerations/g-min", gmin);

  settimer(gmeter, 0);
}

gmeter();
