1
0
Fork 0

initial daughter structure support

This commit is contained in:
cora 2022-10-24 07:07:56 +02:00
parent 24476caf7e
commit f76e0628e4
3 changed files with 46 additions and 8 deletions

View File

@ -19,7 +19,6 @@ mcl_structures.register_structure("nether_outpost",{
after_place = function(pos) after_place = function(pos)
local sp = minetest.find_nodes_in_area(pos,vector.offset(pos,0,20,0),{"mcl_mobspawners:spawner"}) local sp = minetest.find_nodes_in_area(pos,vector.offset(pos,0,20,0),{"mcl_mobspawners:spawner"})
if not sp[1] then return end if not sp[1] then return end
table.shuffle(sp)
mcl_mobspawners.setup_spawner(sp[1], "mobs_mc:blaze", 0, minetest.LIGHT_MAX+1, 10, 8, 0) mcl_mobspawners.setup_spawner(sp[1], "mobs_mc:blaze", 0, minetest.LIGHT_MAX+1, 10, 8, 0)
end end
}) })
@ -37,6 +36,9 @@ mcl_structures.register_structure("nether_bulwark",{
filenames = { filenames = {
modpath.."/schematics/mcl_nether_fortresses_nether_bulwark.mts" modpath.."/schematics/mcl_nether_fortresses_nether_bulwark.mts"
}, },
daughters = {
[modpath.."/schematics/mcl_nether_fortresses_nether_bulwark_interior_1.mts"] = vector.new(5,0,5),
},
y_offset = 0, y_offset = 0,
construct_nodes = {"group:wall"}, construct_nodes = {"group:wall"},
after_place = function(pos,def,pr) after_place = function(pos,def,pr)

View File

@ -1,5 +1,11 @@
mcl_structures.registered_structures = {} mcl_structures.registered_structures = {}
local rotations = {
"0",
"90",
"180",
"270"
}
local place_queue = {}
local disabled_structures = minetest.settings:get("mcl_disabled_structures") local disabled_structures = minetest.settings:get("mcl_disabled_structures")
if disabled_structures then disabled_structures = disabled_structures:split(",") if disabled_structures then disabled_structures = disabled_structures:split(",")
else disabled_structures = {} end else disabled_structures = {} end
@ -206,7 +212,19 @@ local function foundation(ground_p1,ground_p2,pos,sidelen)
minetest.bulk_set_node(stone,{name=node_stone}) minetest.bulk_set_node(stone,{name=node_stone})
end end
function mcl_structures.place_structure(pos, def, pr, blockseed,rot) local function process_queue()
if #place_queue < 1 then return end
local s = table.remove(place_queue)
mcl_structures.place_schematic(s.pos, s.file, s.rot, nil, true, "place_center_x,place_center_z",function(s)
if s.after_place then
s.after_place(s.pos,s.def,s.pr)
end
end,s.pr)
minetest.after(0.5,process_queue)
end
function mcl_structures.place_structure(pos, def, pr, blockseed)
if not def then return end if not def then return end
if not rot then rot = "random" end if not rot then rot = "random" end
local log_enabled = logging and not def.terrain_feature local log_enabled = logging and not def.terrain_feature
@ -244,13 +262,31 @@ function mcl_structures.place_structure(pos, def, pr, blockseed,rot)
local r = pr:next(1,#def.filenames) local r = pr:next(1,#def.filenames)
local file = def.filenames[r] local file = def.filenames[r]
if file then if file then
local rot = rotations[pr:next(1,#rotations)]
local ap = function(pos,def,pr,blockseed) end local ap = function(pos,def,pr,blockseed) end
if def.after_place then ap = def.after_place end
if def.daughters then
for fn,p in pairs(def.daughters) do
local p = vector.add(pp,p)
ap = function(pos,def,pr,blockseed)
mcl_structures.place_schematic(pos, fn, rot, nil, true, "place_center_x,place_center_z",function()
if def.loot then generate_loot(pp,def,pr,blockseed) end
if def.construct_nodes then construct_nodes(pp,def,pr,blockseed) end
if def.after_place then
def.after_place(pos,def,pr)
end
--ap(pos,def,pr,blockseed)
end,pr)
end
end
elseif def.after_place then ap = def.after_place
end
mcl_structures.place_schematic(pp, file, rot, def.replacements, true, "place_center_x,place_center_z",function(p1, p2, size, rotation) mcl_structures.place_schematic(pp, file, rot, def.replacements, true, "place_center_x,place_center_z",function(p1, p2, size, rotation)
if not def.daughters then
if def.loot then generate_loot(pp,def,pr,blockseed) end if def.loot then generate_loot(pp,def,pr,blockseed) end
if def.construct_nodes then construct_nodes(pp,def,pr,blockseed) end if def.construct_nodes then construct_nodes(pp,def,pr,blockseed) end
return ap(pp,def,pr,blockseed,p1,p2,size,rotation) return ap(pp,def,pr,blockseed,p1,p2,size,rotation)
end
end,pr) end,pr)
if log_enabled then if log_enabled then
minetest.log("action","[mcl_structures] "..def.name.." placed at "..minetest.pos_to_string(pp)) minetest.log("action","[mcl_structures] "..def.name.." placed at "..minetest.pos_to_string(pp))