rotate foundation
This commit is contained in:
parent
3739ba62b1
commit
863d79debb
@ -5,7 +5,7 @@ local schematic_table = {
|
|||||||
lamp = {name = "lamp", mts = schem_path.."lamp.mts", hsize = 7, max_num = 0.2, rplc = "n"},
|
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"},
|
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"},
|
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 ={}
|
local count_buildings ={}
|
||||||
-- iterate over whole table to get all keys
|
-- 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 width = schematic["size"]["x"]
|
||||||
local depth = schematic["size"]["z"]
|
local depth = schematic["size"]["z"]
|
||||||
local height = schematic["size"]["y"]
|
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
|
-- place schematic
|
||||||
minetest.after(2, function()
|
minetest.after(2, function()
|
||||||
minetest.place_schematic(pos, schematic, "random", nil, true)
|
minetest.place_schematic(pos, schematic, rotation, nil, true)
|
||||||
-- fill chest
|
-- fill chest
|
||||||
if name == "hut" then
|
if name == "hut" then
|
||||||
minetest.after(2,settlements.fill_chest,pos)
|
minetest.after(2,settlements.fill_chest,pos)
|
||||||
|
@ -17,12 +17,21 @@ end
|
|||||||
--
|
--
|
||||||
-- Function to fill empty space below baseplate when building on a hill
|
-- 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 p5 = settlements.shallowCopy(pos)
|
||||||
local height = height * 3 -- remove trees and leaves above
|
local fheight = height * 3 -- remove trees and leaves above
|
||||||
for yi = 0,height do
|
local fwidth
|
||||||
for xi = 0,width-1 do
|
local fdepth
|
||||||
for zi = 0,depth-1 do
|
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
|
if yi == 0 then
|
||||||
local p = {x=p5.x+xi, y=p5.y, z=p5.z+zi}
|
local p = {x=p5.x+xi, y=p5.y, z=p5.z+zi}
|
||||||
minetest.after(1,settlements.ground,p)--(p)
|
minetest.after(1,settlements.ground,p)--(p)
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user