diff --git a/depends.txt b/depends.txt index b270b77..53fabe4 100644 --- a/depends.txt +++ b/depends.txt @@ -1,3 +1,4 @@ default vacuum bedrock? +skybox? diff --git a/init.lua b/init.lua index 964e3ef..50fe653 100644 --- a/init.lua +++ b/init.lua @@ -1,98 +1,10 @@ -local has_bedrock_mod = minetest.get_modpath("bedrock") - --- http://dev.minetest.net/PerlinNoiseMap - --- basic planet height noise -local base_params = { - offset = 0, - scale = 1, - spread = {x=1024, y=512, z=1024}, - seed = 3468584, - octaves = 5, - persist = 0.6 +planet_mars = { + -- technic EU storage value + y_start = tonumber(minetest.settings:get("planet_mars.y_start")) or 11000, + y_height = tonumber(minetest.settings:get("planet_mars.y_height")) or 500, } --- ore params -local ore_params = { - offset = 0, - scale = 1, - spread = {x=128, y=64, z=128}, - seed = 935472, - octaves = 4, - persist = 0.6 -} - -local c_base = minetest.get_content_id("default:desert_stone") -local c_air = minetest.get_content_id("air") -local c_ignore = minetest.get_content_id("ignore") -local c_vacuum = minetest.get_content_id("vacuum:vacuum") -local c_clay = minetest.get_content_id("default:clay") -local c_bedrock - -if has_bedrock_mod then - c_bedrock = minetest.get_content_id("bedrock:bedrock") -end - -local y_min = 11000 -local y_max = 11280 -local y_diff = y_max - y_min - - -minetest.register_on_generated(function(minp, maxp, seed) - - if minp.y < y_min or minp.y > y_max then - return - end - - local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") - local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax} - local data = vm:get_data() - - local is_solid = minp.y < y_min+100 - - local side_length = maxp.x - minp.x + 1 -- 80 - local map_lengths_xyz = {x=side_length, y=side_length, z=side_length} - - local base_perlin_map = minetest.get_perlin_map(base_params, map_lengths_xyz):get3dMap_flat(minp) - local ore_perlin_map = minetest.get_perlin_map(ore_params, map_lengths_xyz):get3dMap_flat(minp) - - local i = 1 - - for z=minp.z,maxp.z do - for y=minp.y,maxp.y do - for x=minp.x,maxp.x do - - local index = area:index(x,y,z) - - if y >= y_min and y < y_min+10 and has_bedrock_mod then - data[index] = c_bedrock - - elseif data[index] == c_air or data[index] == c_vacuum or data[index] == c_ignore then - -- unpopulated node - - -- higher elevation = lower chance - local chance = (y-minp.y) / side_length - - local base_n = math.min(0, base_perlin_map[i] + 1) - local ore_n = ore_perlin_map[i] - - if is_solid or base_n > chance then - -- basic material - data[index] = c_base - end - end - - i = i + 1 - - end --x - end --y - end --z - - - vm:set_data(data) - vm:write_to_map() - -end) - +dofile(MP.."/mapgen.lua") +dofile(MP.."/skybox.lua") print("[OK] Planet: mars") diff --git a/mapgen.lua b/mapgen.lua new file mode 100644 index 0000000..964e3ef --- /dev/null +++ b/mapgen.lua @@ -0,0 +1,98 @@ +local has_bedrock_mod = minetest.get_modpath("bedrock") + +-- http://dev.minetest.net/PerlinNoiseMap + +-- basic planet height noise +local base_params = { + offset = 0, + scale = 1, + spread = {x=1024, y=512, z=1024}, + seed = 3468584, + octaves = 5, + persist = 0.6 +} + +-- ore params +local ore_params = { + offset = 0, + scale = 1, + spread = {x=128, y=64, z=128}, + seed = 935472, + octaves = 4, + persist = 0.6 +} + +local c_base = minetest.get_content_id("default:desert_stone") +local c_air = minetest.get_content_id("air") +local c_ignore = minetest.get_content_id("ignore") +local c_vacuum = minetest.get_content_id("vacuum:vacuum") +local c_clay = minetest.get_content_id("default:clay") +local c_bedrock + +if has_bedrock_mod then + c_bedrock = minetest.get_content_id("bedrock:bedrock") +end + +local y_min = 11000 +local y_max = 11280 +local y_diff = y_max - y_min + + +minetest.register_on_generated(function(minp, maxp, seed) + + if minp.y < y_min or minp.y > y_max then + return + end + + local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") + local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax} + local data = vm:get_data() + + local is_solid = minp.y < y_min+100 + + local side_length = maxp.x - minp.x + 1 -- 80 + local map_lengths_xyz = {x=side_length, y=side_length, z=side_length} + + local base_perlin_map = minetest.get_perlin_map(base_params, map_lengths_xyz):get3dMap_flat(minp) + local ore_perlin_map = minetest.get_perlin_map(ore_params, map_lengths_xyz):get3dMap_flat(minp) + + local i = 1 + + for z=minp.z,maxp.z do + for y=minp.y,maxp.y do + for x=minp.x,maxp.x do + + local index = area:index(x,y,z) + + if y >= y_min and y < y_min+10 and has_bedrock_mod then + data[index] = c_bedrock + + elseif data[index] == c_air or data[index] == c_vacuum or data[index] == c_ignore then + -- unpopulated node + + -- higher elevation = lower chance + local chance = (y-minp.y) / side_length + + local base_n = math.min(0, base_perlin_map[i] + 1) + local ore_n = ore_perlin_map[i] + + if is_solid or base_n > chance then + -- basic material + data[index] = c_base + end + end + + i = i + 1 + + end --x + end --y + end --z + + + vm:set_data(data) + vm:write_to_map() + +end) + + +print("[OK] Planet: mars") diff --git a/skybox.lua b/skybox.lua new file mode 100644 index 0000000..9cf31f5 --- /dev/null +++ b/skybox.lua @@ -0,0 +1,28 @@ +local has_skybox_mod = minetest.get_modpath("skybox") + +if has_skybox_mod then + skybox.register({ + -- http://www.custommapmakers.org/skyboxes.php + name = "mars", + miny = 11000, + maxy = 11999, + gravity = 0.37, + always_day = true, + clouds = { + thickness=16, + color={r=244, g=189, b=114, a=229}, + ambient={r=0, g=0, b=0, a=255}, + density=0.4, + height=11300, + speed={y=-2,x=0} + }, + textures = { + "mars_up.jpg^[transformR270", + "mars_dn.jpg^[transformR90", + "mars_ft.jpg", + "mars_bk.jpg", + "mars_lf.jpg", + "mars_rt.jpg" + } + }) +end diff --git a/textures/mars_bk.jpg b/textures/mars_bk.jpg new file mode 100644 index 0000000..590f94a Binary files /dev/null and b/textures/mars_bk.jpg differ diff --git a/textures/mars_dn.jpg b/textures/mars_dn.jpg new file mode 100644 index 0000000..2c47b12 Binary files /dev/null and b/textures/mars_dn.jpg differ diff --git a/textures/mars_ft.jpg b/textures/mars_ft.jpg new file mode 100644 index 0000000..cb5f43b Binary files /dev/null and b/textures/mars_ft.jpg differ diff --git a/textures/mars_lf.jpg b/textures/mars_lf.jpg new file mode 100644 index 0000000..87ea74a Binary files /dev/null and b/textures/mars_lf.jpg differ diff --git a/textures/mars_rt.jpg b/textures/mars_rt.jpg new file mode 100644 index 0000000..752a221 Binary files /dev/null and b/textures/mars_rt.jpg differ diff --git a/textures/mars_up.jpg b/textures/mars_up.jpg new file mode 100644 index 0000000..3dbc751 Binary files /dev/null and b/textures/mars_up.jpg differ