Problem with variable Fuel [FIXED]
Posted: Fri Mar 01, 2019 6:51 pm
Hi, I got an error message telling me :
Can't set currently burning to an item without a Fuel value.
The mod is adding Electric Train. Regular fuel can be use in the train if the rail isn't powered. Was working well on 0.16, but not in 0.17 and I don't know what to change more than that.
Faulty line :
The full function :
I'm missing something there and I don't see it 
Can't set currently burning to an item without a Fuel value.
The mod is adding Electric Train. Regular fuel can be use in the train if the rail isn't powered. Was working well on 0.16, but not in 0.17 and I don't know what to change more than that.
Faulty line :
Code: Select all
train.last_fuel['fuel'] = train.entity.burner.currently_burningCode: Select all
function OnTick()
if #global.TrainList > 0 and #global.ProviderList > 0 then
local need_power = 0
local provider_power = 0
local rest_power = 0
local split_power = 0
for i,provider in pairs(global.ProviderList) do
if provider and provider.valid then
provider_power = provider_power + provider.energy
else
table.remove(global.ProviderList,i)
end
end
if provider_power > 0 then
for i,train in pairs(global.TrainList) do
if train and train.entity and train.entity.valid then
if not train.entity.burner.currently_burning or train.entity.burner.currently_burning ~= global.Fuel then
train.last_fuel['fuel'] = train.entity.burner.currently_burning
train.last_fuel['fuel_value'] = train.entity.burner.remaining_burning_fuel
train.entity.burner.currently_burning = global.Fuel
train.entity.burner.remaining_burning_fuel = global.Fuel.fuel_value
end
need_power = need_power + global.Fuel.fuel_value - train.entity.burner.remaining_burning_fuel
else
table.remove(global.TrainList,i)
end
end
rest_power = provider_power - need_power
if rest_power >= 0 then
for _,train in pairs(global.TrainList) do
train.entity.burner.remaining_burning_fuel = global.Fuel.fuel_value
end
split_power = rest_power / #global.ProviderList
for _,provider in pairs(global.ProviderList) do
provider.energy = split_power
end
else
for _,provider in pairs(global.ProviderList) do
provider.energy = 0
end
split_power = provider_power / #global.TrainList
for _,train in pairs(global.TrainList) do
train.entity.burner.remaining_burning_fuel = train.entity.burner.remaining_burning_fuel + split_power
end
end
else
_ChangeTrainFuel()
end
else
if #global.TrainList > 0 and #global.ProviderList == 0 then
_ChangeTrainFuel()
end
end