###########################################################################
##            Fuel system : BARANGER Emmanuel 05/2024                    ##
###########################################################################

var FuelSystem = func {

  if (getprop("/sim/model/show-tanks") != nil) {
    var ts = getprop("/sim/model/show-tanks");

    if ( ts == 1 ) {
      setprop("/consumables/fuel/tank[1]/selected", 1);
      setprop("/consumables/fuel/tank[1]/level-lbs", 524.7);
      setprop("/consumables/fuel/tank[2]/selected", 1);
      setprop("/consumables/fuel/tank[2]/level-lbs", 524.7);
    } else {
      setprop("/consumables/fuel/tank[1]/selected", 0);
      setprop("/consumables/fuel/tank[1]/level-lbs", 0);
      setprop("/consumables/fuel/tank[2]/selected", 0);
      setprop("/consumables/fuel/tank[2]/level-lbs", 0);
    }

    settimer(FuelSystem, 0.5);
  }
}

setlistener("/sim/signals/fdm-initialized", func{
  print("Fuel System ... OK");
  settimer(FuelSystem, 0);
});
