Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase detection of compatibility with aircraft #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 55 additions & 47 deletions addon-main.nas
Original file line number Diff line number Diff line change
Expand Up @@ -177,62 +177,70 @@ var initListenForUserRanksChange = func(addon) {
}
};

var main = func (addon) {
# Must be _setlistener because removelistener doesn't work well with setlistener
var fdmInitListener = _setlistener("/sim/signals/fdm-initialized", func {
if (getprop("/sim/signals/fdm-initialized")) {
# checking compatibility, set agl trigger by current agl.
if (checkCompatibility()) {

# If defined, load ICAO wake turbulence guess values
var icao_wake_t_cat = getprop("/aircraft/icao/wake-turbulence-category");
if (icao_wake_t_cat != nil and icao_wake_t_cat != "") {
var icao_wake_t_cat_cfg = LANDING_RANK_CFG.getNode("icao-wake-turbulence-category/"~icao_wake_t_cat);
if (icao_wake_t_cat_cfg != nil) {
evaluateLandingRateAddonCfg(icao_wake_t_cat_cfg, addon);
setprop(addon.node.getPath()~"/ranks/loaded-from", "icao-wakecategory");
}
}
var init = func (addon, fdmInitListener) {
# checking compatibility, set agl trigger by current agl.
if (checkCompatibility()) {

# If defined, load ICAO wake turbulence guess values
var icao_wake_t_cat = getprop("/aircraft/icao/wake-turbulence-category");
if (icao_wake_t_cat != nil and icao_wake_t_cat != "") {
var icao_wake_t_cat_cfg = LANDING_RANK_CFG.getNode("icao-wake-turbulence-category/"~icao_wake_t_cat);
if (icao_wake_t_cat_cfg != nil) {
evaluateLandingRateAddonCfg(icao_wake_t_cat_cfg, addon);
setprop(addon.node.getPath()~"/ranks/loaded-from", "icao-wakecategory");
}
}

# If defined, load aircraft type values
var aircraft = getprop("/sim/aircraft");
if (aircraft != nil and aircraft != "") {
var aircraft_type_cfg = LANDING_RANK_CFG.getNode("aircraft-types/"~aircraft);
if (aircraft_type_cfg != nil) {
evaluateLandingRateAddonCfg(aircraft_type_cfg, addon);
setprop(addon.node.getPath()~"/ranks/loaded-from", "aircraft-type");
}
}
# If defined, load aircraft type values
var aircraft = getprop("/sim/aircraft");
if (aircraft != nil and aircraft != "") {
var aircraft_type_cfg = LANDING_RANK_CFG.getNode("aircraft-types/"~aircraft);
if (aircraft_type_cfg != nil) {
evaluateLandingRateAddonCfg(aircraft_type_cfg, addon);
setprop(addon.node.getPath()~"/ranks/loaded-from", "aircraft-type");
}
}

# load addon-hints from aircraft
var addon_hints = props.globals.getNode("/sim/addon-hints/landing_rate/");
if (addon_hints != nil) {
evaluateLandingRateAddonCfg(addon_hints, addon);
setprop(addon.node.getPath()~"/ranks/loaded-from", "aircraft-addon-hints");
}
# load addon-hints from aircraft
var addon_hints = props.globals.getNode("/sim/addon-hints/landing_rate/");
if (addon_hints != nil) {
evaluateLandingRateAddonCfg(addon_hints, addon);
setprop(addon.node.getPath()~"/ranks/loaded-from", "aircraft-addon-hints");
}

aglFt = getprop("/position/altitude-agl-ft") + 6;
aglFt = getprop("/position/altitude-agl-ft") + 6;

initLandingRateTimer(addon); # init addon
removelistener(fdmInitListener);
initLandingRateTimer(addon); # init addon
removelistener(fdmInitListener);

initListenForUserRanksChange(addon);
initListenForUserRanksChange(addon);

printPersistentScreenMsg("Landing Rate Addon Loaded", COLOR_WHITE, 20); # success
print("Landing Rate addon loaded."); # success
printPersistentScreenMsg("Landing Rate Addon Loaded", COLOR_WHITE, 20); # success
print("Landing Rate addon loaded."); # success

if (getprop(addon.node.getPath() ~ "/addon-devel/sharemp")) {
printPersistentScreenMsg("Settings: Share landing in multiplayer is enabled", COLOR_YELLOW, 20); # success
print("Settings: Share landing in multiplayer is enabled");
}
if (getprop(addon.node.getPath() ~ "/addon-devel/sharemp")) {
printPersistentScreenMsg("Settings: Share landing in multiplayer is enabled", COLOR_YELLOW, 20); # success
print("Settings: Share landing in multiplayer is enabled");
}

} else {
# prints persistent message, white, 30 sec
printPersistentScreenMsg("Aircraft not compatible with Landing Rate addon. Sorry about that.", COLOR_WHITE, 30);
} else {
# prints persistent message, white, 30 sec
printPersistentScreenMsg("Aircraft not compatible with Landing Rate addon. Sorry about that.", COLOR_WHITE, 30);

# die addon, quit script with custom message.
logprint(LOG_ALERT, "Landing Rate addon shutdown. Aircraft not compatible with Landing Rate addon. Sorry about that.");
}
# die addon, quit script with custom message.
logprint(LOG_ALERT, "Landing Rate addon shutdown. Aircraft not compatible with Landing Rate addon. Sorry about that.");
}
};

var main = func (addon) {
# Must be _setlistener because removelistener doesn't work well with setlistener
var fdmInitListener = _setlistener("/sim/signals/fdm-initialized", func {
if (getprop("/sim/signals/fdm-initialized")) {
# Some aircraft like an24b report incompatibility, and it only need
# to give them a few seconds to set the required properties.
var timer = maketimer(2, func { init(addon, fdmInitListener) });
timer.singleShot = 1;
timer.start();
}
});
};