Improve village ground generation
This commit is contained in:
parent
dbf02685c9
commit
68782753ce
@ -42,7 +42,7 @@ function util.fixlight(pos1, pos2)
|
|||||||
return #nodes
|
return #nodes
|
||||||
end
|
end
|
||||||
|
|
||||||
function util.nodefunc(pos1, pos2, name, func, nomanip)
|
function util.nodefunc(pos1, pos2, nodes, func, nomanip)
|
||||||
-- function based off fixlight
|
-- function based off fixlight
|
||||||
-- call a function for every node of a single type
|
-- call a function for every node of a single type
|
||||||
local pos1, pos2 = util.sort_pos(pos1, pos2)
|
local pos1, pos2 = util.sort_pos(pos1, pos2)
|
||||||
@ -52,7 +52,7 @@ function util.nodefunc(pos1, pos2, name, func, nomanip)
|
|||||||
manip:read_from_map(pos1, pos2)
|
manip:read_from_map(pos1, pos2)
|
||||||
end
|
end
|
||||||
|
|
||||||
local nodes = minetest.find_nodes_in_area(pos1, pos2, name)
|
local nodes = minetest.find_nodes_in_area(pos1, pos2, nodes)
|
||||||
for _, pos in ipairs(nodes) do
|
for _, pos in ipairs(nodes) do
|
||||||
func(pos)
|
func(pos)
|
||||||
end
|
end
|
||||||
|
@ -11,6 +11,7 @@ local village_file = minetest.get_worldpath() .. "/villages.dat"
|
|||||||
|
|
||||||
local modpath = minetest.get_modpath("village")
|
local modpath = minetest.get_modpath("village")
|
||||||
local mapseed = minetest.get_mapgen_setting("seed")
|
local mapseed = minetest.get_mapgen_setting("seed")
|
||||||
|
local water_level = tonumber(minetest.get_mapgen_setting("water_level"))
|
||||||
|
|
||||||
--[[ List of village wood materials (schematic replacements)
|
--[[ List of village wood materials (schematic replacements)
|
||||||
One of these will be chosen at random and it applies
|
One of these will be chosen at random and it applies
|
||||||
@ -208,15 +209,19 @@ function village.lift_ground(pos, scanheight)
|
|||||||
|
|
||||||
local stonenode = nil
|
local stonenode = nil
|
||||||
|
|
||||||
|
if minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name == "air" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
for y = pos.y, pos.y - scanheight, -1 do
|
for y = pos.y, pos.y - scanheight, -1 do
|
||||||
local p = {x = pos.x, y = y, z = pos.z}
|
local p = {x = pos.x, y = y, z = pos.z}
|
||||||
|
|
||||||
local nn = minetest.get_node(p).name
|
local nn = minetest.get_node(p).name
|
||||||
local an = minetest.get_node({x = p.x, y = p.y + 1, z = p.z}).name
|
local an = minetest.get_node({x = p.x, y = p.y + 1, z = p.z}).name
|
||||||
|
|
||||||
if nn ~= "air" then
|
if nn ~= "air" and minetest.registered_nodes[nn].liquidtype ~= "none" then
|
||||||
local nd = minetest.registered_nodes[nn]
|
local nd = minetest.registered_nodes[nn]
|
||||||
if not nd.buildable_to then -- avoid grass, fluids, etc.
|
if not nd.buildable_to then
|
||||||
if topnode == nil and nn ~= an then
|
if topnode == nil and nn ~= an then
|
||||||
topnode = nn
|
topnode = nn
|
||||||
elseif fillernode == nil and nn ~= an then
|
elseif fillernode == nil and nn ~= an then
|
||||||
@ -251,6 +256,7 @@ function village.lift_ground(pos, scanheight)
|
|||||||
|
|
||||||
local th = pos.y - y
|
local th = pos.y - y
|
||||||
|
|
||||||
|
-- TODO: Optimize speed
|
||||||
if th <= fillerdepth - topdepth then
|
if th <= fillerdepth - topdepth then
|
||||||
minetest.set_node(p, {name = fillernode})
|
minetest.set_node(p, {name = fillernode})
|
||||||
elseif th <= topdepth then
|
elseif th <= topdepth then
|
||||||
@ -265,10 +271,22 @@ function village.spawn_chunk(pos, orient, replace, pr, chunktype, nofill)
|
|||||||
util.getvoxelmanip(pos, {x = pos.x+12, y = pos.y+12, z = pos.z+12})
|
util.getvoxelmanip(pos, {x = pos.x+12, y = pos.y+12, z = pos.z+12})
|
||||||
|
|
||||||
if nofill ~= true then
|
if nofill ~= true then
|
||||||
|
minetest.place_schematic(
|
||||||
|
{x = pos.x-6, y = pos.y-5, z = pos.z-6},
|
||||||
|
modpath .. "/schematics/village_filler.mts",
|
||||||
|
"0",
|
||||||
|
{},
|
||||||
|
false
|
||||||
|
)
|
||||||
|
|
||||||
|
local py = pos.y-6
|
||||||
|
if py < water_level then
|
||||||
|
py = water_level
|
||||||
|
end
|
||||||
util.nodefunc(
|
util.nodefunc(
|
||||||
{x = pos.x-6, y = pos.y-7, z = pos.z-6},
|
{x = pos.x-6, y = py, z = pos.z-6},
|
||||||
{x = pos.x+17, y = pos.y-6, z = pos.z+17},
|
{x = pos.x+17, y = py, z = pos.z+17},
|
||||||
"air",
|
{"air", "group:liquid"},
|
||||||
function(pos)
|
function(pos)
|
||||||
village.lift_ground(pos, 15) -- distance to lift ground; larger numbers will be slower
|
village.lift_ground(pos, 15) -- distance to lift ground; larger numbers will be slower
|
||||||
end, true)
|
end, true)
|
||||||
@ -281,13 +299,6 @@ function village.spawn_chunk(pos, orient, replace, pr, chunktype, nofill)
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
minetest.place_schematic(
|
|
||||||
{x = pos.x-6, y = pos.y-5, z = pos.z-6},
|
|
||||||
modpath .. "/schematics/village_filler.mts",
|
|
||||||
"0",
|
|
||||||
{},
|
|
||||||
false
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if chunktype == "orchard" then
|
if chunktype == "orchard" then
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user