From aa2686c0b9e3c9d99369cfeaf9ae497ac49400ec Mon Sep 17 00:00:00 2001
From: andy <andy>
Date: Fri, 30 Apr 2004 14:42:42 +0000
Subject: [PATCH] Support a "kill-when-empty" flag on tanks to enable the
 strict "engines die when any tank is empty" behavior.  Otherwise, just
 deselect the empty tank.  This matches the "both" behavior many lightplane
 fuel selectors have.

---
 Nasal/fuel.nas | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Nasal/fuel.nas b/Nasal/fuel.nas
index a213c089a..02bc4b277 100644
--- a/Nasal/fuel.nas
+++ b/Nasal/fuel.nas
@@ -60,7 +60,13 @@ fuelUpdate = func {
             ppg = t.getNode("density-ppg").getValue();
             lbs = t.getNode("level-gal_us").getValue() * ppg;
             lbs = lbs - fuelPerTank;
-            if(lbs < 0) { lbs = 0; outOfFuel = 1; }
+            if(lbs < 0) {
+                lbs = 0; 
+                # Kill the engines if we're told to, otherwise simply
+                # deselect the tank.
+                if(t.getBoolValue("kill-when-empty")) { outOfFuel = 1; }
+                else { t.setBoolValue("selected", 0); }
+            }
             gals = lbs / ppg;
             t.getNode("level-gal_us").setDoubleValue(gals);
             t.getNode("level-lbs").setDoubleValue(lbs);