Fix redundant elsif, fix and simplify broken fill-up code.
(Pointed out by Csaba HALASZ)
This commit is contained in:
parent
abaa43a1a5
commit
f236a438b8
1 changed files with 4 additions and 5 deletions
|
@ -125,7 +125,7 @@ var update_loop = func {
|
|||
t.getNode("level-lbs").setDoubleValue(lbs);
|
||||
}
|
||||
|
||||
} elsif (consumed < 0) {
|
||||
} else {
|
||||
#find the number of tanks which can accept fuel
|
||||
var available = 0;
|
||||
|
||||
|
@ -140,7 +140,7 @@ var update_loop = func {
|
|||
}
|
||||
|
||||
if (available > 0) {
|
||||
var fuel_per_tank = consumed / available;
|
||||
var fuel_per_tank = -consumed / available;
|
||||
|
||||
# add fuel to each available tank
|
||||
foreach (var t; selected_tanks) {
|
||||
|
@ -148,9 +148,8 @@ var update_loop = func {
|
|||
var capacity = t.getNode("capacity-gal_us").getValue() * ppg;
|
||||
var lbs = t.getNode("level-gal_us").getValue() * ppg;
|
||||
|
||||
if (capacity - lbs >= fuel_per_tank) {
|
||||
lbs -= fuel_per_tank;
|
||||
} elsif (capacity - lbs < fuel_per_tank) {
|
||||
lbs += fuel_per_tank;
|
||||
if (lbs > capacity) {
|
||||
lbs = capacity;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue