From ab6f7ee0d84e17bc04db563f8ba597a966c9bd00 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 14 Mar 2019 10:37:34 +0100 Subject: [PATCH] Generate dirt in the underground --- mods/areas/areas.dat | 2 +- mods/tutorial/mapgen.lua | 36 +++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/mods/areas/areas.dat b/mods/areas/areas.dat index 6b867bd..9518083 100644 --- a/mods/areas/areas.dat +++ b/mods/areas/areas.dat @@ -1 +1 @@ -return {{["owner"] = "singleplayer", ["name"] = "Start room", ["pos1"] = {["y"] = 1, ["x"] = 41, ["z"] = 27}, ["pos2"] = {["y"] = 4, ["x"] = 51, ["z"] = 37}}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 4, ["x"] = 82, ["z"] = 34}, ["name"] = "Jumping section", ["pos1"] = {["y"] = -1, ["x"] = 57, ["z"] = 21}}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 5, ["x"] = 99, ["z"] = 68}, ["pos1"] = {["y"] = 1, ["x"] = 88, ["z"] = 59}, ["name"] = "Pointing section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 5, ["x"] = 99, ["z"] = 75}, ["pos1"] = {["y"] = 1, ["x"] = 88, ["z"] = 70}, ["name"] = "Using section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 3, ["x"] = 70, ["z"] = 68}, ["pos1"] = {["y"] = 1, ["x"] = 65, ["z"] = 58}, ["name"] = "Inventory and Chests section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = -1, ["x"] = 70, ["z"] = 61}, ["pos1"] = {["y"] = -3, ["x"] = 67, ["z"] = 58}, ["name"] = "Comestibles section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 3, ["x"] = 86, ["z"] = 68}, ["pos1"] = {["y"] = 1, ["x"] = 72, ["z"] = 58}, ["name"] = "Crafting and Tools section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 7, ["x"] = 79, ["z"] = 67}, ["pos1"] = {["y"] = 5, ["x"] = 73, ["z"] = 59}, ["name"] = "Smelting section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 15, ["x"] = 86, ["z"] = 56}, ["pos1"] = {["y"] = -4, ["x"] = 53, ["z"] = 41}, ["name"] = "Swimming section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 4, ["x"] = 64, ["z"] = 80}, ["pos1"] = {["y"] = -6, ["x"] = 58, ["z"] = 58}, ["name"] = "Diving section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 9, ["x"] = 48, ["z"] = 92}, ["pos1"] = {["y"] = 0, ["x"] = 31, ["z"] = 78}, ["name"] = "Waterfall section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 6, ["x"] = 47, ["z"] = 76}, ["pos1"] = {["y"] = 0, ["x"] = 31, ["z"] = 56}, ["name"] = "Viscosity section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 4, ["x"] = 56, ["z"] = 68}, ["pos1"] = {["y"] = 1, ["x"] = 49, ["z"] = 58}, ["name"] = "Health and Damage section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 15, ["x"] = 73, ["z"] = 40}, ["pos1"] = {["y"] = 1, ["x"] = 60, ["z"] = 36}, ["name"] = "Climbing section"}, {["owner"] = "singleplayer", ["pos1"] = {["y"] = 1, ["x"] = 68, ["z"] = 75}, ["name"] = "Mining section", ["pos2"] = {["y"] = 7, ["x"] = 81, ["z"] = 93}}, {["owner"] = "singleplayer", ["pos1"] = {["y"] = 1, ["x"] = 85, ["z"] = 79}, ["name"] = "Special Blocks section", ["pos2"] = {["y"] = 5, ["x"] = 93, ["z"] = 93}}, {["owner"] = "singleplayer", ["pos1"] = {["y"] = -8, ["x"] = 68, ["z"] = 97}, ["name"] = "Tutorial Mine", ["pos2"] = {["y"] = 4, ["x"] = 81, ["z"] = 112}}, {["owner"] = "singleplayer", ["pos1"] = {["y"] = 1, ["x"] = 55, ["z"] = 82}, ["name"] = "Building section", ["pos2"] = {["y"] = 6, ["x"] = 66, ["z"] = 93}}, {["owner"] = "singleplayer", ["pos1"] = {["y"] = -1, ["x"] = 13, ["z"] = 26}, ["name"] = "Sneaking section", ["pos2"] = {["y"] = 8, ["x"] = 37, ["z"] = 52}}, {["owner"] = "singleplayer", ["pos1"] = {["y"] = 0, ["x"] = 19, ["z"] = 68}, ["name"] = "Good-Bye room", ["pos2"] = {["y"] = 3, ["x"] = 29, ["z"] = 77}}} +return {{["owner"] = "singleplayer", ["name"] = "Start room", ["pos1"] = {["y"] = 1, ["x"] = 41, ["z"] = 27}, ["pos2"] = {["y"] = 4, ["x"] = 51, ["z"] = 37}}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 4, ["x"] = 82, ["z"] = 34}, ["name"] = "Jumping section", ["pos1"] = {["y"] = -1, ["x"] = 57, ["z"] = 21}}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 5, ["x"] = 99, ["z"] = 68}, ["pos1"] = {["y"] = 1, ["x"] = 88, ["z"] = 59}, ["name"] = "Pointing section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 5, ["x"] = 99, ["z"] = 75}, ["pos1"] = {["y"] = 1, ["x"] = 88, ["z"] = 70}, ["name"] = "Using section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 3, ["x"] = 70, ["z"] = 68}, ["pos1"] = {["y"] = 1, ["x"] = 65, ["z"] = 58}, ["name"] = "Inventory and Chests section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = -1, ["x"] = 70, ["z"] = 61}, ["pos1"] = {["y"] = -3, ["x"] = 67, ["z"] = 58}, ["name"] = "Comestibles section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 3, ["x"] = 86, ["z"] = 68}, ["pos1"] = {["y"] = 1, ["x"] = 72, ["z"] = 58}, ["name"] = "Crafting and Tools section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 7, ["x"] = 79, ["z"] = 67}, ["pos1"] = {["y"] = 5, ["x"] = 73, ["z"] = 59}, ["name"] = "Smelting section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 15, ["x"] = 86, ["z"] = 56}, ["pos1"] = {["y"] = -4, ["x"] = 53, ["z"] = 41}, ["name"] = "Swimming section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 4, ["x"] = 64, ["z"] = 80}, ["pos1"] = {["y"] = -6, ["x"] = 58, ["z"] = 58}, ["name"] = "Diving section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 9, ["x"] = 48, ["z"] = 92}, ["pos1"] = {["y"] = 0, ["x"] = 31, ["z"] = 78}, ["name"] = "Waterfall section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 6, ["x"] = 47, ["z"] = 76}, ["pos1"] = {["y"] = 0, ["x"] = 31, ["z"] = 56}, ["name"] = "Viscosity section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 4, ["x"] = 56, ["z"] = 68}, ["pos1"] = {["y"] = 1, ["x"] = 49, ["z"] = 58}, ["name"] = "Health and Damage section"}, {["owner"] = "singleplayer", ["pos2"] = {["y"] = 15, ["x"] = 73, ["z"] = 40}, ["pos1"] = {["y"] = 1, ["x"] = 60, ["z"] = 36}, ["name"] = "Climbing section"}, {["owner"] = "singleplayer", ["pos1"] = {["y"] = 1, ["x"] = 68, ["z"] = 75}, ["name"] = "Mining section", ["pos2"] = {["y"] = 7, ["x"] = 81, ["z"] = 93}}, {["owner"] = "singleplayer", ["pos1"] = {["y"] = 1, ["x"] = 85, ["z"] = 79}, ["name"] = "Special Blocks section", ["pos2"] = {["y"] = 5, ["x"] = 93, ["z"] = 93}}, {["owner"] = "singleplayer", ["pos1"] = {["y"] = -8, ["x"] = 68, ["z"] = 97}, ["name"] = "Tutorial Mine", ["pos2"] = {["y"] = 4, ["x"] = 81, ["z"] = 112}}, {["owner"] = "singleplayer", ["pos1"] = {["y"] = 1, ["x"] = 55, ["z"] = 82}, ["name"] = "Building section", ["pos2"] = {["y"] = 6, ["x"] = 66, ["z"] = 93}}, {["owner"] = "singleplayer", ["pos1"] = {["y"] = -1, ["x"] = 13, ["z"] = 26}, ["name"] = "Sneaking section", ["pos2"] = {["y"] = 8, ["x"] = 37, ["z"] = 52}}, {["owner"] = "singleplayer", ["pos1"] = {["y"] = 0, ["x"] = 19, ["z"] = 68}, ["name"] = "Good-Bye room", ["pos2"] = {["y"] = 3, ["x"] = 29, ["z"] = 77}},{["owner"] = "singleplayer", ["pos1"] = {["y"] = -1, ["x"] = 49, ["z"] = 56}, ["name"] = "Canal 1", ["pos2"] = {["y"] = -1, ["x"] = 62, ["z"] = 62}},{["owner"] = "singleplayer", ["pos1"] = {["y"] = -1, ["x"] = 88, ["z"] = 30}, ["name"] = "Canal 2", ["pos2"] = {["y"] = -1, ["x"] = 88, ["z"] = 36}},{["owner"] = "singleplayer", ["pos1"] = {["y"] = -2, ["x"] = 41, ["z"] = 28}, ["name"] = "Canal 3", ["pos2"] = {["y"] = -1, ["x"] = 47, ["z"] = 47}},{["owner"] = "singleplayer", ["pos1"] = {["y"] = -2, ["x"] = 39, ["z"] = 38}, ["name"] = "Canal 4", ["pos2"] = {["y"] = -1, ["x"] = 44, ["z"] = 44}},{["owner"] = "singleplayer", ["pos1"] = {["y"] = -1, ["x"] = 80, ["z"] = 34}, ["name"] = "Canal 5", ["pos2"] = {["y"] = -2, ["x"] = 38, ["z"] = 38}},{["owner"] = "singleplayer", ["pos1"] = {["y"] = -1, ["x"] = 73, ["z"] = 19}, ["name"] = "Canal 6", ["pos2"] = {["y"] = -2, ["x"] = 73, ["z"] = 41}},{["owner"] = "singleplayer", ["pos1"] = {["y"] = -3, ["x"] = 10, ["z"] = 28}, ["name"] = "Canal 7", ["pos2"] = {["y"] = -1, ["x"] = 41, ["z"] = 30}},{["owner"] = "singleplayer", ["pos1"] = {["y"] = -2, ["x"] = 80, ["z"] = 33}, ["name"] = "Canal 8", ["pos2"] = {["y"] = -2, ["x"] = 81, ["z"] = 38}},{["owner"] = "singleplayer", ["pos1"] = {["y"] = -2, ["x"] = 73, ["z"] = 20}, ["name"] = "Canal 9", ["pos2"] = {["y"] = -1, ["x"] = 74, ["z"] = 41}},{["owner"] = "singleplayer", ["pos1"] = {["y"] = -3, ["x"] = 72, ["z"] = 58}, ["name"] = "Darkroom", ["pos2"] = {["y"] = -2, ["x"] = 77, ["z"] = 67}}} diff --git a/mods/tutorial/mapgen.lua b/mods/tutorial/mapgen.lua index b8247ab..1a87982 100644 --- a/mods/tutorial/mapgen.lua +++ b/mods/tutorial/mapgen.lua @@ -7,6 +7,10 @@ local map_editing = minetest.settings:get_bool("tutorial_debug_map_editing") -- == END OF DEBUG SETTINGS == +local c_dirt = minetest.get_content_id("default:dirt") +local c_dirt_with_grass = minetest.get_content_id("default:dirt_with_grass") +local c_grass = minetest.get_content_id("default:grass_5") + -- Directory where the map data will be stored tutorial.map_directory = minetest.get_modpath("tutorial").."/mapdata/" @@ -340,29 +344,31 @@ minetest.register_on_generated(function(minp, maxp, seed) end end - -- Generate a layer of grass for the outside area + -- Generate a flat grass land and a dirt-only underground for the rest of the map if map_editing ~= true then local grasslev = 0 if minp.y <= grasslev and maxp.y >= grasslev then local vdata = vm:get_data(vbuffer) local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax}) - local c_dirt_with_grass = minetest.get_content_id("default:dirt_with_grass") - local c_grass = minetest.get_content_id("default:grass_5") for x = minp.x, maxp.x do for z = minp.z, maxp.z do - local p_pos = area:index(x, grasslev, z) - local p_pos_above - if minp.y <= grasslev+1 and maxp.y >= maxp.y then - p_pos_above = area:index(x, grasslev + 1, z) - end - local _, areas_count = areas:getAreasAtPos({x=x,y=grasslev,z=z}) - if areas_count == 0 then - if vdata[p_pos] == minetest.CONTENT_AIR then - vdata[p_pos] = c_dirt_with_grass - if p_pos_above and vdata[p_pos_above] == minetest.CONTENT_AIR then - if math.random(0,50) == 0 then - vdata[p_pos_above] = c_grass + for y = minp.y, maxp.y do + local p_pos = area:index(x, y, z) + local p_pos_above + if minp.y <= grasslev+1 and maxp.y >= maxp.y then + p_pos_above = area:index(x, y + 1, z) + end + local _, areas_count = areas:getAreasAtPos({x=x,y=y,z=z}) + if areas_count == 0 and vdata[p_pos] == minetest.CONTENT_AIR then + if y == grasslev then + vdata[p_pos] = c_dirt_with_grass + if p_pos_above and vdata[p_pos_above] == minetest.CONTENT_AIR then + if math.random(0,50) == 0 then + vdata[p_pos_above] = c_grass + end end + elseif y < grasslev then + vdata[p_pos] = c_dirt end end end