From aced2d78791c66b99d4e708221c9dd413f2ec356 Mon Sep 17 00:00:00 2001 From: Hermios Date: Tue, 28 May 2024 15:41:07 +0300 Subject: [PATCH 1/2] update energy available per accu. Allow set to loco as soon as accu as energy available --- prototypes/entities.lua | 6 +++--- prototypes/locomotive.lua | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/prototypes/entities.lua b/prototypes/entities.lua index 37fa0ef..ce95b30 100644 --- a/prototypes/entities.lua +++ b/prototypes/entities.lua @@ -107,12 +107,12 @@ createdata("electric-energy-interface","electric-energy-interface",rail_electric flags = {"not-on-map","placeable-off-grid","not-blueprintable","not-deconstructable"}, energy_production = "0W", energy_usage = "0W", - electric_buffer_size="20KJ", + electric_buffer_size="1MJ", energy_source = { type = "electric", - buffer_capacity = "20KJ", - input_flow_limit = "20KJ", + buffer_capacity = "1MJ", + input_flow_limit = "1MJ", drain = "0J", usage_priority = "primary-input", output_flow_limit = "0J", diff --git a/prototypes/locomotive.lua b/prototypes/locomotive.lua index 414b7be..05e89f6 100644 --- a/prototypes/locomotive.lua +++ b/prototypes/locomotive.lua @@ -17,7 +17,7 @@ function locomotive:update() end if self.burner.heat =self.ratio_fuel then + if rail and rail.accu.energy>0 then local required_energy=self.burner.heat_capacity*0.99-self.burner.heat local power_transfer = math.min(rail.accu.energy,required_energy) self.burner.heat=self.burner.heat+power_transfer From 9edcc34e56f888aa21e7b26533ee665667018779 Mon Sep 17 00:00:00 2001 From: Hermios Date: Tue, 28 May 2024 16:36:41 +0300 Subject: [PATCH 2/2] add migration for update of locos --- migrations/replace-all-rails.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 migrations/replace-all-rails.lua diff --git a/migrations/replace-all-rails.lua b/migrations/replace-all-rails.lua new file mode 100644 index 0000000..4d7a5c5 --- /dev/null +++ b/migrations/replace-all-rails.lua @@ -0,0 +1,21 @@ +require "constants" +require "prototypes.rail-power" +require "__Hermios_Framework__.control-libs" +for _,entity in pairs(global.custom_entities or {}) do + if entity.name==straight_rail_power or entity.name==curved_rail_power then + local direction=entity.direction + local force=entity.force + local surface=entity.surface + local position=entity.position + local name=entity.name + custom_prototype=custom_prototypes[entity.prototype_index] + setmetatable(entity,custom_prototype) + custom_prototype.__index=custom_prototype + + global.custom_entities[entity.unit_number].on_removed() + global.custom_entities[entity.unit_number]=nil + entity.destroy() + local rail=surface.create_entity{name=name,force=force,position=position,direction=direction} + on_built(rail) + end +end \ No newline at end of file