Skip to content

Commit

Permalink
rotate foundation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeb187 committed Jul 4, 2018
1 parent 3739ba6 commit 863d79d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
8 changes: 5 additions & 3 deletions buildings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
19 changes: 14 additions & 5 deletions foundation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Binary file modified schematics/church.mts
Binary file not shown.

0 comments on commit 863d79d

Please sign in to comment.