From 6b8236e8f3ece5f2b24ba741fc2f4ce26e7d0fb1 Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 28 Oct 2022 13:34:58 +0200 Subject: [PATCH] Fix crash in villagegen --- mods/CORE/mcl_util/init.lua | 1 + mods/MAPGEN/mcl_structures/api.lua | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index 58285039a..0972e5019 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -23,6 +23,7 @@ function table.update_nil(t, ...) end function mcl_util.file_exists(name) + if type(name) ~= "string" then return end local f = io.open(name) if not f then return false diff --git a/mods/MAPGEN/mcl_structures/api.lua b/mods/MAPGEN/mcl_structures/api.lua index 719beebd8..6a7fc2c39 100644 --- a/mods/MAPGEN/mcl_structures/api.lua +++ b/mods/MAPGEN/mcl_structures/api.lua @@ -32,8 +32,8 @@ local function ecb_place(blockpos, action, calls_remaining, param) end function mcl_structures.place_schematic(pos, schematic, rotation, replacements, force_placement, flags, after_placement_callback, pr, callback_param) - if not mcl_util.file_exists(schematic) then - minetest.log("warning","[mcl_structures] schematic file "..schematic.." does not exist.") + if type(schematic) ~= "table" and not mcl_util.file_exists(schematic) then + minetest.log("warning","[mcl_structures] schematic file "..tostring(schematic).." does not exist.") return end local s = loadstring(minetest.serialize_schematic(schematic, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}) .. " return schematic")() if s and s.size then