first commit
commit
3330fe3643
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1,49 @@
|
|||
-- fairly imperfect code
|
||||
|
||||
local c_air = minetest.get_content_id("air")
|
||||
local c_water = minetest.get_content_id("default:water_source")
|
||||
local c_stone = minetest.get_content_id("default:stone")
|
||||
local c_dirt = minetest.get_content_id("default:dirt")
|
||||
local c_dirt_with_grass = minetest.get_content_id("default:dirt_with_grass")
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
|
||||
local x0,z0,x1,z1 = minp.x,minp.z,maxp.x,maxp.z -- Assume X and Z lengths are equal
|
||||
|
||||
t1 = os.clock()
|
||||
local geninfo = "[mg] generates..."
|
||||
print(geninfo)
|
||||
minetest.chat_send_all(geninfo)
|
||||
|
||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||
local data = vm:get_data()
|
||||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||
|
||||
for x=minp.x,maxp.x,1 do
|
||||
for z=minp.z,maxp.z,1 do
|
||||
for y=minp.y,maxp.y,1 do
|
||||
local p_pos = area:index(x, y, z)
|
||||
local x = x/10
|
||||
local land_base = 10*math.abs(x + math.sin(x) + math.sin(x + math.sin(x)))
|
||||
if y == math.floor(land_base) then
|
||||
data[p_pos] = c_dirt_with_grass
|
||||
elseif y == math.floor(land_base) - 1 then
|
||||
data[p_pos] = c_dirt
|
||||
elseif y < land_base then
|
||||
data[p_pos] = c_stone
|
||||
elseif y < 30 then
|
||||
data[p_pos] = c_water
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vm:set_data(data)
|
||||
vm:calc_lighting()
|
||||
vm:update_liquids()
|
||||
vm:write_to_map()
|
||||
|
||||
local geninfo = string.format("[mg] done after: %.2fs", os.clock() - t1)
|
||||
print(geninfo)
|
||||
minetest.chat_send_all(geninfo)
|
||||
end)
|
|
@ -0,0 +1,72 @@
|
|||
-- fairly imperfect code
|
||||
|
||||
local c_air = minetest.get_content_id("air")
|
||||
local c_water = minetest.get_content_id("default:water_source")
|
||||
local c_stone = minetest.get_content_id("default:stone")
|
||||
|
||||
local river_rarity = 0.1
|
||||
local river_scale = 10
|
||||
|
||||
local perlin_scale = river_rarity*river_scale*100
|
||||
local inverted_rarity = 1-river_rarity
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
|
||||
--avoid calculating perlin noises for unneeded places
|
||||
if maxp.y <= -150
|
||||
or minp.y >= 150 then
|
||||
return
|
||||
end
|
||||
|
||||
local perlin1 = minetest.get_perlin(11,3, 0.5, perlin_scale) --Get map specific perlin
|
||||
local x0,z0,x1,z1 = minp.x,minp.z,maxp.x,maxp.z -- Assume X and Z lengths are equal
|
||||
|
||||
if not ( perlin1:get2d( {x=x0, y=z0} ) > inverted_rarity ) --top left
|
||||
and not ( perlin1:get2d( { x = x0 + ( (x1-x0)/2), y=z0 } ) > inverted_rarity )--top middle
|
||||
and not (perlin1:get2d({x=x1, y=z1}) > inverted_rarity) --bottom right
|
||||
and not (perlin1:get2d({x=x1, y=z0+((z1-z0)/2)}) > inverted_rarity) --right middle
|
||||
and not (perlin1:get2d({x=x0, y=z1}) > inverted_rarity) --bottom left
|
||||
and not (perlin1:get2d({x=x1, y=z0}) > inverted_rarity) --top right
|
||||
and not (perlin1:get2d({x=x0+((x1-x0)/2), y=z1}) > inverted_rarity) --left middle
|
||||
and not (perlin1:get2d({x=(x1-x0)/2, y=(z1-z0)/2}) > inverted_rarity) --middle
|
||||
and not (perlin1:get2d({x=x0, y=z1+((z1-z0)/2)}) > inverted_rarity) then --bottom middle
|
||||
return
|
||||
end
|
||||
|
||||
t1 = os.clock()
|
||||
local geninfo = "[mg] generates..."
|
||||
print(geninfo)
|
||||
minetest.chat_send_all(geninfo)
|
||||
|
||||
|
||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||
local data = vm:get_data()
|
||||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||
|
||||
for x=minp.x,maxp.x,1 do
|
||||
for z=minp.z,maxp.z,1 do
|
||||
local test = math.abs(perlin1:get2d({x=x, y=z}))
|
||||
if test <= 0.1 then
|
||||
for y=minp.y,maxp.y,1 do
|
||||
local p_pos = area:index(x, y, z)
|
||||
if y <= test*100-10 then
|
||||
data[p_pos] = c_stone
|
||||
elseif y <= 1 then
|
||||
data[p_pos] = c_water
|
||||
else
|
||||
data[p_pos] = c_air
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vm:set_data(data)
|
||||
vm:calc_lighting()
|
||||
vm:update_liquids()
|
||||
vm:write_to_map()
|
||||
|
||||
local geninfo = string.format("[mg] done after: %.2fs", os.clock() - t1)
|
||||
print(geninfo)
|
||||
minetest.chat_send_all(geninfo)
|
||||
end)
|
Loading…
Reference in New Issue