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

Post your bugs and problems so we can fix them.
Post Reply
User avatar
wasmoo
Manual Inserter
Manual Inserter
Posts: 3
Joined: Mon Apr 27, 2020 11:57 am
Contact:

[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
}
}

Post Reply

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users