[Rseding91] [0.18.36] Energy lost when setting energy on a heat buffer

This subforum contains all the issues which we already resolved.
User avatar
wasmoo
Burner Inserter
Burner Inserter
Posts: 9
Joined: Mon Apr 27, 2020 11:57 am
Contact:

[Rseding91] [0.18.36] Energy lost when setting energy on a heat buffer

Post by wasmoo »

I created a mod that adds heat-powered buildings. When I attempted to set the energy level of one of these buildings, the power value was set to 0, and the temperature was reduced to the min_working_temperature. (Setting temperature worked fine.)

Here's a minimalist example:

Code: Select all

-- data.lua
local heat_machine = table.deepcopy(data.raw["assembling-machine"]["assembling-machine-3"])
heat_machine.name = "heat-machine"
heat_machine.energy_source = table.deepcopy(data.raw["boiler"]["heat-exchanger"].energy_source)
data:extend{heat_machine}

Code: Select all

-- control.lua

local function on_tick(e)
  local entities = game.surfaces[1].find_entities_filtered({name="heat-machine"})
  for _, entity in ipairs(entities) do
    local before = {
      temperature = entity.temperature,
      power = entity.energy,
    }
    entity.energy = entity.energy + 100 -- THIS DOESN'T WORK
    local after ={
      temperature = entity.temperature,
      power = entity.energy,
    }
    log(serpent.block{
      before = before,
      after = after,
    })
  end

end

script.on_init(function()
  script.on_event(defines.events.on_tick, on_tick)
end)

In game, I place the entity using the console:

Code: Select all

/c game.surfaces[1].create_entity{name="heat-machine",position={0,0}}
The log output looks like this:
after = {
power = 0,
temperature = 500
},
before = {
power = 0,
temperature = 500
}
}
Rseding91
Factorio Staff
Factorio Staff
Posts: 14250
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.18.36] Energy lost when setting energy on a heat buffer

Post by Rseding91 »

Thanks for the report. It's now fixed for the next release.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Resolved Problems and Bugs”