forked from minetest/minetest_game
papyrus generation
This commit is contained in:
parent
4abfcda81f
commit
5f6039bc3c
@ -68,13 +68,20 @@ local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume,
|
|||||||
--print("generate_ore done")
|
--print("generate_ore done")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function make_papyrus(pos, size)
|
||||||
|
for y=0,size-1 do
|
||||||
|
local p = {x=pos.x, y=pos.y+y, z=pos.z}
|
||||||
|
minetest.env:set_node(p, {name="default:papyrus"})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_on_generated(function(minp, maxp, seed)
|
minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed, 1/8/8/8, 5, -31000, 64)
|
generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed, 1/8/8/8, 5, -31000, 64)
|
||||||
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+1, 1/16/16/16, 5, -5, 7)
|
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+1, 1/16/16/16, 5, -5, 7)
|
||||||
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+2, 1/12/12/12, 5, -16, -5)
|
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+2, 1/12/12/12, 5, -16, -5)
|
||||||
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+3, 1/9/9/9, 5, -31000, -17)
|
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+3, 1/9/9/9, 5, -31000, -17)
|
||||||
-- Generate clay
|
|
||||||
if maxp.y >= 2 and minp.y <= 0 then
|
if maxp.y >= 2 and minp.y <= 0 then
|
||||||
|
-- Generate clay
|
||||||
-- Assume X and Z lengths are equal
|
-- Assume X and Z lengths are equal
|
||||||
local divlen = 4
|
local divlen = 4
|
||||||
local divs = (maxp.x-minp.x)/divlen+1;
|
local divs = (maxp.x-minp.x)/divlen+1;
|
||||||
@ -109,6 +116,31 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- Generate papyrus
|
||||||
|
local perlin1 = minetest.env:get_perlin(354, 3, 0.7, 100)
|
||||||
|
-- Assume X and Z lengths are equal
|
||||||
|
local divlen = 8
|
||||||
|
local divs = (maxp.x-minp.x)/divlen+1;
|
||||||
|
for divx=0,divs-1 do
|
||||||
|
for divz=0,divs-1 do
|
||||||
|
local x0 = minp.x + math.floor((divx+0)*divlen)
|
||||||
|
local z0 = minp.z + math.floor((divz+0)*divlen)
|
||||||
|
local x1 = minp.x + math.floor((divx+1)*divlen)
|
||||||
|
local z1 = minp.z + math.floor((divz+1)*divlen)
|
||||||
|
-- Determine papyrus amount from perlin noise
|
||||||
|
local papyrus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 45 - 20)
|
||||||
|
-- Find random positions for papyrus based on this random
|
||||||
|
local pr = PseudoRandom(seed+1)
|
||||||
|
for i=0,papyrus_amount do
|
||||||
|
local x = pr:next(x0, x1)
|
||||||
|
local z = pr:next(z0, z1)
|
||||||
|
if minetest.env:get_node({x=x,y=1,z=z}).name == "default:dirt_with_grass" and
|
||||||
|
minetest.env:find_node_near({x=x,y=1,z=z}, 1, "default:water_source") then
|
||||||
|
make_papyrus({x=x,y=2,z=z}, pr:next(2, 4))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user