From b7f26e2ddca9b7e88c89210332a4b41e8d589505 Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 9 Aug 2022 19:28:30 +0200 Subject: [PATCH] Add setting to selectively disable strucutres --- mods/MAPGEN/mcl_structures/api.lua | 8 ++++++++ settingtypes.txt | 3 +++ 2 files changed, 11 insertions(+) diff --git a/mods/MAPGEN/mcl_structures/api.lua b/mods/MAPGEN/mcl_structures/api.lua index 6850255b3..c883c4d7a 100644 --- a/mods/MAPGEN/mcl_structures/api.lua +++ b/mods/MAPGEN/mcl_structures/api.lua @@ -1,5 +1,12 @@ mcl_structures.registered_structures = {} +local disabled_structures = minetest.settings:get("mcl_disabled_structures") +if disabled_structures then disabled_structures = disabled_structures:split(",") +else disabled_structures = {} end + +function mcl_structures.is_disabled(structname) + if table.indexof(disabled_structures,structname) ~= -1 then return true end +end function mcl_structures.fill_chests(p1,p2,loot,pr) for it,lt in pairs(loot) do @@ -168,6 +175,7 @@ function mcl_structures.place_structure(pos, def, pr, blockseed) end function mcl_structures.register_structure(name,def,nospawn) --nospawn means it will be placed by another (non-nospawn) structure that contains it's structblock i.e. it will not be placed by mapgen directly + if mcl_structures.is_disabled(name) then return end local structblock = "mcl_structures:structblock_"..name local flags = "place_center_x, place_center_z, force_placement" local y_offset = 0 diff --git a/settingtypes.txt b/settingtypes.txt index 35db8bde7..7c8bc651e 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -39,6 +39,9 @@ mcl_doTileDrops (Blocks have drops) bool true # If enabled, TNT explosions destroy blocks. mcl_tnt_griefing (TNT destroys blocks) bool true +# Comma separated list of disabled structure names +mcl_disabled_structures (Disabled structures) string + [Players] # If enabled, players respawn at the bed they last lay on instead of normal # spawn.