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.