2018-07-29 11:41:28 -07:00
|
|
|
-------------------------------------------------------------------------------
|
2018-07-07 04:39:28 -07:00
|
|
|
-- function to fill empty space below baseplate when building on a hill
|
2018-07-29 11:41:28 -07:00
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
function settlements.ground_lvm(pos) -- role model: Wendelsteinkircherl, Brannenburg
|
2018-07-21 11:31:29 -07:00
|
|
|
local c_dirt = minetest.get_content_id("default:dirt")
|
|
|
|
local c_stone = minetest.get_content_id("default:stone")
|
|
|
|
--
|
2018-07-29 11:41:28 -07:00
|
|
|
local p2 = settlements.shallowCopy(pos)
|
2018-06-26 11:08:14 -07:00
|
|
|
local cnt = 0
|
2018-07-21 11:31:29 -07:00
|
|
|
local mat = c_dirt
|
2018-06-26 11:08:14 -07:00
|
|
|
p2.y = p2.y-1
|
2018-06-26 11:23:11 -07:00
|
|
|
while true do
|
2018-06-26 11:08:14 -07:00
|
|
|
cnt = cnt+1
|
2018-07-21 10:41:20 -07:00
|
|
|
if cnt > 20 then break end
|
2018-07-21 11:31:29 -07:00
|
|
|
if cnt>math.random(2,4) then mat = c_stone end
|
|
|
|
--minetest.swap_node(p2, {name="default:"..mat})
|
|
|
|
local vi = va:index(p2.x, p2.y, p2.z)
|
|
|
|
data[vi] = mat
|
2018-06-26 11:08:14 -07:00
|
|
|
p2.y = p2.y-1
|
|
|
|
end
|
2018-07-29 11:41:28 -07:00
|
|
|
-- return data
|
2018-06-26 11:08:14 -07:00
|
|
|
end
|
2018-07-29 11:41:28 -07:00
|
|
|
-------------------------------------------------------------------------------
|
2018-07-07 04:39:28 -07:00
|
|
|
-- function to fill empty space below baseplate when building on a hill
|
2018-07-29 11:41:28 -07:00
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
function settlements.ground(pos) -- role model: Wendelsteinkircherl, Brannenburg
|
|
|
|
local p2 = settlements.shallowCopy(pos)
|
|
|
|
local cnt = 0
|
|
|
|
local mat = "default:dirt"
|
|
|
|
p2.y = p2.y-1
|
|
|
|
while true do
|
|
|
|
cnt = cnt+1
|
|
|
|
if cnt > 20 then break end
|
|
|
|
if cnt>math.random(2,4)
|
|
|
|
then
|
|
|
|
mat = "default:stone"
|
|
|
|
end
|
|
|
|
minetest.swap_node(p2, {name=mat})
|
|
|
|
p2.y = p2.y-1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
-- function clear space above baseplate
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
function settlements.terraform_lvm()
|
2018-07-21 11:31:29 -07:00
|
|
|
local c_air = minetest.get_content_id("air")
|
2018-07-29 11:41:28 -07:00
|
|
|
local fheight
|
2018-07-04 12:15:43 -07:00
|
|
|
local fwidth
|
|
|
|
local fdepth
|
2018-07-29 11:41:28 -07:00
|
|
|
|
|
|
|
|
|
|
|
for i, built_house in ipairs(settlement_info) do
|
|
|
|
-- pick right schematic_info to current built_house
|
|
|
|
for j, schem in ipairs(schematic_table) do
|
|
|
|
if settlement_info[i]["name"] == schem["name"]
|
|
|
|
then
|
|
|
|
schematic_data = schem
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local pos = settlement_info[i]["pos"]
|
|
|
|
if settlement_info[i]["rotat"] == "0" or settlement_info[i]["rotat"] == "180"
|
|
|
|
then
|
|
|
|
fwidth = schematic_data["hwidth"]
|
|
|
|
fdepth = schematic_data["hdepth"]
|
|
|
|
else
|
|
|
|
fwidth = schematic_data["hdepth"]
|
|
|
|
fdepth = schematic_data["hwidth"]
|
|
|
|
end
|
|
|
|
fheight = schematic_data["hheight"] * 3 -- remove trees and leaves above
|
|
|
|
--
|
|
|
|
-- now that every info is available -> create platform and clear space above
|
|
|
|
--
|
|
|
|
for zi = 0,fdepth-1 do
|
|
|
|
for yi = 0,fheight do
|
|
|
|
for xi = 0,fwidth-1 do
|
|
|
|
if yi == 0 then
|
|
|
|
local p = {x=pos.x+xi, y=pos.y, z=pos.z+zi}
|
|
|
|
settlements.ground_lvm(p)
|
|
|
|
else
|
|
|
|
--break --todo
|
|
|
|
-- write ground
|
|
|
|
local vi = va:index(pos.x+xi, pos.y+yi, pos.z+zi)
|
|
|
|
if data[vi] ~= c_air
|
|
|
|
--local node = minetest.get_node_or_nil({x=p5.x+xi, y=p5.y+yi, z=p5.z+zi})
|
|
|
|
--if node then
|
|
|
|
--if node.name ~= "air"
|
|
|
|
then
|
|
|
|
--minetest.swap_node({x=pos.x+xi, y=pos.y+yi, z=pos.z+zi},{name="air"})
|
|
|
|
data[vi] = c_air
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-04 12:15:43 -07:00
|
|
|
end
|
2018-07-29 11:41:28 -07:00
|
|
|
end
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
-- function clear space above baseplate
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
function settlements.terraform()
|
|
|
|
local fheight
|
|
|
|
local fwidth
|
|
|
|
local fdepth
|
|
|
|
|
|
|
|
for i, built_house in ipairs(settlement_info) do
|
|
|
|
-- pick right schematic_info to current built_house
|
|
|
|
for j, schem in ipairs(schematic_table) do
|
|
|
|
if settlement_info[i]["name"] == schem["name"]
|
|
|
|
then
|
|
|
|
schematic_data = schem
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local pos = settlement_info[i]["pos"]
|
|
|
|
if settlement_info[i]["rotat"] == "0" or settlement_info[i]["rotat"] == "180"
|
|
|
|
then
|
|
|
|
fwidth = schematic_data["hwidth"]
|
|
|
|
fdepth = schematic_data["hdepth"]
|
|
|
|
else
|
|
|
|
fwidth = schematic_data["hdepth"]
|
|
|
|
fdepth = schematic_data["hwidth"]
|
|
|
|
end
|
2018-07-30 11:54:36 -07:00
|
|
|
--fheight = schematic_data["hheight"] * 3 -- remove trees and leaves above
|
|
|
|
fheight = schematic_data["hheight"] -- remove trees and leaves above
|
2018-07-29 11:41:28 -07:00
|
|
|
--
|
|
|
|
-- now that every info is available -> create platform and clear space above
|
|
|
|
--
|
2018-07-04 12:15:43 -07:00
|
|
|
for xi = 0,fwidth-1 do
|
|
|
|
for zi = 0,fdepth-1 do
|
2018-07-30 11:54:36 -07:00
|
|
|
for yi = 0,fheight *3 do
|
2018-07-29 11:41:28 -07:00
|
|
|
if yi == 0 then
|
|
|
|
local p = {x=pos.x+xi, y=pos.y, z=pos.z+zi}
|
|
|
|
settlements.ground(p)
|
|
|
|
else
|
|
|
|
-- write ground
|
2018-07-30 11:54:36 -07:00
|
|
|
local p = {x=pos.x+xi, y=pos.y+yi, z=pos.z+zi}
|
|
|
|
minetest.forceload_block(p)
|
|
|
|
local node = minetest.get_node_or_nil(p)
|
2018-07-29 11:41:28 -07:00
|
|
|
if node then
|
|
|
|
if node.name ~= "air"
|
|
|
|
then
|
2018-07-30 11:54:36 -07:00
|
|
|
minetest.swap_node(p,{name="air"})
|
2018-07-29 11:41:28 -07:00
|
|
|
end
|
|
|
|
end
|
2018-07-17 01:22:48 -07:00
|
|
|
end
|
2018-06-26 11:08:14 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-07-29 11:41:28 -07:00
|
|
|
|
2018-06-26 11:08:14 -07:00
|
|
|
end
|
2018-07-21 11:31:29 -07:00
|
|
|
end
|