Skip to content

Commit

Permalink
townhall as new center
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeb187 committed Jul 8, 2018
1 parent 8a98e45 commit 8f3da44
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
10 changes: 3 additions & 7 deletions buildings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
--
Expand Down
3 changes: 2 additions & 1 deletion const.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
24 changes: 24 additions & 0 deletions utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8f3da44

Please sign in to comment.