http://i.imgur.com/lJgJyNA.png
when running this code:
Code: Select all
140: c = game.surfaces[1].create_entity{name = "car", force = game.forces.neutral, position = {x=0,y=0}}
141: c.burner.currently_burning = game.item_prototypes["coal"]
Code: Select all
140: c = game.surfaces[1].create_entity{name = "car", force = game.forces.neutral, position = {x=0,y=0}}
141: c.burner.currently_burning = game.item_prototypes["coal"]
Yes.kumpu wrote:Thanks! How would I use the string? Item prototype name?
It automatically handles reducing remaining energy if it's above the amount coal can handle. If it's at 0, then it still stays at 0 after setting it.kumpu wrote:Well either I'm missing something or this is another bug, but setting it to e.g. "coal" does not actually update LuaBurner::remaining_burning_fuel, as the docs say...
I see. So instead of a nice convenient consume() function I have to use smth like thisRseding91 wrote:It automatically handles reducing remaining energy if it's above the amount coal can handle. If it's at 0, then it still stays at 0 after setting it.
Code: Select all
self.baseEnt.burner.remaining_burning_fuel = self.baseEnt.burner.remaining_burning_fuel - baseEngineConsumption
if self.baseEnt.burner.remaining_burning_fuel <= 0 then
if self.baseEnt.burner.inventory.is_empty() then --force display the out of fuel symbol
local mod = self.baseEnt.effectivity_modifier
self.baseEnt.effectivity_modifier = 0
self.baseEnt.passenger.riding_state = {acceleration = defines.riding.acceleration.accelerating, direction = defines.riding.direction.straight}
self.baseEnt.effectivity_modifier = mod
else
local fuelItemStack = nil
for i = 1, #self.baseEnt.burner.inventory do
if self.baseEnt.burner.inventory[i] and self.baseEnt.burner.inventory[i].valid_for_read then
fuelItemStack = self.baseEnt.burner.inventory[i]
break
end
end
if fuelItemStack then
self.baseEnt.burner.currently_burning = fuelItemStack.prototype.name
self.baseEnt.burner.remaining_burning_fuel = fuelItemStack.prototype.fuel_value
self.baseEnt.burner.inventory.remove({name = fuelItemStack.name})
end
end
end
Right, thanksRseding91 wrote:A small thing: "fuelItemStack.prototype.name" can just be "fuelItemStack.name"