forked from Mineclonia/Mineclonia
Fix village initialization: MineClone2/MineClone2#1206 MineClone2/MineClone2#1207 MineClone2/MineClone2#1209
This commit is contained in:
parent
2b513aa592
commit
2ce5c5415a
|
@ -175,6 +175,36 @@ end
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- evaluate settlement_info and place schematics
|
-- evaluate settlement_info and place schematics
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
-- Initialize node
|
||||||
|
local function construct_node(p1, p2, name)
|
||||||
|
local r = minetest.registered_nodes[name]
|
||||||
|
if r then
|
||||||
|
if r.on_construct then
|
||||||
|
local nodes = minetest.find_nodes_in_area(p1, p2, name)
|
||||||
|
for p=1, #nodes do
|
||||||
|
local pos = nodes[p]
|
||||||
|
r.on_construct(pos)
|
||||||
|
end
|
||||||
|
return nodes
|
||||||
|
end
|
||||||
|
minetest.log("warning","[mcl_villages] No on_construct defined for node name " .. name)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
minetest.log("warning","[mcl_villages] Attempt to 'construct' inexistant nodes: " .. name)
|
||||||
|
end
|
||||||
|
local function init_nodes(p1, p2, size, rotation, pr)
|
||||||
|
construct_node(p1, p2, "mcl_itemframes:item_frame")
|
||||||
|
construct_node(p1, p2, "mcl_furnaces:furnace")
|
||||||
|
construct_node(p1, p2, "mcl_anvils:anvil")
|
||||||
|
|
||||||
|
local nodes = construct_node(p1, p2, "mcl_chests:chest")
|
||||||
|
if nodes and #nodes > 0 then
|
||||||
|
for p=1, #nodes do
|
||||||
|
local pos = nodes[p]
|
||||||
|
settlements.fill_chest(pos, pr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
function settlements.place_schematics(settlement_info, pr)
|
function settlements.place_schematics(settlement_info, pr)
|
||||||
local building_all_info
|
local building_all_info
|
||||||
for i, built_house in ipairs(settlement_info) do
|
for i, built_house in ipairs(settlement_info) do
|
||||||
|
@ -243,6 +273,10 @@ function settlements.place_schematics(settlement_info, pr)
|
||||||
schematic,
|
schematic,
|
||||||
rotation,
|
rotation,
|
||||||
nil,
|
nil,
|
||||||
true)
|
true,
|
||||||
|
nil,
|
||||||
|
init_nodes,
|
||||||
|
pr
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -67,9 +67,6 @@ local function build_a_settlement(minp, maxp, blockseed)
|
||||||
|
|
||||||
-- evaluate settlement_info and place schematics
|
-- evaluate settlement_info and place schematics
|
||||||
settlements.place_schematics(settlement_info, pr)
|
settlements.place_schematics(settlement_info, pr)
|
||||||
|
|
||||||
-- evaluate settlement_info and initialize furnaces and chests
|
|
||||||
settlements.initialize_nodes(settlement_info, pr)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ecb_village(blockpos, action, calls_remaining, param)
|
local function ecb_village(blockpos, action, calls_remaining, param)
|
||||||
|
|
|
@ -218,43 +218,6 @@ function settlements.initialize_anvil(pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- initialize furnace, chests, anvil
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
local building_all_info
|
|
||||||
function settlements.initialize_nodes(settlement_info, pr)
|
|
||||||
for i, built_house in ipairs(settlement_info) do
|
|
||||||
for j, schem in ipairs(settlements.schematic_table) do
|
|
||||||
if settlement_info[i]["name"] == schem["name"] then
|
|
||||||
building_all_info = schem
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local width = building_all_info["hwidth"]
|
|
||||||
local depth = building_all_info["hdepth"]
|
|
||||||
local height = building_all_info["hheight"]
|
|
||||||
|
|
||||||
local p = settlement_info[i]["pos"]
|
|
||||||
for yi = 1,height do
|
|
||||||
for xi = 0,width do
|
|
||||||
for zi = 0,depth do
|
|
||||||
local ptemp = {x=p.x+xi, y=p.y+yi, z=p.z+zi}
|
|
||||||
local node = mcl_mapgen_core.get_node(ptemp)
|
|
||||||
if node.name == "mcl_furnaces:furnace" or
|
|
||||||
node.name == "mcl_chests:chest" or
|
|
||||||
node.name == "mcl_anvils:anvil" then
|
|
||||||
minetest.registered_nodes[node.name].on_construct(ptemp)
|
|
||||||
end
|
|
||||||
-- when chest is found -> fill with stuff
|
|
||||||
if node.name == "mcl_chests:chest" then
|
|
||||||
minetest.after(3, settlements.fill_chest, ptemp, pr)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
-- randomize table
|
-- randomize table
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
function shuffle(tbl, pr)
|
function shuffle(tbl, pr)
|
||||||
|
|
Loading…
Reference in New Issue