From fca259c0748630e5dd259881a168fabec073da61 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 22 May 2022 01:51:03 +0200 Subject: [PATCH] fix crash during (artificial) village creation when using the village tool doing that on an unsuitable location would result in no position for the belltower being available this checks for that and ... doesn't crash then ^^ --- mods/MAPGEN/mcl_villages/buildings.lua | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/mods/MAPGEN/mcl_villages/buildings.lua b/mods/MAPGEN/mcl_villages/buildings.lua index c9fc87ed4..9038769fd 100644 --- a/mods/MAPGEN/mcl_villages/buildings.lua +++ b/mods/MAPGEN/mcl_villages/buildings.lua @@ -237,18 +237,20 @@ function settlements.place_schematics(settlement_info, pr) --attempt to place one belltower in the center of the village - this doesn't always work out great but it's a lot better than doing it first or last. local belltower = table.remove(settlement_info,math.floor(#settlement_info/2)) - mcl_structures.place_schematic( - vector.offset(belltower["pos"],0,1,0), - settlements.modpath.."/schematics/belltower.mts", - belltower["rotation"], - nil, - true, - nil, - function(p1, p2, size, rotation, pr) - spawn_iron_golem(p1) - end, - pr - ) + if belltower then + mcl_structures.place_schematic( + vector.offset(belltower["pos"],0,0,0), + settlements.modpath.."/schematics/belltower.mts", + belltower["rotation"], + nil, + true, + nil, + function(p1, p2, size, rotation, pr) + spawn_iron_golem(p1) + end, + pr + ) + end for i, built_house in ipairs(settlement_info) do local is_last = i == #settlement_info