######################################################################
#                                                                    #
# If the plane is on the ground, fold the wings                      #
#                                                                    #
# Helijah 03/2025                                                    #
######################################################################

setlistener("/sim/presets/latitude-deg", func {
  #print("*** ON WATER ? ***");
  settimer(func {
    #var typ = getprop("/sim/model/mode");
    var typ = getprop("/sim/multiplay/generic/string[0]");
    var lat = getprop("/position/latitude-deg");
    var lon = getprop("/position/longitude-deg");
    var g = geodinfo(lat, lon);
    if (g != nil and g[1] != nil and g[1].solid) {
      #print("*** NO ***");
      if (typ == "SEAPLANE" ) {
        setprop("/sim/model/door-positions/wings/position-norm",1);
        setprop("/sim/multiplay/generic/float[13]",1);
      }
    }
  }, 8);
}, 1);
