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 ^^
This commit is contained in:
cora 2022-05-22 01:51:03 +02:00
parent 7379d5bee8
commit fca259c074

View File

@ -237,8 +237,9 @@ 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. --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)) local belltower = table.remove(settlement_info,math.floor(#settlement_info/2))
if belltower then
mcl_structures.place_schematic( mcl_structures.place_schematic(
vector.offset(belltower["pos"],0,1,0), vector.offset(belltower["pos"],0,0,0),
settlements.modpath.."/schematics/belltower.mts", settlements.modpath.."/schematics/belltower.mts",
belltower["rotation"], belltower["rotation"],
nil, nil,
@ -249,6 +250,7 @@ function settlements.place_schematics(settlement_info, pr)
end, end,
pr pr
) )
end
for i, built_house in ipairs(settlement_info) do for i, built_house in ipairs(settlement_info) do
local is_last = i == #settlement_info local is_last = i == #settlement_info