From 2d81821888021b5cde349199a9908d57f8fcbb4c Mon Sep 17 00:00:00 2001 From: Simon Ciperle Date: Wed, 25 Sep 2024 22:55:06 +0200 Subject: [PATCH] Fix: Add nil checks for manure system mixers to prevent crash in onDelete - Added checks to ensure spec_manureSystemPlaceableMixers and its mixers table are not nil before attempting to unload mixers. - This prevents potential crashes caused by attempting to iterate over a nil table. --- .../specializations/ManureSystemPlaceableMixers.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/placeables/specializations/ManureSystemPlaceableMixers.lua b/src/placeables/specializations/ManureSystemPlaceableMixers.lua index 532eddf..b5265fa 100644 --- a/src/placeables/specializations/ManureSystemPlaceableMixers.lua +++ b/src/placeables/specializations/ManureSystemPlaceableMixers.lua @@ -175,8 +175,10 @@ end ---@return void function ManureSystemPlaceableMixers:onDelete() - for _, mixer in ipairs(self.spec_manureSystemPlaceableMixers.mixers) do - self:unloadMixer(mixer) + if self.spec_manureSystemPlaceableMixers ~= nil and self.spec_manureSystemPlaceableMixers.mixers ~= nil then + for _, mixer in ipairs(self.spec_manureSystemPlaceableMixers.mixers) do + self:unloadMixer(mixer) + end end end