Testing bedrock/ skyrock, added unique layers
Temporarily added a bedrock and skyrock node (in default namespace for now on my local machine as it is in the default mod ... sorry ...). Introduced a layer table containing and a loop to populate the layer settings based on a single random seed and with some noise settings hard coded for now.
This commit is contained in:
parent
4e76adb03d
commit
f8ac6237ad
189
mapgen.lua
189
mapgen.lua
|
@ -1,19 +1,59 @@
|
||||||
local settings = {}
|
local settings = {}
|
||||||
|
local layers = {}
|
||||||
|
|
||||||
settings.layers = 16
|
settings.number_of_layers = 32
|
||||||
|
settings.day_light = 15
|
||||||
|
settings.night_light = 0
|
||||||
|
settings.bedrock = "default:bedrock"
|
||||||
|
settings.skyrock = "default:skyrock"
|
||||||
|
|
||||||
settings.water_height = 0
|
settings.water_height = 0
|
||||||
settings.height_map_seed = 9625423
|
|
||||||
settings.terrain_type_seed = 2376457
|
settings.seed = 835726
|
||||||
settings.lake_seed = 5232353
|
|
||||||
|
math.randomseed(settings.seed)
|
||||||
|
|
||||||
|
for i = settings.number_of_layers / -2, settings.number_of_layers / 2 do
|
||||||
|
layers[i] = {
|
||||||
|
height_map_seed = math.random(-1000000000000, 1000000000000),
|
||||||
|
height_map_params = {
|
||||||
|
offset = 0,
|
||||||
|
scale = 50,
|
||||||
|
spread = {x=2048, y=2048, z=2048},
|
||||||
|
seed = settings.height_map_seed,
|
||||||
|
octaves = 7,
|
||||||
|
persist = 0.7
|
||||||
|
},
|
||||||
|
height_map = nil,
|
||||||
|
height_map_2dmap = {},
|
||||||
|
terrain_type_seed = math.random(-1000000000000, 1000000000000),
|
||||||
|
terrain_type_params = {
|
||||||
|
offset = 2.5,
|
||||||
|
scale = 2.5,
|
||||||
|
spread = {x=1024, y=1024, z=1024},
|
||||||
|
seed = settings.terrain_type_seed,
|
||||||
|
octaves = 6,
|
||||||
|
persist = 0.6
|
||||||
|
},
|
||||||
|
terrain_type_map = nil,
|
||||||
|
terrain_type_2dmap = {},
|
||||||
|
mountain_map_seed = math.random(-1000000000000, 1000000000000),
|
||||||
|
mountain_peak_params = {
|
||||||
|
offset = -75,
|
||||||
|
scale = 125,
|
||||||
|
spread = {x=256, y=256, z=256},
|
||||||
|
seed = settings.mountain_peak_seed,
|
||||||
|
octaves = 7,
|
||||||
|
persist = 0.6
|
||||||
|
},
|
||||||
|
mountain_peak_map = nil,
|
||||||
|
mountain_peak_2dmap = {},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
settings.cave_seed = 6568239
|
settings.cave_seed = 6568239
|
||||||
|
|
||||||
settings.perlin_worm_start_seed = 1423423
|
local layer_height = 65535 / settings.number_of_layers
|
||||||
settings.perlin_worm_yaw_seed = 3572245
|
|
||||||
settings.perlin_worm_pitch_seed = 8763243
|
|
||||||
|
|
||||||
local layer_height = 65535 / settings.layers
|
|
||||||
local half_layer_height = layer_height / 2
|
local half_layer_height = layer_height / 2
|
||||||
|
|
||||||
-- Base terrain is the lower frequency, lower amplitude noise
|
-- Base terrain is the lower frequency, lower amplitude noise
|
||||||
|
@ -21,14 +61,14 @@ local half_layer_height = layer_height / 2
|
||||||
-- flat plains, hills or mountains
|
-- flat plains, hills or mountains
|
||||||
-- Mountain peak generates peaks when greater than zero, making
|
-- Mountain peak generates peaks when greater than zero, making
|
||||||
-- jagged and rugged peaks on the surface or mountain tops
|
-- jagged and rugged peaks on the surface or mountain tops
|
||||||
local height_map
|
--local height_map
|
||||||
local terrain_type_map
|
--local terrain_type_map
|
||||||
local mountain_peak_map
|
--local mountain_peak_map
|
||||||
local lake_map
|
local lake_map
|
||||||
|
|
||||||
local height_map_2dmap = {}
|
--local height_map_2dmap = {}
|
||||||
local terrain_type_2dmap = {}
|
--local terrain_type_2dmap = {}
|
||||||
local mountain_peak_2dmap = {}
|
--local mountain_peak_2dmap = {}
|
||||||
local lake_3dmap = {}
|
local lake_3dmap = {}
|
||||||
|
|
||||||
local cave_map
|
local cave_map
|
||||||
|
@ -43,32 +83,32 @@ local perlin_worm_pitch_3dmap = {}
|
||||||
|
|
||||||
local perlin_worms = {}
|
local perlin_worms = {}
|
||||||
|
|
||||||
local height_map_params = {
|
--local height_map_params = {
|
||||||
offset = 0,
|
-- offset = 0,
|
||||||
scale = 50,
|
-- scale = 50,
|
||||||
spread = {x=2048, y=2048, z=2048},
|
-- spread = {x=2048, y=2048, z=2048},
|
||||||
seed = settings.height_map_seed,
|
-- seed = settings.height_map_seed,
|
||||||
octaves = 7,
|
-- octaves = 7,
|
||||||
persist = 0.7
|
-- persist = 0.7
|
||||||
}
|
--}
|
||||||
|
|
||||||
local terrain_type_params = {
|
--local terrain_type_params = {
|
||||||
offset = 2.5,
|
-- offset = 2.5,
|
||||||
scale = 2.5,
|
-- scale = 2.5,
|
||||||
spread = {x=1024, y=1024, z=1024},
|
-- spread = {x=1024, y=1024, z=1024},
|
||||||
seed = settings.terrain_type_seed,
|
-- seed = settings.terrain_type_seed,
|
||||||
octaves = 6,
|
-- octaves = 6,
|
||||||
persist = 0.6
|
-- persist = 0.6
|
||||||
}
|
--}
|
||||||
|
|
||||||
local mountain_peak_params = {
|
--local mountain_peak_params = {
|
||||||
offset = -75,
|
-- offset = -75,
|
||||||
scale = 125,
|
-- scale = 125,
|
||||||
spread = {x=256, y=256, z=256},
|
-- spread = {x=256, y=256, z=256},
|
||||||
seed = settings.mountain_peak_seed,
|
-- seed = settings.mountain_peak_seed,
|
||||||
octaves = 7,
|
-- octaves = 7,
|
||||||
persist = 0.6
|
-- persist = 0.6
|
||||||
}
|
--}
|
||||||
|
|
||||||
local lake_params = {
|
local lake_params = {
|
||||||
offset = 0,
|
offset = 0,
|
||||||
|
@ -97,21 +137,49 @@ local perlin_worm_start_params = {
|
||||||
persist = 0.7
|
persist = 0.7
|
||||||
}
|
}
|
||||||
|
|
||||||
|
minetest.register_node("default:skyrock", {
|
||||||
|
description = "Multi Map Impenetrable Skyblock",
|
||||||
|
drawtype = "airlike",
|
||||||
|
tiles ={"star_button.png"},
|
||||||
|
inventory_image = "star_button.png",
|
||||||
|
is_ground_content = false,
|
||||||
|
walkable = true,
|
||||||
|
pointable = false,
|
||||||
|
diggable = false,
|
||||||
|
climbable = false,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("default:bedrock", {
|
||||||
|
description = "Multi Map Impenetrable Bedrock",
|
||||||
|
drawtype = "normal",
|
||||||
|
tiles ={"multi_map_bedrock.png"},
|
||||||
|
is_ground_content = false,
|
||||||
|
walkable = true,
|
||||||
|
pointable = false,
|
||||||
|
diggable = false,
|
||||||
|
climbable = false,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_on_generated(function(minp, maxp)
|
minetest.register_on_generated(function(minp, maxp)
|
||||||
local c_stone = minetest.get_content_id("default:stone")
|
local c_stone = minetest.get_content_id("default:stone")
|
||||||
local c_air = minetest.get_content_id("air")
|
local c_air = minetest.get_content_id("air")
|
||||||
local c_water = minetest.get_content_id("default:water_source")
|
local c_water = minetest.get_content_id("default:water_source")
|
||||||
|
local c_bedrock = minetest.get_content_id("default:bedrock")
|
||||||
|
local c_skyrock = minetest.get_content_id("default:skyrock")
|
||||||
|
|
||||||
local current_layer = "undefined"
|
local current_layer = nil
|
||||||
|
|
||||||
for l = (settings.layers / -2), (settings.layers / 2) do
|
for l = (settings.number_of_layers / -2), (settings.number_of_layers / 2) do
|
||||||
if minp.y >= (l * layer_height) - half_layer_height and minp.y < (l * layer_height) + half_layer_height then
|
if minp.y >= (l * layer_height) - half_layer_height and minp.y < (l * layer_height) + half_layer_height then
|
||||||
current_layer = l
|
current_layer = l
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
print("Current layer = "..current_layer)
|
if not current_layer then
|
||||||
|
minetest.log("error", "Could not determine current multi_map layer, exiting mapgen!")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local sidelen = maxp.x - minp.x + 1
|
local sidelen = maxp.x - minp.x + 1
|
||||||
local blocklen = sidelen / 5
|
local blocklen = sidelen / 5
|
||||||
|
@ -131,16 +199,21 @@ minetest.register_on_generated(function(minp, maxp)
|
||||||
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
|
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
|
||||||
local vm_data = vm:get_data()
|
local vm_data = vm:get_data()
|
||||||
|
|
||||||
height_map = height_map or minetest.get_perlin_map(height_map_params, chulenxz)
|
layers[current_layer].height_map = layers[current_layer].height_map or
|
||||||
terrain_type_map = terrain_type_map or minetest.get_perlin_map(terrain_type_params, chulenxz)
|
minetest.get_perlin_map(layers[current_layer].height_map_params, chulenxz)
|
||||||
mountain_peak_map = mountain_peak_map or minetest.get_perlin_map(mountain_peak_params, chulenxz)
|
|
||||||
|
layers[current_layer].terrain_type_map = layers[current_layer].terrain_type_map or
|
||||||
|
minetest.get_perlin_map(layers[current_layer].terrain_type_params, chulenxz)
|
||||||
|
|
||||||
|
layers[current_layer].mountain_peak_map = layers[current_layer].mountain_peak_map or
|
||||||
|
minetest.get_perlin_map(layers[current_layer].mountain_peak_params, chulenxz)
|
||||||
|
|
||||||
cave_map = cave_map or minetest.get_perlin_map(cave_params, chulenxyz)
|
cave_map = cave_map or minetest.get_perlin_map(cave_params, chulenxyz)
|
||||||
perlin_worm_start_map = perlin_worm_start_map or minetest.get_perlin_map(perlin_worm_start_params, chulenxyz)
|
perlin_worm_start_map = perlin_worm_start_map or minetest.get_perlin_map(perlin_worm_start_params, chulenxyz)
|
||||||
|
|
||||||
height_map:get2dMap_flat(minposxz, height_map_2dmap)
|
layers[current_layer].height_map:get2dMap_flat(minposxz, layers[current_layer].height_map_2dmap)
|
||||||
terrain_type_map:get2dMap_flat(minposxz, terrain_type_2dmap)
|
layers[current_layer].terrain_type_map:get2dMap_flat(minposxz, layers[current_layer].terrain_type_2dmap)
|
||||||
mountain_peak_map:get2dMap_flat(minposxz, mountain_peak_2dmap)
|
layers[current_layer].mountain_peak_map:get2dMap_flat(minposxz, layers[current_layer].mountain_peak_2dmap)
|
||||||
|
|
||||||
cave_map:get3dMap_flat(minposxyz, cave_3dmap)
|
cave_map:get3dMap_flat(minposxyz, cave_3dmap)
|
||||||
perlin_worm_start_map:get3dMap_flat(minposxyz, perlin_worm_start_3dmap)
|
perlin_worm_start_map:get3dMap_flat(minposxyz, perlin_worm_start_3dmap)
|
||||||
|
@ -158,14 +231,18 @@ minetest.register_on_generated(function(minp, maxp)
|
||||||
local vi = area:index(minp.x, y, z)
|
local vi = area:index(minp.x, y, z)
|
||||||
for x = minp.x, maxp.x do
|
for x = minp.x, maxp.x do
|
||||||
local nix
|
local nix
|
||||||
local terrain_type = terrain_type_2dmap[nixz]
|
local terrain_type = layers[current_layer].terrain_type_2dmap[nixz]
|
||||||
local height = terrain_type * height_map_2dmap[nixz]
|
local height = terrain_type * layers[current_layer].height_map_2dmap[nixz]
|
||||||
|
|
||||||
if mountain_peak_2dmap[nixz] > 0 then
|
if layers[current_layer].mountain_peak_2dmap[nixz] > 0 then
|
||||||
height = height + mountain_peak_2dmap[nixz]
|
height = height + layers[current_layer].mountain_peak_2dmap[nixz]
|
||||||
end
|
end
|
||||||
|
|
||||||
if y <= height + (layer_height * current_layer) then
|
if (layer_height * current_layer) - half_layer_height <= y and y <= (layer_height * current_layer) - half_layer_height + (sidelen / 2) then
|
||||||
|
vm_data[vi] = c_bedrock
|
||||||
|
elseif (layer_height * current_layer) + half_layer_height - (sidelen * 5) <= y and y <= (layer_height * current_layer) + half_layer_height then
|
||||||
|
vm_data[vi] = c_skyrock
|
||||||
|
elseif y <= height + (layer_height * current_layer) then
|
||||||
-- if math.abs(cave_3dmap[nixyz]) < 10 then -- + (y / 400) then
|
-- if math.abs(cave_3dmap[nixyz]) < 10 then -- + (y / 400) then
|
||||||
vm_data[vi] = c_stone
|
vm_data[vi] = c_stone
|
||||||
-- else
|
-- else
|
||||||
|
@ -173,8 +250,6 @@ minetest.register_on_generated(function(minp, maxp)
|
||||||
-- end
|
-- end
|
||||||
elseif y <= (layer_height * current_layer) + settings.water_height then
|
elseif y <= (layer_height * current_layer) + settings.water_height then
|
||||||
vm_data[vi] = c_water
|
vm_data[vi] = c_water
|
||||||
-- else
|
|
||||||
-- vm_data[vi] = c_air
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Increment noise index.
|
-- Increment noise index.
|
||||||
|
@ -193,8 +268,8 @@ minetest.register_on_generated(function(minp, maxp)
|
||||||
|
|
||||||
|
|
||||||
vm:set_data(vm_data)
|
vm:set_data(vm_data)
|
||||||
-- vm:set_lighting({day=0, night=0})
|
vm:set_lighting({day=settings.day_light, night=settings.night_light})
|
||||||
vm:update_liquids()
|
vm:update_liquids()
|
||||||
vm:calc_lighting()
|
vm:calc_lighting(false)
|
||||||
vm:write_to_map()
|
vm:write_to_map()
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue