This repository has been archived on 2021-09-26. You can view files and clone it, but cannot push or open issues or pull requests.
IDG-A32X/Nasal/MCDU2/PERFCLB.nas

51 lines
1.8 KiB
Text

##############################################################
# Copyright (c) A3XX Development Team - All Rights Reserved. #
##############################################################
##################################################################
# A3XX mCDU by Joshua Davidson (it0uchpods) and Jonathan Redpath #
##################################################################
var perfCLBInput = func(key) {
var scratchpad = getprop("/MCDU[1]/scratchpad");
if (key == "L5") {
if (scratchpad == "CLR") {
setprop("/FMGC/internal/cost-index", 0);
setprop("/FMGC/internal/cost-index-set", 0);
setprop("/MCDU[1]/scratchpad-msg", "0");
setprop("/MCDU[1]/scratchpad", "");
} else {
var ci = int(scratchpad);
var cis = size(scratchpad);
if (cis >= 1 and cis <= 3) {
if (ci == nil) {
if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") {
setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad"));
}
setprop("/MCDU[1]/scratchpad-msg", "1");
setprop("/MCDU[1]/scratchpad", "NOT ALLOWED");
} else if (ci >= 0 and ci <= 120) {
setprop("/FMGC/internal/cost-index", ci);
setprop("/FMGC/internal/cost-index-set", 1);
setprop("/MCDU[1]/scratchpad", "");
} else {
if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") {
setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad"));
}
setprop("/MCDU[1]/scratchpad-msg", "1");
setprop("/MCDU[1]/scratchpad", "NOT ALLOWED");
}
} else {
if (getprop("/MCDU[1]/scratchpad") != "NOT ALLOWED") {
setprop("/MCDU[1]/last-scratchpad", getprop("/MCDU[1]/scratchpad"));
}
setprop("/MCDU[1]/scratchpad-msg", "1");
setprop("/MCDU[1]/scratchpad", "NOT ALLOWED");
}
}
} else if (key == "L6") {
setprop("/MCDU[1]/page", "TO");
} else if (key == "R6") {
setprop("/MCDU[1]/page", "CRZ");
}
}