fixed in control.lua
local function consume_fuel_or_equipment (unit)
if unit.vehicle.grid and unit.vehicle.grid.available_in_batteries > 10000 then
--Added by Undarl; basic battery fueling logic courtesy of Sirenfal
---Modified by the Nexela
local player = game.players[1]
player.print("consume_fuel_or_equipment")
unit.vehicle.burner.currently_burning = high_fuel_item
local energy_deficit = game.item_prototypes[high_fuel_item].fuel_value - unit.vehicle.burner.remaining_burning_fuel
local batteries = table.filter(unit.vehicle.grid.equipment, function(v) return v.type == "battery-equipment" end)
if batteries then player.print("batteries is present(" .. #batteries .. ") energy = " .. unit.vehicle.grid.available_in_batteries) end
local num_batteries = #batteries
while num_batteries > 0 and energy_deficit > 0 do
local battery = batteries[num_batteries]
local energy_used = math.min(battery.energy, energy_deficit)
player.print("energy_deficit(" .. energy_deficit .. ") energy battery = " .. battery.energy)
player.print("energy_used(" .. energy_used .. ")")
battery.energy = battery.energy - energy_used
unit.vehicle.burner.remaining_burning_fuel = unit.vehicle.burner.remaining_burning_fuel + energy_used
energy_deficit = energy_deficit - energy_used
num_batteries = num_batteries - 1
end
else
for _, inv_num in pairs(inv_nums) do
local inventory = unit.vehicle.get_inventory(inv_num)
if inventory then
local contents = inventory.get_contents()
local fuel_item = get_fuel.item(contents)
if fuel_item then
if inv_num ~= defines.inventory.fuel then
if contents[fuel_item.name] > 1 then
-- move fuel to fuel inventory
unit.vehicle.burner.currently_burning = fuel_item.name
unit.vehicle.burner.remaining_burning_fuel = unit.vehicle.burner.remaining_burning_fuel + fuel_item.fuel_value
local fuel_inv = unit.vehicle.get_inventory(defines.inventory.fuel)
local inserted = fuel_inv.insert{name = fuel_item.name, count = contents[fuel_item.name] -1}
if inserted > 0 then
inventory.remove({name = fuel_item.name, count = inserted})
end
else
unit.vehicle.burner.currently_burning = fuel_item.name
unit.vehicle.burner.remaining_burning_fuel = unit.vehicle.burner.remaining_burning_fuel + fuel_item.fuel_value
inventory.remove({name=fuel_item.name, count=1})
end
else
-- burning from correct slot
unit.vehicle.burner.currently_burning = fuel_item.name
unit.vehicle.burner.remaining_burning_fuel = unit.vehicle.burner.remaining_burning_fuel + fuel_item.fuel_value
inventory.remove({name=fuel_item.name, count=1})
return true
end
end
end
end
end
end