Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions migrations/replace-all-rails.lua
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions prototypes/entities.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion prototypes/locomotive.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function locomotive:update()
end
if self.burner.heat <self.burner.heat_capacity*0.1 then
local rail=global.custom_entities[(self.train.front_rail or self.train.back_rail).unit_number]
if rail and rail.accu.energy>=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
Expand Down