Aircraft Fuel State Discrepancy

Post bug reports and ask for game support here.

Moderator: MOD_Command

Post Reply
DismalPseudoscience
Posts: 53
Joined: Fri Oct 10, 2014 5:34 am

Aircraft Fuel State Discrepancy

Post by DismalPseudoscience »

Hi all!

I've observed an apparent bug where aircraft are flying around with clearly positive fuel remaining, but a Lua call to their fuel state suggests 0 aviation fuel remaining.

In my scenario, I allow the player to spawn a flight of Tomcats with a special action, but I try to use Lua to take them away from the player once their fuel state is low (or if the player tries to land them to game my system and keep them permanently).

In my Lua action, the planes de-spawn once their fuel state is less than 1/3rd their maximum. However, they seem to reach this with ~85% of their fuel left according to the unit view in the sidebar. You can test this by starting my special action, and then flying the Tomcats around until they disappear.

I added an extra Tomcat for testing purposes (flying around over Iran in the save) and called its fuel state in the script consol, finding that it currently is airborne with 0 fuel! This explains why my Lua action de-spawns my planes so quickly, but why should this be happening? Am I misunderstanding the Lua around fuel states, or is this a bug?

Thank you!
Attachments
IntheWal..UELTEST.zip
(209.77 KiB) Downloaded 10 times
Dimitris
Posts: 15552
Joined: Sun Jul 31, 2005 10:29 am
Contact:

RE: Aircraft Fuel State Discrepancy

Post by Dimitris »

Thanks, logged. We'll investigate as time permits.
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Aircraft Fuel State Discrepancy

Post by michaelm75au »

I think the issue is that only one 'fuel' is being returned. There should be 3 from the looks of it.

I'll change the table to use the combined fuel values, and probably add a new table item for the break down in case you want independent fuel levels.

I don't think multiple fuel levels of the same type were in place when the Lua fuel methods were first written.
Michael
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Aircraft Fuel State Discrepancy

Post by michaelm75au »

With the proposed change, 'fuel' may return an extended table.
{ [1] = { max = 7355, name = 'AviationFuel', type = 2001, current = 6986.43359375 }, [2] = { max = 810, name = 'AviationFuel', type = 2001, current = 0 }, [3] = { max = 810, name = 'AviationFuel', type = 2001, current = 0 }, [2001] = { max = 8975, name = 'AviationFuel', type = 2001, current = 6986.43359375 } }
The normal fuel type [2001] will be present with total of that fuel type, but there may be several other entries [1...] which will be the main fuel plus the drop tank capacity - in the attached example file from above, the Tomcat has 2 drop tanks (which appear to be empty now.
Michael
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Aircraft Fuel State Discrepancy

Post by KnightHawk75 »

ORIGINAL: michaelm75au

I think the issue is that only one 'fuel' is being returned. There should be 3 from the looks of it.

I'll change the table to use the combined fuel values, and probably add a new table item for the break down in case you want independent fuel levels.

I don't think multiple fuel levels of the same type were in place when the Lua fuel methods were first written.

Thank you, was just about to post about this issue too, lua returning only the first or random storage tank. Looking forward to the change, being able to enum through each tank is even better than what I was going to suggest.
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Aircraft Fuel State Discrepancy

Post by michaelm75au »

In order to mitigate breaking any old scripts using .fuel, I think I will change the .fuel method to just return the totals by fuel type so it looks like the original way, and add the 'tank' breakdown as a new method "fuels".
example
local plane = ScenEdit_GetUnit({name='panther #1', side='Iran'})
local fuel = plane.fuel

print 'Start'
print(fuel)
for i, tank in ipairs(plane.fuels) do
print("Tank #" .. i)
print(tank)
end

print 'Set '
plane = ScenEdit_SetUnit({name='panther #1', side='Iran', fuel={{2001,8200}} })
print(plane.fuel)
for i, tank in ipairs(plane.fuels) do
print("Tank #" .. i)
print(tank)
end

Start
{ [2001] = { type = 2001, current = 8500, name = 'AviationFuel', max = 10140 } }
Tank #1
{ type = 2001, current = 6065, name = 'AviationFuel', max = 6065 }
Tank #2
{ type = 2001, current = 1125, name = 'AviationFuel', max = 1125 }
Tank #3
{ type = 2001, current = 1125, name = 'AviationFuel', max = 1125 }
Tank #4
{ type = 2001, current = 185, name = 'AviationFuel', max = 1825 }

Set
{ [2001] = { type = 2001, current = 8085, name = 'AviationFuel', max = 10140 } }
Tank #1
{ type = 2001, current = 6065, name = 'AviationFuel', max = 6065 }
Tank #2
{ type = 2001, current = 1010, name = 'AviationFuel', max = 1125 }
Tank #3
{ type = 2001, current = 1010, name = 'AviationFuel', max = 1125 }
Tank #4
{ type = 2001, current = 0, name = 'AviationFuel', max = 1825 }
Michael
Post Reply

Return to “Tech Support”