Added grass and variable coast line.

master
Lemon Slemon 2015-05-09 19:18:14 -07:00
parent 159e337afa
commit 3964b4c687
2 changed files with 20 additions and 15 deletions

View File

@ -1 +1,2 @@
default
flowers

View File

@ -6,7 +6,7 @@ if not chunksize then
end
if not SIZE then
SIZE = 350
SIZE = 1000
end
@ -17,7 +17,6 @@ local ssize = math.ceil(math.abs(SIZE))
-- Heights
local h = {}
h.sea = -1
h.beach = 0
h.ice = ssize * (3/4)
local recursion_depth = math.ceil(math.abs(SIZE)/10)
@ -64,7 +63,7 @@ local c_sand = minetest.get_content_id("default:sand")
local c_sandstone = minetest.get_content_id("default:sandstone")
local c_snow = minetest.get_content_id("default:snowblock")
local c_ice = minetest.get_content_id("default:ice")
local c_lava = minetest.get_content_id("default:lava_source")
local c_grass = minetest.get_content_id("default:grass_1")
minetest.register_on_generated(function(minp, maxp, seed)
@ -87,28 +86,33 @@ minetest.register_on_generated(function(minp, maxp, seed)
for z=minp.z,maxp.z do
local land_base = land_base + heightz[z]
land_base = land_base + SIZE/3*math.sin(get_distance(x,z))
if SIZE*math.cos(get_distance(x/SIZE,z,100,-1000)) - land_base > SIZE then
land_base = land_base + SIZE/5*math.sin(get_distance(x,z,1230,-51234)/SIZE) + SIZE/5*math.sin((x + y)/SIZE)
land_base = land_base + SIZE/5*math.sin(get_distance(x,z,12*z,-51*x)/SIZE)
end
land_base = math.floor(land_base)
local beach = math.floor(SIZE/97*math.cos((x - z)*10/(SIZE))) -- Also used for ice
for y=minp.y,maxp.y do
local p_pos = area:index(x, y, z)
if y < land_base - 1 then
data[p_pos] = c_stone
elseif y == math.floor(land_base) then
if y > h.ice then
elseif y == land_base + 1 and y > beach + 1 and y < beach + h.ice and y > h.sea then
data[p_pos] = c_grass
elseif y == land_base then
if y > beach + h.ice then
data[p_pos] = c_snow
elseif y > h.beach then
data[p_pos] = c_dirt_with_grass
elseif y >= beach then
if y >= h.sea - 1 then
data[p_pos] = c_dirt_with_grass
else
data[p_pos] = c_dirt
end
else
data[p_pos] = c_sand
end
elseif y == math.floor(land_base) - 1 then
if y > h.ice then
elseif y == land_base - 1 then
if y > beach + h.ice then
data[p_pos] = c_ice
elseif y > h.beach then
elseif y >= beach then
data[p_pos] = c_dirt
else
data[p_pos] = c_sandstone
@ -121,8 +125,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
vm:set_data(data)
vm:calc_lighting()
vm:update_liquids()
-- vm:calc_lighting()
-- vm:update_liquids()
vm:write_to_map()
local geninfo = string.format("[mg] done after: %.2fs", os.clock() - t1)