1
0
Fork 0

Formatting: remove need for leading zeroes, sprintf() on wind_heading / magnitude

This commit is contained in:
legoboyvdlp R 2020-06-14 12:56:10 +01:00
parent 1abf474b58
commit 3ff34c66da
3 changed files with 36 additions and 37 deletions

View file

@ -73,7 +73,7 @@ var windCLBPage = {
var wind = 0;
wind = fmgc.windController.clb_winds[computer_temp].wind5;
if (wind.altitude != "") {
me.L5 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, nil, "blu"];
me.L5 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, nil, "blu"];
me.fontMatrix[0][4] = 1;
} else {
me.L5 = ["[ ]/[ ]/[ ]", nil, "blu"];
@ -86,7 +86,7 @@ var windCLBPage = {
if (me.items >= 4) {
wind = fmgc.windController.clb_winds[computer_temp].wind4;
if (wind.altitude != "") {
me.L4 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, nil, "blu"];
me.L4 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, nil, "blu"];
me.fontMatrix[0][3] = 1;
} else {
me.L4 = ["[ ]/[ ]/[ ]", nil, "blu"];
@ -99,7 +99,7 @@ var windCLBPage = {
if (me.items >= 3) {
wind = fmgc.windController.clb_winds[computer_temp].wind3;
if (wind.altitude != "") {
me.L3 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, nil, "blu"];
me.L3 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, nil, "blu"];
me.fontMatrix[0][2] = 1;
} else {
me.L3 = ["[ ]/[ ]/[ ]", nil, "blu"];
@ -112,7 +112,7 @@ var windCLBPage = {
if (me.items >= 2) {
wind = fmgc.windController.clb_winds[computer_temp].wind2;
if (wind.altitude != "") {
me.L2 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, nil, "blu"];
me.L2 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, nil, "blu"];
me.fontMatrix[0][1] = 1;
} else {
me.L2 = ["[ ]/[ ]/[ ]", nil, "blu"];
@ -125,7 +125,7 @@ var windCLBPage = {
if (me.items >= 1) {
wind = fmgc.windController.clb_winds[computer_temp].wind1;
if (wind.altitude != "") {
me.L1 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, "TRU WIND/ALT", "blu"];
me.L1 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, "TRU WIND/ALT", "blu"];
me.fontMatrix[0][0] = 1;
} else {
me.L1 = ["[ ]/[ ]/[ ]", "TRU WIND/ALT", "blu"];
@ -192,11 +192,11 @@ var windCLBPage = {
} else if (index == 6) {
setprop("/MCDU[" ~ me.computer ~ "]/page", fmgc.windController.accessPage[me.computer]);
} else if (me.items >= index) {
if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) == 13) {
if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) >= 5 and size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) <= 13) {
var winds = split("/", mcdu_scratchpad.scratchpads[me.computer].scratchpad);
if (size(winds[0]) == 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and
size(winds[1]) == 3 and num(winds[1]) != nil and winds[1] >= 0 and winds[1] <= 200 and
size(winds[2]) == 5 and ((num(winds[2]) != nil and winds[2] >= 1000 and winds[2] <= 39000) or
if (size(winds[0]) >= 1 and size(winds[0]) <= 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and
size(winds[1]) >= 1 and size(winds[1]) <= 3 and num(winds[1]) != nil and winds[1] >= 0 and winds[1] <= 200 and
size(winds[2]) >= 4 and size(winds[2]) <= 5 and ((num(winds[2]) != nil and winds[2] >= 1000 and winds[2] <= 39000) or
(num(split("FL", winds[2])[1]) != nil and split("FL", winds[2])[1] >= 10 and split("FL", winds[2])[1] <= 390))) {
me.makeTmpy();
var computer_temp = 2;

View file

@ -98,7 +98,7 @@ var windCRZPage = {
if (me.items >= 4) {
wind = fmgc.windController.crz_winds[computer_temp].wind4;
if (wind.altitude != "") {
me.L4 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, nil, "blu"];
me.L4 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, nil, "blu"];
me.fontMatrix[0][3] = 1;
} else {
me.L4 = ["[ ]/[ ]/[ ]", nil, "blu"];
@ -111,7 +111,7 @@ var windCRZPage = {
if (me.items >= 3) {
wind = fmgc.windController.crz_winds[computer_temp].wind3;
if (wind.altitude != "") {
me.L3 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, nil, "blu"];
me.L3 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, nil, "blu"];
me.fontMatrix[0][2] = 1;
} else {
me.L3 = ["[ ]/[ ]/[ ]", nil, "blu"];
@ -124,7 +124,7 @@ var windCRZPage = {
if (me.items >= 2) {
wind = fmgc.windController.crz_winds[computer_temp].wind2;
if (wind.altitude != "") {
me.L2 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, nil, "blu"];
me.L2 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, nil, "blu"];
me.fontMatrix[0][1] = 1;
} else {
me.L2 = ["[ ]/[ ]/[ ]", nil, "blu"];
@ -137,7 +137,7 @@ var windCRZPage = {
if (me.items >= 1) {
wind = fmgc.windController.crz_winds[computer_temp].wind1;
if (wind.altitude != "") {
me.L1 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, "TRU WIND/ALT", "blu"];
me.L1 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, "TRU WIND/ALT", "blu"];
me.fontMatrix[0][0] = 1;
} else {
me.L1 = ["[ ]/[ ]/[ ]", "TRU WIND/ALT", "blu"];
@ -157,7 +157,7 @@ var windCRZPage = {
if (me.items >= 4) {
wind = fmgc.windController.winds[computer_temp][me.match_location].wind4;
if (wind.altitude != "") {
me.L4 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, nil, "blu"];
me.L4 = [sprintf("%03.0f", wind.heading) ~ "°/" ~sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, nil, "blu"];
me.fontMatrix[0][3] = 1;
} else {
me.L4 = ["[ ]/[ ]/[ ]", nil, "blu"];
@ -170,7 +170,7 @@ var windCRZPage = {
if (me.items >= 3) {
wind = fmgc.windController.winds[computer_temp][me.match_location].wind3;
if (wind.altitude != "") {
me.L3 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, nil, "blu"];
me.L3 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, nil, "blu"];
me.fontMatrix[0][2] = 1;
} else {
me.L3 = ["[ ]/[ ]/[ ]", nil, "blu"];
@ -183,7 +183,7 @@ var windCRZPage = {
if (me.items >= 2) {
wind = fmgc.windController.winds[computer_temp][me.match_location].wind2;
if (wind.altitude != "") {
me.L2 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, nil, "blu"];
me.L2 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, nil, "blu"];
me.fontMatrix[0][1] = 1;
} else {
me.L2 = ["[ ]/[ ]/[ ]", nil, "blu"];
@ -196,7 +196,7 @@ var windCRZPage = {
if (me.items >= 1) {
wind = fmgc.windController.winds[computer_temp][me.match_location].wind1;
if (wind.altitude != "") {
me.L1 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, "TRU WIND/ALT", "blu"];
me.L1 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, "TRU WIND/ALT", "blu"];
me.fontMatrix[0][0] = 1;
} else {
me.L1 = ["[ ]/[ ]/[ ]", "TRU WIND/ALT", "blu"];
@ -281,11 +281,10 @@ var windCRZPage = {
} else if (index == 6) {
setprop("/MCDU[" ~ me.computer ~ "]/page", fmgc.windController.accessPage[me.computer]);
} else if (index == 5) {
var sts = size(mcdu_scratchpad.scratchpads[me.computer].scratchpad);
if (sts >= 7 and sts <= 9) {
if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) >= 6 and size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) <= 9) {
var winds = split("/", mcdu_scratchpad.scratchpads[me.computer].scratchpad);
if (size(winds[0]) >= 1 and size(winds[0]) <= 3 and num(winds[0]) != nil and winds[0] >= -99 and winds[0] <= 99 and
size(winds[1]) == 5 and ((num(winds[1]) != nil and winds[1] >= 1000 and winds[1] <= 39000) or
size(winds[1]) >= 4 and size(winds[1]) <= 5 and ((num(winds[1]) != nil and winds[1] >= 1000 and winds[1] <= 39000) or
(num(split("FL", winds[1])[1]) != nil and split("FL", winds[1])[1] >= 10 and split("FL", winds[1])[1] <= 390))) {
me.makeTmpy();
var computer_temp = 2;
@ -326,11 +325,11 @@ var windCRZPage = {
mcdu_message(me.computer, "NOT ALLOWED");
}
} else if (me.items >= index) {
if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) == 13) {
if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) >= 5 and size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) <= 13) {
var winds = split("/", mcdu_scratchpad.scratchpads[me.computer].scratchpad);
if (size(winds[0]) == 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and
size(winds[1]) == 3 and num(winds[1]) != nil and winds[1] >= 0 and winds[1] <= 200 and
size(winds[2]) == 5 and ((num(winds[2]) != nil and winds[2] >= 1000 and winds[2] <= 39000) or
if (size(winds[0]) >= 1 and size(winds[0]) <= 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and
size(winds[1]) >= 1 and size(winds[1]) <= 3 and num(winds[1]) != nil and winds[1] >= 0 and winds[1] <= 200 and
size(winds[2]) >= 4 and size(winds[2]) <= 5 and ((num(winds[2]) != nil and winds[2] >= 1000 and winds[2] <= 39000) or
(num(split("FL", winds[2])[1]) != nil and split("FL", winds[2])[1] >= 10 and split("FL", winds[2])[1] <= 390))) {
me.makeTmpy();
var computer_temp = 2;

View file

@ -74,7 +74,7 @@ var windDESPage = {
var wind = 0;
wind = fmgc.windController.des_winds[computer_temp].wind5;
if (wind.altitude != "") {
me.L5 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, nil, "blu"];
me.L5 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, nil, "blu"];
me.fontMatrix[0][4] = 1;
} else {
me.L5 = ["[ ]/[ ]/[ ]", nil, "blu"];
@ -87,7 +87,7 @@ var windDESPage = {
if (me.items >= 4) {
wind = fmgc.windController.des_winds[computer_temp].wind4;
if (wind.altitude != "") {
me.L4 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, nil, "blu"];
me.L4 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, nil, "blu"];
me.fontMatrix[0][3] = 1;
} else {
me.L4 = ["[ ]/[ ]/[ ]", nil, "blu"];
@ -100,7 +100,7 @@ var windDESPage = {
if (me.items >= 3) {
wind = fmgc.windController.des_winds[computer_temp].wind3;
if (wind.altitude != "") {
me.L3 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, nil, "blu"];
me.L3 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, nil, "blu"];
me.fontMatrix[0][2] = 1;
} else {
me.L3 = ["[ ]/[ ]/[ ]", nil, "blu"];
@ -113,7 +113,7 @@ var windDESPage = {
if (me.items >= 2) {
wind = fmgc.windController.des_winds[computer_temp].wind2;
if (wind.altitude != "") {
me.L2 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, nil, "blu"];
me.L2 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, nil, "blu"];
me.fontMatrix[0][1] = 1;
} else {
me.L2 = ["[ ]/[ ]/[ ]", nil, "blu"];
@ -126,7 +126,7 @@ var windDESPage = {
if (me.items >= 1) {
wind = fmgc.windController.des_winds[computer_temp].wind1;
if (wind.altitude != "") {
me.L1 = [wind.heading ~ "°/" ~ wind.magnitude ~ "/" ~ wind.altitude, "TRU WIND/ALT", "blu"];
me.L1 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude) ~ "/" ~ wind.altitude, "TRU WIND/ALT", "blu"];
me.fontMatrix[0][0] = 1;
} else {
me.L1 = ["[ ]/[ ]/[ ]", "TRU WIND/ALT", "blu"];
@ -139,7 +139,7 @@ var windDESPage = {
if (getprop("/FMGC/internal/alt-set")) {
wind = fmgc.windController.des_winds[computer_temp].alt1;
if (wind.heading != 0 and wind.magnitude != 0) {
me.R1 = [wind.heading ~ "°/" ~ wind.magnitude, "ALTN WIND ", "blu"];
me.R1 = [sprintf("%03.0f", wind.heading) ~ "°/" ~ sprintf("%03.0f", wind.magnitude), "ALTN WIND ", "blu"];
me.fontMatrix[1][0] = 1;
} else {
me.R1 = ["[ ]/[ ]", "ALTN WIND ", "blu"];
@ -208,11 +208,11 @@ var windDESPage = {
} else if (index == 6) {
setprop("/MCDU[" ~ me.computer ~ "]/page", fmgc.windController.accessPage[me.computer]);
} else if (me.items >= index) {
if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) == 13) {
if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) >= 5 and size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) <= 13) {
var winds = split("/", mcdu_scratchpad.scratchpads[me.computer].scratchpad);
if (size(winds[0]) == 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and
size(winds[1]) == 3 and num(winds[1]) != nil and winds[1] >= 0 and winds[1] <= 200 and
size(winds[2]) == 5 and ((num(winds[2]) != nil and winds[2] >= 1000 and winds[2] <= 39000) or
if (size(winds[0]) >= 0 and size(winds[0]) <= 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and
size(winds[1]) >= 0 and size(winds[1]) <= 3 and num(winds[1]) != nil and winds[1] >= 0 and winds[1] <= 200 and
size(winds[2]) >= 4 and size(winds[2]) <= 5 and ((num(winds[2]) != nil and winds[2] >= 1000 and winds[2] <= 39000) or
(num(split("FL", winds[2])[1]) != nil and split("FL", winds[2])[1] >= 10 and split("FL", winds[2])[1] <= 390))) {
me.makeTmpy();
var computer_temp = 2;
@ -312,10 +312,10 @@ var windDESPage = {
},
pushButtonRight: func(index) {
if (index == 1 and getprop("/FMGC/internal/alt-set")) {
if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) == 7) {
if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) >= 3 and size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) <= 7) {
var winds = split("/", mcdu_scratchpad.scratchpads[me.computer].scratchpad);
if (size(winds[0]) == 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and
size(winds[1]) == 3 and num(winds[1]) != nil and winds[1] >= 0 and winds[1] <= 200) {
if (size(winds[0]) >= 1 and size(winds[0]) <= 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and
size(winds[1]) >= 1 and size(winds[1]) <= 3 and num(winds[1]) != nil and winds[1] >= 0 and winds[1] <= 200) {
me.makeTmpy();
var computer_temp = 2;
if (fmgc.flightPlanController.temporaryFlag[me.computer]) {