System: bug fix

This commit is contained in:
Sidi Liang 2019-07-31 14:22:33 +08:00
parent 394a34d05f
commit 5925a7cdb1
2 changed files with 23 additions and 13 deletions

View File

@ -272,24 +272,30 @@ var chargeBatterySec = func(){
}
var chargeTimer = maketimer(1, chargeBatterySec);
var chargeBatteryStart = func(){
if(props.getNode("/",1).getValue("services/service-truck/connect") == 1 and props.getNode("/",1).getValue("/controls/engines/engine/started") == 0){
var deltaBattery = 288000-props.getNode("/systems/electrical/e-tron/battery-kWs").getValue();
var remainingTime = sprintf("%.0f", (deltaBattery / 240) / 60); #Based on 20 mins from 0 to full
#screen.log.write("Recharging. About "~remainingTime~" mins remaining.", 0, 0.584, 1);
setprop("/sim/sound/voices/pilot", "Recharging. About "~remainingTime~" mins remaining.");
chargeTimer.start();
props.getNode("/controls/is-recharging", 1).setValue(1);
}else if(!props.getNode("/",1).getValue("services/service-truck/connect")){
#screen.log.write("Cannot recharge. Call service truck and connect the cable first.", 0, 0.584, 1);
setprop("/sim/sound/voices/pilot", "Cannot recharge. Call service truck and connect the cable first.");
}else if(props.getNode("/",1).getValue("/controls/engines/engine/started")){
#screen.log.write("Cannot recharge. Shut down the engine first.", 0, 0.584, 1);
setprop("/sim/sound/voices/pilot", "Cannot recharge. Shut down the engine first.");
if(!chargeTimer.isRunning()){
if(props.getNode("/",1).getValue("services/service-truck/connect") == 1 and props.getNode("/",1).getValue("/controls/engines/engine/started") == 0){
var deltaBattery = 288000-props.getNode("/systems/electrical/e-tron/battery-kWs").getValue();
var remainingTime = sprintf("%.0f", (deltaBattery / 240) / 60); #Based on 20 mins from 0 to full
#screen.log.write("Recharging. About "~remainingTime~" mins remaining.", 0, 0.584, 1);
setprop("/sim/sound/voices/pilot", "Recharging. About "~remainingTime~" mins remaining.");
chargeTimer.start();
props.getNode("/controls/is-recharging", 1).setValue(1);
}else if(!props.getNode("/",1).getValue("services/service-truck/connect")){
screen.log.write("Cannot recharge. Call service truck and connect the cable first.", 0, 0.584, 1);
setprop("/sim/sound/voices/pilot", "Cannot recharge. Call service truck and connect the cable first.");
}else if(props.getNode("/",1).getValue("/controls/engines/engine/started")){
screen.log.write("Cannot recharge. Shut down the engine first.", 0, 0.584, 1);
setprop("/sim/sound/voices/pilot", "Cannot recharge. Shut down the engine first.");
}
}else if(chargeTimer.isRunning()){
chargeBatteryStop();
}
}
var chargeBatteryStop = func(){
chargeTimer.stop();
screen.log.write("Recharge Stopped", 0, 0.584, 1);
setprop("/sim/sound/voices/pilot", "Recharge Stopped. Have a nice ride!");
props.getNode("/controls/is-recharging", 1).setValue(0);
}

View File

@ -74,6 +74,10 @@
<command>property-toggle</command>
<property>services/service-truck/enable</property>
</binding>
<binding>
<command>nasal</command>
<script>setprop("/sim/sound/voices/pilot", "Hey there! How can I help you, comrade?")</script>
</binding>
<binding>
<command>dialog-update</command>
</binding>