Changing Fuel on aircraft: incorrect results when #drop tanks is 2,4,5?
Posted: Thu Jun 11, 2020 2:06 pm
This applies to aircraft types only, and only aircraft with 2 drop+ tanks (with exception) that I've found.
Aircraft tested with no drop tanks or 1 drop tank work entirely as expected, as do those with 3.
When using unit.fuel to set fuel on type 2001, any value you give it that is a decrease, the difference seems to be applied twice. Any value you give it that is an increase the difference seems to be doubled.
Lets take a mig-31BM #3963 with a long-range aa-13 loadout and 2 drop tanks.
She starts with her main tank @ 16350 and 2 drop tanks at @ 2000 each for a total of 20350.
local u = ScenEdit_GetUnit({name='MiG-31BM Foxhound', guid='4FH7PU-0HM0E070ONF69'});
print(--before--);print(u.fuel);print(u.fuels);
{ [2001] = { max = 20350, type = 2001, name = 'AviationFuel', current = 20350 } }
{ [1] = { max = 16350, type = 2001, name = 'AviationFuel', current = 16350 }, [2] = { max = 2000, type = 2001, name = 'AviationFuel', current = 2000 }, [3] = { max = 2000, type = 2001, name = 'AviationFuel', current = 2000 } }
So let's say I want to set her fuel to 19350, a subtraction of 1000.
I have two options SetUnit or update the table and feed it back.
Lets do typical update table method.
local newfuel = u.fuel --get a copy
newfuel[2001].current = 19350; --change copy
u.fuel = newfuel -- submit our changes.
print(--after--);print(u.fuel);print(u.fuels);
---after---
{ [2001] = { max = 20350, type = 2001, name = 'AviationFuel', current = 18350 } }
{ [1] = { max = 16350, type = 2001, name = 'AviationFuel', current = 16350 }, [2] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1000 }, [3] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1000 } }
As you can see it doubled the difference requested and took 1000 each out of the drop tanks. You will get the same result using: ScenEdit_SetUnit({guid=u.guid, fuel={ {2001,19350} } }) for our purposes it doesn't matter which you use.
Now it's at 18350. So let's try adding back 1000 by telling it once again we would like 19350, basically just run it a second time.
---before---
{ [2001] = { max = 20350, type = 2001, name = 'AviationFuel', current = 18350 } }
{ [1] = { max = 16350, type = 2001, name = 'AviationFuel', current = 16350 }, [2] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1000 }, [3] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1000 } }
---after---
{ [2001] = { max = 20350, type = 2001, name = 'AviationFuel', current = 18350 } }
{ [1] = { max = 16350, type = 2001, name = 'AviationFuel', current = 16350 }, [2] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1000 }, [3] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1000 } }
It did not change anything, as if thinks it was at 19350 already.[&:]
If we re-run it and tell it anything above 19350, like 19360, it will add 20 fuel instead of 10.
---before---
{ [2001] = { max = 20350, type = 2001, name = 'AviationFuel', current = 18350 } }
{ [1] = { max = 16350, type = 2001, name = 'AviationFuel', current = 16350 }, [2] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1000 }, [3] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1000 } }
---after---
{ [2001] = { max = 20350, type = 2001, name = 'AviationFuel', current = 18370 } }
{ [1] = { max = 16350, type = 2001, name = 'AviationFuel', current = 16350 }, [2] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1010 }, [3] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1010 } }
Now if you test the same thing on a mig-31BM #3963 with no drop tanks: works fine.
Now if you test the same thing on a mig-35 #3914 with 1 drop tanks or 3 drop tanks: works fine.
Now if you test the same thing on a f-15EX #7441 with 4 drop tanks. try removing 1000 like above, you get the off-by-double problem 14150 becomes 12150 when setting to 13150.
Now it gets even more odd.
Grab an EA-6B ICAPIII with 5 tanks on a ferry loadout:
---before---
{ [2001] = { max = 11550, type = 2001, name = 'AviationFuel', current = 11550 } }
{ [1] = { max = 7000, type = 2001, name = 'AviationFuel', current = 7000 }, [2] = { max = 910, type = 2001, name = 'AviationFuel', current = 910 }, [3] = { max = 910, type = 2001, name = 'AviationFuel', current = 910 }, [4] = { max = 910, type = 2001, name = 'AviationFuel', current = 910 }, [5] = { max = 910, type = 2001, name = 'AviationFuel', current = 910 }, [6] = { max = 910, type = 2001, name = 'AviationFuel', current = 910 } }
ScenEdit_SetUnit({guid=u.guid, fuel={ {2001,10550} } }) --lets try removing the same 1000.
---after---
{ [2001] = { max = 11550, type = 2001, name = 'AviationFuel', current = 7000 } }
{ [1] = { max = 7000, type = 2001, name = 'AviationFuel', current = 7000 }, [2] = { max = 910, type = 2001, name = 'AviationFuel', current = 0 }, [3] = { max = 910, type = 2001, name = 'AviationFuel', current = 0 }, [4] = { max = 910, type = 2001, name = 'AviationFuel', current = 0 }, [5] = { max = 910, type = 2001, name = 'AviationFuel', current = 0 }, [6] = { max = 910, type = 2001, name = 'AviationFuel', current = 0 } }
^I can't explain that one, removed 4550.[&:] And if you run again after that asking for say 11000, it results in 8800?
Anyway in all cases when setting via the gui the problem does not appear on any of the tested aircraft.
Aircraft tested with no drop tanks or 1 drop tank work entirely as expected, as do those with 3.
When using unit.fuel to set fuel on type 2001, any value you give it that is a decrease, the difference seems to be applied twice. Any value you give it that is an increase the difference seems to be doubled.
Lets take a mig-31BM #3963 with a long-range aa-13 loadout and 2 drop tanks.
She starts with her main tank @ 16350 and 2 drop tanks at @ 2000 each for a total of 20350.
local u = ScenEdit_GetUnit({name='MiG-31BM Foxhound', guid='4FH7PU-0HM0E070ONF69'});
print(--before--);print(u.fuel);print(u.fuels);
{ [2001] = { max = 20350, type = 2001, name = 'AviationFuel', current = 20350 } }
{ [1] = { max = 16350, type = 2001, name = 'AviationFuel', current = 16350 }, [2] = { max = 2000, type = 2001, name = 'AviationFuel', current = 2000 }, [3] = { max = 2000, type = 2001, name = 'AviationFuel', current = 2000 } }
So let's say I want to set her fuel to 19350, a subtraction of 1000.
I have two options SetUnit or update the table and feed it back.
Lets do typical update table method.
local newfuel = u.fuel --get a copy
newfuel[2001].current = 19350; --change copy
u.fuel = newfuel -- submit our changes.
print(--after--);print(u.fuel);print(u.fuels);
---after---
{ [2001] = { max = 20350, type = 2001, name = 'AviationFuel', current = 18350 } }
{ [1] = { max = 16350, type = 2001, name = 'AviationFuel', current = 16350 }, [2] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1000 }, [3] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1000 } }
As you can see it doubled the difference requested and took 1000 each out of the drop tanks. You will get the same result using: ScenEdit_SetUnit({guid=u.guid, fuel={ {2001,19350} } }) for our purposes it doesn't matter which you use.
Now it's at 18350. So let's try adding back 1000 by telling it once again we would like 19350, basically just run it a second time.
---before---
{ [2001] = { max = 20350, type = 2001, name = 'AviationFuel', current = 18350 } }
{ [1] = { max = 16350, type = 2001, name = 'AviationFuel', current = 16350 }, [2] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1000 }, [3] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1000 } }
---after---
{ [2001] = { max = 20350, type = 2001, name = 'AviationFuel', current = 18350 } }
{ [1] = { max = 16350, type = 2001, name = 'AviationFuel', current = 16350 }, [2] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1000 }, [3] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1000 } }
It did not change anything, as if thinks it was at 19350 already.[&:]
If we re-run it and tell it anything above 19350, like 19360, it will add 20 fuel instead of 10.
---before---
{ [2001] = { max = 20350, type = 2001, name = 'AviationFuel', current = 18350 } }
{ [1] = { max = 16350, type = 2001, name = 'AviationFuel', current = 16350 }, [2] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1000 }, [3] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1000 } }
---after---
{ [2001] = { max = 20350, type = 2001, name = 'AviationFuel', current = 18370 } }
{ [1] = { max = 16350, type = 2001, name = 'AviationFuel', current = 16350 }, [2] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1010 }, [3] = { max = 2000, type = 2001, name = 'AviationFuel', current = 1010 } }
Now if you test the same thing on a mig-31BM #3963 with no drop tanks: works fine.
Now if you test the same thing on a mig-35 #3914 with 1 drop tanks or 3 drop tanks: works fine.
Now if you test the same thing on a f-15EX #7441 with 4 drop tanks. try removing 1000 like above, you get the off-by-double problem 14150 becomes 12150 when setting to 13150.
Now it gets even more odd.
Grab an EA-6B ICAPIII with 5 tanks on a ferry loadout:
---before---
{ [2001] = { max = 11550, type = 2001, name = 'AviationFuel', current = 11550 } }
{ [1] = { max = 7000, type = 2001, name = 'AviationFuel', current = 7000 }, [2] = { max = 910, type = 2001, name = 'AviationFuel', current = 910 }, [3] = { max = 910, type = 2001, name = 'AviationFuel', current = 910 }, [4] = { max = 910, type = 2001, name = 'AviationFuel', current = 910 }, [5] = { max = 910, type = 2001, name = 'AviationFuel', current = 910 }, [6] = { max = 910, type = 2001, name = 'AviationFuel', current = 910 } }
ScenEdit_SetUnit({guid=u.guid, fuel={ {2001,10550} } }) --lets try removing the same 1000.
---after---
{ [2001] = { max = 11550, type = 2001, name = 'AviationFuel', current = 7000 } }
{ [1] = { max = 7000, type = 2001, name = 'AviationFuel', current = 7000 }, [2] = { max = 910, type = 2001, name = 'AviationFuel', current = 0 }, [3] = { max = 910, type = 2001, name = 'AviationFuel', current = 0 }, [4] = { max = 910, type = 2001, name = 'AviationFuel', current = 0 }, [5] = { max = 910, type = 2001, name = 'AviationFuel', current = 0 }, [6] = { max = 910, type = 2001, name = 'AviationFuel', current = 0 } }
^I can't explain that one, removed 4550.[&:] And if you run again after that asking for say 11000, it results in 8800?
Anyway in all cases when setting via the gui the problem does not appear on any of the tested aircraft.