From 721f6f271fa62ba8cd18466e22f02540c3145414 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Sun, 6 Jul 2025 10:58:08 +0200 Subject: [PATCH] Fix common.is_surface --- Bio_Industries_2/common.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Bio_Industries_2/common.lua b/Bio_Industries_2/common.lua index 0cbceff..24cb6e6 100644 --- a/Bio_Industries_2/common.lua +++ b/Bio_Industries_2/common.lua @@ -566,10 +566,13 @@ return function(mod_name) -- Check if argument is a valid surface common.is_surface = function(surface) local t = type(surface) - surface = (t == "number" or t == "string" and game.surfaces[surface]) or - (t == "table" and surface.object_name and - surface.object_name == "LuaSurface" and surface) - return surface + local result = false + if (t == "number" or t == "string") and game.surfaces[surface] and game.surfaces[surface].valid then + result = game.surfaces[surface] + elseif surface and surface.object_name == "LuaSurface" and surface.valid then + result = surface + end + return result end