# ===============================
# Angles of flaps
# Angles of trims Helijah 02/2025
# ===============================

var loop = func {

  # Flaps
  var fl = getprop("/surface-positions/flap-pos-norm");
  if (fl != nil ) {
    if (getprop("/surface-positions/flappos") != nil ) {
      setprop("/surface-positions/flappos", fl * 33 );
    }
  }

  # Trims
  if ( getprop("/controls/flight/aileron-trim") != nil ) {
    var trimaile = getprop("/controls/flight/aileron-trim");
    if (getprop("/controls/flight/aileron-trim-val") != nil ) {
      if (getprop("/controls/flight/aileron-trim-sgn") != nil ) {
        setprop("/controls/flight/aileron-trim-sgn", 1 );
        if (trimaile < 0 ) {
          trimaile = trimaile * -1;
          setprop("/controls/flight/aileron-trim-sgn", 0 );
        }
        setprop("/controls/flight/aileron-trim-val", trimaile );
      }
    }
  }

  if ( getprop("/controls/flight/elevator-trim") != nil ) {
    var trimelev = getprop("/controls/flight/elevator-trim");
    if (getprop("/controls/flight/elevator-trim-val") != nil ) {
      if (getprop("/controls/flight/elevator-trim-sgn") != nil ) {
        setprop("/controls/flight/elevator-trim-sgn", 1 );
        if (trimelev < 0 ) {
          trimelev = trimelev * -1;
          setprop("/controls/flight/elevator-trim-sgn", 0 );
        }
        setprop("/controls/flight/elevator-trim-val", trimelev );
      }
    }
  }

  if ( getprop("/controls/flight/rudder-trim") != nil ) {
    var trimrudd = getprop("/controls/flight/rudder-trim");
    if (getprop("/controls/flight/rudder-trim-val") != nil ) {
      if (getprop("/controls/flight/rudder-trim-sgn") != nil ) {
        setprop("/controls/flight/rudder-trim-sgn", 1 );
        if (trimrudd < 0 ) {
          trimrudd = trimrudd * -1;
          setprop("/controls/flight/rudder-trim-sgn", 0 );
        }
        setprop("/controls/flight/rudder-trim-val", trimrudd );
      }
    }
  }

  settimer(loop, 0.5);
}

loop();
