townhall as new center

master
Rochambeau 2018-07-08 19:16:04 +02:00
parent 8a98e4566e
commit 8f3da4406f
3 changed files with 29 additions and 8 deletions

View File

@ -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
--

View File

@ -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"},

View File

@ -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)