# ===========================
# = Mass by Helijah 01/2026 =
# ===========================

var update_mass = func {

  var show1 = getprop("sim/multiplay/generic/bool[7]");     # tanks
  var show2 = getprop("sim/multiplay/generic/bool[17]");    # AL/AN-99 left/right int
  var show3 = getprop("sim/multiplay/generic/bool[19]");    # AL/AN-99 center
  var show4 = getprop("sim/multiplay/generic/bool[18]");    # AL/AN-99 left  ext
  var show5 = getprop("sim/multiplay/generic/bool[20]");    # AL/AN-99 right ext
  var show6 = getprop("sim/multiplay/generic/bool[21]");    # AGM-88 HARM left  ext
  var show7 = getprop("sim/multiplay/generic/bool[22]");    # AGM-88 HARM right ext

  # Left int
  setprop("/sim/weight[0]/weight-lb",getprop("/sim/weight[0]/opt[0]/lbs"));
  setprop("/sim/weight[0]/selected",getprop("/sim/weight[0]/opt[0]/name"));
  setprop("/consumables/fuel/tank[2]/level-lbs",getprop("/sim/weight[0]/opt[0]/lbs"));

  # Right int
  setprop("/sim/weight[1]/weight-lb",getprop("/sim/weight[1]/opt[0]/lbs"));
  setprop("/sim/weight[1]/selected",getprop("/sim/weight[1]/opt[0]/name"));
  setprop("/consumables/fuel/tank[3]/level-lbs",getprop("/sim/weight[1]/opt[0]/lbs"));

  # Center
  setprop("/sim/weight[2]/weight-lb",getprop("/sim/weight[2]/opt[0]/lbs"));
  setprop("/sim/weight[2]/selected",getprop("/sim/weight[2]/opt[0]/name"));

  # Left ext
  setprop("/sim/weight[3]/weight-lb",getprop("/sim/weight[3]/opt[0]/lbs"));
  setprop("/sim/weight[3]/selected",getprop("/sim/weight[3]/opt[0]/name"));

  # Right ext
  setprop("/sim/weight[4]/weight-lb",getprop("/sim/weight[4]/opt[0]/lbs"));
  setprop("/sim/weight[4]/selected",getprop("/sim/weight[4]/opt[0]/name"));

  if ( show1 != 0 ) {
    # Left int
    setprop("/sim/weight[0]/weight-lb",getprop("/sim/weight[0]/opt[1]/lbs"));
    setprop("/sim/weight[0]/selected",getprop("/sim/weight[0]/opt[1]/name"));
    setprop("/consumables/fuel/tank[2]/level-lbs",getprop("/sim/weight[0]/opt[1]/lbs"));
    # Right int
    setprop("/sim/weight[1]/weight-lb",getprop("/sim/weight[1]/opt[1]/lbs"));
    setprop("/sim/weight[1]/selected",getprop("/sim/weight[1]/opt[1]/name"));
    setprop("/consumables/fuel/tank[3]/level-lbs",getprop("/sim/weight[1]/opt[1]/lbs"));
  }
  if ( show2 != 0 ) {
    # Left int
    setprop("/sim/weight[0]/weight-lb",getprop("/sim/weight[0]/opt[2]/lbs"));
    setprop("/sim/weight[0]/selected",getprop("/sim/weight[0]/opt[2]/name"));
    setprop("/consumables/fuel/tank[2]/level-lbs",getprop("/sim/weight[0]/opt[0]/lbs"));
    # Right int
    setprop("/sim/weight[1]/weight-lb",getprop("/sim/weight[1]/opt[2]/lbs"));
    setprop("/sim/weight[1]/selected",getprop("/sim/weight[1]/opt[2]/name"));
    setprop("/consumables/fuel/tank[3]/level-lbs",getprop("/sim/weight[1]/opt[0]/lbs"));
  }
  if ( show3 != 0 ) {
    # Center
    setprop("/sim/weight[2]/weight-lb",getprop("/sim/weight[2]/opt[1]/lbs"));
    setprop("/sim/weight[2]/selected",getprop("/sim/weight[2]/opt[1]/name"));
  }
  if ( show4 != 0 ) {
    # Left ext
    setprop("/sim/weight[3]/weight-lb",getprop("/sim/weight[3]/opt[1]/lbs"));
    setprop("/sim/weight[3]/selected",getprop("/sim/weight[3]/opt[1]/name"));
  }
  if ( show5 != 0 ) {
    # right ext
    setprop("/sim/weight[4]/weight-lb",getprop("/sim/weight[4]/opt[1]/lbs"));
    setprop("/sim/weight[4]/selected",getprop("/sim/weight[4]/opt[1]/name"));
  }
  if ( show6 != 0 ) {
    # Left ext
    setprop("/sim/weight[3]/weight-lb",getprop("/sim/weight[3]/opt[2]/lbs"));
    setprop("/sim/weight[3]/selected",getprop("/sim/weight[3]/opt[2]/name"));
  }
  if ( show7 != 0 ) {
    # right ext
    setprop("/sim/weight[4]/weight-lb",getprop("/sim/weight[4]/opt[2]/lbs"));
    setprop("/sim/weight[4]/selected",getprop("/sim/weight[4]/opt[2]/name"));
  }

  settimer(update_mass, 0.1);
}

update_mass();
