From 19ef9e698b5ec7993212db3f5fd702ef8d52faaf Mon Sep 17 00:00:00 2001 From: Hermios Date: Wed, 21 Feb 2024 19:50:12 +0200 Subject: [PATCH] add case for rail not valid. remove condition on locomotive in front --- prototypes/locomotive.lua | 2 +- prototypes/rail-power.lua | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/prototypes/locomotive.lua b/prototypes/locomotive.lua index e945663..b1af1e4 100644 --- a/prototypes/locomotive.lua +++ b/prototypes/locomotive.lua @@ -12,7 +12,7 @@ function locomotive:new(entity) end function locomotive:update() - if not self.entity.valid or not self.entity.is_headed_to_trains_front then + if not self.entity.valid then return end local required_fuel=self.stack_size-self.entity.get_item_count() diff --git a/prototypes/rail-power.lua b/prototypes/rail-power.lua index cc1285f..ae23ea6 100644 --- a/prototypes/rail-power.lua +++ b/prototypes/rail-power.lua @@ -36,6 +36,9 @@ function railprototype:on_built() end function railprototype:connect() + if not self.entity or not self.entity.valid then + return + end self.electricnode.disconnect_neighbour() --connect to other rails for _,rail in pairs(self:get_connected_powerrails()) do