Question about defines.entity_status.no_fuel
Posted: Fri Apr 21, 2023 6:52 pm
I've got a tank which has an empty fuel directory and is not burning any fuel. There is a no-fuel icon indicating that the tank, indeed, has no fuel. But when I print the tank's status with
I get
Why does that happen? Is defines.entity_status.no_fuel not supposed to work with vehicles? In the API description, most states come with a description like "Used by generators and solar panels", but no such limitation is given for no_fuel, so I'd expected this to work with all entities that could consume fuel -- including car prototypes.
If this is working as intended, how can I determine whether a vehicle (car and spider-vehicle prototypes) has no fuel left? Checking for an empty fuel inventory is trivial, the hard part is the fuel currently burned (shown by the bar next to the fuel inventory slots).
Use case: My mod sends unarmed vehicles into a panic mode when enemies are near, so they speed off into a random direction. But that doesn't make sense for vehicles that are completely out of fuel. Deciding that a vehicle has no fuel based solely on whether its fuel inventory is empty doesn't make sense because some fuel (nuclear, rocket etc.) lasts for an incredibly long time. So, a tank could still cover some considerable distance with 20% of a rocket-fuel cell left for burning -- even if the fuel inventory was empty.
Code: Select all
/c v = game.player.vehicle; states = {};
for name, id in pairs(defines.entity_status) do states[id] = name end
game.print("Status: "..states[v.status])
Code: Select all
Status: working
If this is working as intended, how can I determine whether a vehicle (car and spider-vehicle prototypes) has no fuel left? Checking for an empty fuel inventory is trivial, the hard part is the fuel currently burned (shown by the bar next to the fuel inventory slots).
Use case: My mod sends unarmed vehicles into a panic mode when enemies are near, so they speed off into a random direction. But that doesn't make sense for vehicles that are completely out of fuel. Deciding that a vehicle has no fuel based solely on whether its fuel inventory is empty doesn't make sense because some fuel (nuclear, rocket etc.) lasts for an incredibly long time. So, a tank could still cover some considerable distance with 20% of a rocket-fuel cell left for burning -- even if the fuel inventory was empty.