rotate foundation

master
Rochambeau 2018-07-04 21:15:43 +02:00
parent 3739ba62b1
commit 863d79debb
3 changed files with 19 additions and 8 deletions

View File

@ -5,7 +5,7 @@ local schematic_table = {
lamp = {name = "lamp", mts = schem_path.."lamp.mts", hsize = 7, max_num = 0.2, rplc = "n"},
tower = {name = "tower", mts = schem_path.."tower.mts", hsize = 10, max_num = 0.2, rplc = "n"},
well = {name = "well", mts = schem_path.."well.mts", hsize = 10, max_num = 0, rplc = "n"},
church = {name = "church", mts = schem_path.."church.mts", hsize = 13, max_num = 0.1, rplc = "n"}
church = {name = "church", mts = schem_path.."church.mts", hsize = 14, max_num = 0.1, rplc = "n"}
}
local count_buildings ={}
-- iterate over whole table to get all keys
@ -36,10 +36,12 @@ function settlements.build_schematic(pos, building, replace_wall, name)
local width = schematic["size"]["x"]
local depth = schematic["size"]["z"]
local height = schematic["size"]["y"]
settlements.foundation(pos, width, depth, height)
local possible_rotations = {"0", "90", "180", "270"}
local rotation = possible_rotations[ math.random( #possible_rotations ) ]
settlements.foundation(pos, width, depth, height, rotation)
-- place schematic
minetest.after(2, function()
minetest.place_schematic(pos, schematic, "random", nil, true)
minetest.place_schematic(pos, schematic, rotation, nil, true)
-- fill chest
if name == "hut" then
minetest.after(2,settlements.fill_chest,pos)

View File

@ -17,12 +17,21 @@ end
--
-- Function to fill empty space below baseplate when building on a hill
--
function settlements.foundation(pos, width, depth, height)
function settlements.foundation(pos, width, depth, height, rotation)
local p5 = settlements.shallowCopy(pos)
local height = height * 3 -- remove trees and leaves above
for yi = 0,height do
for xi = 0,width-1 do
for zi = 0,depth-1 do
local fheight = height * 3 -- remove trees and leaves above
local fwidth
local fdepth
if rotation == "0" or rotation == "180" then
fwidth = width
fdepth = depth
else
fwidth = depth
fdepth = width
end
for yi = 0,fheight do
for xi = 0,fwidth-1 do
for zi = 0,fdepth-1 do
if yi == 0 then
local p = {x=p5.x+xi, y=p5.y, z=p5.z+zi}
minetest.after(1,settlements.ground,p)--(p)

Binary file not shown.