If statement with 3 conditions.
On Extend Script engine my code works fine. But on JS it’s not just not working, it, it does not give errors, does not put anything into the text layer, but somehow works properly when all the variables are equal 1 (the last if condition). Honestly do not understand why it works somehow, if judging by the Abode post (https://helpx.adobe.com/after-effects/using/legacy-and-extend-script-engine.html) about the difference of engines. JS should not perceive if without else, and I have no one in the code... So th question is how to adapt code to JS.
Ts = thisComp.layer("Clock Controler").marker.key("Start").time;
Te = thisComp.layer("Clock Controler").marker.key("End").time;
St = thisComp.layer("Clock Controler").effect("Time start")("Angle");
En = thisComp.layer("Clock Controler").effect("Time end")("Angle");
if (thisComp.layer("Text Controler").effect("Animate Text")("Checkbox") == 1){
S = ease(time, Ts, Te, St, En) * 10
}
else{
S = thisComp.layer("Clock Controler").effect("Time end")("Angle") * 10
}
M = S/60
H = M/60
D = H/24
use_secs = thisComp.layer("Text Controler").effect("Use seconds in text ")("Checkbox")
use_hours = thisComp.layer("Text Controler").effect("Use hours in text")("Checkbox")
use_days = thisComp.layer("Text Controler").effect("Use days in text")("Checkbox")
//M
if ((use_hours == 0)&&(use_days == 0)&&(use_secs == 0))
if (Math.floor(M) == 1)"1 Minute"
else
Math.round(M) + "m1 Minutes"
//H
else if ((use_hours == 1)&&(use_days == 0)&&(use_secs == 0)){
hour_str = "h1"
min_str = "m1"
if (Math.floor(H) == 0) hour_str = "1"
if (Math.floor(H) == 1) hour_str = "1 Hour "
if (Math.floor(H) > 1) hour_str = Math.floor(H) + " Hours "
if (Math.floor(M % 60) == 0) min_str = "2"
if (Math.floor(M % 60) == 1) min_str = "1 Minute"
if (Math.floor(M % 60) > 1) min_str = Math.floor(M % 60) + " Minutes"
hour_str + min_str
}
//D
else if ((use_hours == 0)&&(use_days == 1)&&(use_secs == 0)){
day_str = "d1"
min_str = "m2"
if (Math.floor(D) == 0) day_str = "3"
if (Math.floor(D) == 1) day_str = "1 Day "
if (Math.floor(D) > 1) day_str = Math.floor(D) + " Days "
if (Math.floor(M % 1440) == 0) min_str = "4"
if (Math.floor(M % 1440) == 1) min_str = "1 Minute"
if (Math.floor(M % 1440) > 1) min_str = Math.floor(M % 1440) + " Minutes"
day_str + min_str
}
//DH
else if ((use_hours == 1)&&(use_days == 1)&&(use_secs == 0))
{
day_str = "d2"
hour_str = "h2"
min_str = "m3"
if (Math.floor(D) == 0) day_str = "5"
if (Math.floor(D) == 1) day_str = "1 Day "
if (Math.floor(D) > 1) day_str = Math.floor(D) + " Days "
if (Math.floor(H%24) == 0) hour_str = "6"
if (Math.floor(H%24) == 1) hour_str = "1 Hour "
if (Math.floor(H%24) > 1) hour_str = Math.floor(H%24) + " Hours "
if (Math.floor(M % 60) == 0) min_str = "7"
if (Math.floor(M % 60) == 1) min_str = "1 Minute"
if (Math.floor(M % 60) > 1) min_str = Math.floor(M % 60) + " Minutes"
day_str + hour_str + min_str
}
//S
else if ((use_hours == 0)&&(use_days == 0)&&(use_secs == 1)){
sec_str = "s1"
min_str = "m4"
if (Math.floor(M) == 0) min_str = "8"
if (Math.floor(M) == 1) min_str = "1 Minute "
if (Math.floor(M) > 1) min_str = Math.floor(M) + " Minutes "
if (Math.floor(S % 60) == 0) sec_str = "9"
if (Math.floor(S % 60) == 1) sec_str = "1 Second"
if (Math.floor(S % 60) > 1) sec_str = Math.floor(S%60) + " Seconds"
min_str + sec_str
}
//HS
if ((use_hours == 1)&&(use_days == 0)&&(use_secs == 1)){
hour_str = "h3"
min_str = "m5"
sec_str = "s2"
if (Math.floor(H) == 0) hour_str = "10"
if (Math.floor(H) == 1) hour_str = "1 Hour "
if (Math.floor(H) > 1) hour_str = Math.floor(H) + " Hours "
if (Math.floor(M % 60) == 0) min_str = "11"
if (Math.floor(M % 60) == 1) min_str = "1 Minute "
if (Math.floor(M % 60) > 1) min_str = Math.floor(M % 60) + " Minutes "
if (Math.floor(S % 60) == 0) sec_str = "12"
if (Math.floor(S % 60) == 1) sec_str = "1 Second"
if (Math.floor(S % 60) > 1) sec_str = Math.floor(S%60) + " Seconds"
hour_str + min_str + sec_str
}
//DS
else if ((use_hours == 0)&&(use_days == 1)&&(use_secs == 1)){
day_str = "d3"
min_str = "m6"
sec_str = "s3"
if (Math.floor(D) == 0) day_str = "13"
if (Math.floor(D) == 1) day_str = "1 Day "
if (Math.floor(D) > 1) day_str = Math.floor(D) + " Days "
if (Math.floor(M % 1440) == 0) min_str = "14"
if (Math.floor(M % 1440) == 1) min_str = "1 Minute "
if (Math.floor(M % 1440) > 1) min_str = Math.floor(M % 1440) + " Minutes "
if (Math.floor(S % 60) == 0) sec_str = "15"
if (Math.floor(S % 60) == 1) sec_str = "1 Second"
if (Math.floor(S % 60) > 1) sec_str = Math.floor(S%60) + " Seconds"
day_str + min_str + sec_str
}
//DHS
if ((use_hours == 1)&&(use_days == 1)&&(use_secs == 1))
{
day_str = "d4"
hour_str = "h4"
min_str = "m7"
sec_str = "s5"
if (Math.floor(D) == 0) day_str = "16"
if (Math.floor(D) == 1) day_str = "1 Day "
if (Math.floor(D) > 1) day_str = Math.floor(D) + " Days "
if (Math.floor(H%24) == 0) hour_str = "\r"
if (Math.floor(H%24) == 1) hour_str = "1 Hour \r"
if (Math.floor(H%24) > 1) hour_str = Math.floor(H%24) + " Hours \r"
if (Math.floor(M % 60) == 0) min_str = "17"
if (Math.floor(M % 60) == 1) min_str = "1 Minute "
if (Math.floor(M % 60) > 1) min_str = Math.floor(M % 60) + " Minutes "
if (Math.floor(S % 60) == 0) sec_str = "18"
if (Math.floor(S % 60) == 1) sec_str = "1 Second"
if (Math.floor(S % 60) > 1) sec_str = Math.floor(S%60) + " Seconds"
day_str + hour_str + min_str + sec_str
}
Honestly do not understand why it works somehow, if judging by the Abode post (https://helpx.adobe.com/after-effects/using/legacy-and-extend-script-engine.html) about the difference of engines. JS should not perceive if without else, and I have no one in the code...
