Fix common.is_surface
This commit is contained in:
parent
04fbdf540c
commit
721f6f271f
1 changed files with 7 additions and 4 deletions
|
@ -566,10 +566,13 @@ return function(mod_name)
|
||||||
-- Check if argument is a valid surface
|
-- Check if argument is a valid surface
|
||||||
common.is_surface = function(surface)
|
common.is_surface = function(surface)
|
||||||
local t = type(surface)
|
local t = type(surface)
|
||||||
surface = (t == "number" or t == "string" and game.surfaces[surface]) or
|
local result = false
|
||||||
(t == "table" and surface.object_name and
|
if (t == "number" or t == "string") and game.surfaces[surface] and game.surfaces[surface].valid then
|
||||||
surface.object_name == "LuaSurface" and surface)
|
result = game.surfaces[surface]
|
||||||
return surface
|
elseif surface and surface.object_name == "LuaSurface" and surface.valid then
|
||||||
|
result = surface
|
||||||
|
end
|
||||||
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue