From 8f3da4406fed789a008185f390be9e9a2a8e3429 Mon Sep 17 00:00:00 2001 From: Rochambeau Date: Sun, 8 Jul 2018 19:16:04 +0200 Subject: [PATCH] townhall as new center --- buildings.lua | 10 +++------- const.lua | 3 ++- utils.lua | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/buildings.lua b/buildings.lua index cdd3679..a0c887c 100644 --- a/buildings.lua +++ b/buildings.lua @@ -35,14 +35,10 @@ function settlements.build_schematic(pos, building, replace_wall, name) local rotation = possible_rotations[ math.random( #possible_rotations ) ] settlements.foundation(pos, width, depth, height, rotation) -- place schematic - minetest.after(3, function() + minetest.after(4, function() minetest.place_schematic(pos, schematic, rotation, nil, true) - -- fill chest - if name == "hut" then - minetest.after(2,settlements.fill_chest,pos) - elseif name == "blacksmith" then - minetest.after(2,settlements.initialize_furnace,pos) - end + -- initialize special nodes (chests, furnace) + minetest.after(2,settlements.initialize_nodes, pos, width, depth, height) end) end -- diff --git a/const.lua b/const.lua index fb8d776..e142067 100644 --- a/const.lua +++ b/const.lua @@ -21,7 +21,8 @@ schem_path = settlements.modpath.."/schematics/" -- list of schematics -- schematic_table = { - {name = "well", mts = schem_path.."well.mts", hsize = 11, max_num = 0, rplc = "n"}, + {name = "townhall", mts = schem_path.."townhall.mts", hsize = 20, max_num = 0, rplc = "n"}, + {name = "well", mts = schem_path.."well.mts", hsize = 11, max_num = 0.055, rplc = "n"}, {name = "hut", mts = schem_path.."hut.mts", hsize = 11, max_num = 0.9, rplc = "y"}, {name = "garden", mts = schem_path.."garden.mts", hsize = 11, max_num = 0.1, rplc = "n"}, {name = "lamp", mts = schem_path.."lamp.mts", hsize = 10, max_num = 0.1, rplc = "n"}, diff --git a/utils.lua b/utils.lua index 0bdf96c..bdcee97 100644 --- a/utils.lua +++ b/utils.lua @@ -141,6 +141,30 @@ function settlements.initialize_furnace(pos) end end -- +-- initialize furnace, chests, bookshelves +-- +function settlements.initialize_nodes(pos, width, depth, height) + local p = settlements.shallowCopy(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 = minetest.get_node(ptemp) + if node.name == "default:furnace" or + node.name == "default:chest" or + node.name == "default:bookshelf" + then + minetest.registered_nodes[node.name].on_construct(ptemp) + end + -- when chest is found -> fill with stuff + if node.name == "default:chest" then + minetest.after(3,settlements.fill_chest,pos) + end + end + end + end +end +-- -- randomize table -- function shuffle(tbl)