diff --git a/mapgen.lua b/mapgen.lua index 670e4fe..e80bc66 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -1,7 +1,8 @@ local node = loud_walking.node local bevel = 40 -local glass = "loud_walking:transparent_scrith" +local cloud_i = 0.5 +local glass = {"loud_walking:sky_scrith", "loud_walking:cloud_scrith", "loud_walking:transparent_scrith"} local data = {} @@ -18,6 +19,10 @@ local cave_noise = {offset = 0, scale = 1, seed = -3977, spread = {x = 30, y = 30, z = 30}, octaves = 3, persist = 0.8, lacunarity = 2} +local cloud_noise = {offset = 0, scale = 1, +seed = -7874, spread = {x = 30, y = 30, z = 30}, octaves = 3, +persist = 0.8, lacunarity = 2} + loud_walking.biomes = {} local biomes = loud_walking.biomes local biome_names = {} @@ -235,8 +240,6 @@ function loud_walking.generate(p_minp, p_maxp, seed) a = VoxelArea:new({MinEdge = emin, MaxEdge = emax}) csize = vector.add(vector.subtract(maxp, minp), 1) - local write = false - -- Deal with memory issues. This, of course, is supposed to be automatic. local mem = math.floor(collectgarbage("count")/1024) if mem > 300 then @@ -283,6 +286,7 @@ function loud_walking.generate(p_minp, p_maxp, seed) terrain = minetest.get_perlin_map(terrain_noise, csize):get2dMap_flat(minp) cave = minetest.get_perlin_map(cave_noise, csize):get3dMap_flat(minp) + cloud = minetest.get_perlin_map(cloud_noise, csize):get2dMap_flat(minp) local pod = is_pod(minp.x, minp.y, minp.z) local connection = connection(minp.x, minp.y, minp.z) @@ -316,10 +320,9 @@ function loud_walking.generate(p_minp, p_maxp, seed) data[ivm] = node("loud_walking:scrith") lightmap[ivm] = 0 else - data[ivm] = node(glass) + data[ivm] = node(glass[cloud[index] < cloud_i and 1 or 2]) end in_cave = false - write = true elseif (dx == 0 or dx == csize.x - 1) or (dz == 0 or dz == csize.z - 1) or (dy == 0 or dy == csize.y - 1) then if math.abs(dy - half - 2) < 2 and (dz == half or dx == half) then data[ivm] = node("air") @@ -327,31 +330,30 @@ function loud_walking.generate(p_minp, p_maxp, seed) if biome ~= "underground" and dy < half then data[ivm] = node("loud_walking:scrith") lightmap[ivm] = 0 + elseif dy == csize.y - 1 then + data[ivm] = node(glass[cloud[index] < cloud_i and 1 or 2]) else - data[ivm] = node(glass) + data[ivm] = node(glass[1]) end - write = true end in_cave = false elseif (((dx == 35 or dx == 45) and dz >= 35 and dz <= 45) or ((dz == 35 or dz == 45) and dx >= 35 and dx <= 45)) and dx ~= 40 and dz ~= 40 and dy == csize.y - 2 then data[ivm] = node("loud_walking:controls") elseif (((dx == 35 or dx == 45) and dz >= 35 and dz <= 45) or ((dz == 35 or dz == 45) and dx >= 35 and dx <= 45)) and dx ~= 40 and dz ~= 40 and dy > csize.y - 5 then - data[ivm] = node(glass) + data[ivm] = node(glass[3]) elseif dz >= 35 and dz <= 45 and dx >= 35 and dx <= 45 and dy == csize.y - 5 then - data[ivm] = node(glass) + data[ivm] = node(glass[3]) elseif not in_cave and (ocean or swamp or beach) and dy > terr + ground and dy <= half and dy == terr + ground + 1 then -- ** water decorations ** --local deco = get_decoration(biome) --if deco then -- data[ivm] = node(deco) --end - --write = true elseif not in_cave and dy == terr + ground + 1 then local deco = get_decoration(biome) if deco then data[ivm] = node(deco) end - write = true elseif (ocean or swamp or beach) and dy > terr + ground and dy <= half and dy >= half - depth_water_top then data[ivm] = node(node_water_top) in_cave = false @@ -400,12 +402,10 @@ function loud_walking.generate(p_minp, p_maxp, seed) data[ivm] = node(node_top) lightmap[ivm] = 0 in_cave = false - write = true elseif dy > terr + ground - depth_filler - depth_top then data[ivm] = node(node_filler) lightmap[ivm] = 0 in_cave = false - write = true else data[ivm] = node(node_stone) if in_cave and node_stone == "default:stone" and math.random(20) == 1 then @@ -417,12 +417,10 @@ function loud_walking.generate(p_minp, p_maxp, seed) end lightmap[ivm] = 0 in_cave = false - write = true end elseif connection and dy == half and ((dx == half and connection % 4 == 0) or (dz == half and connection % 2 == 1)) then data[ivm] = node("loud_walking:scrith") lightmap[ivm] = 0 - write = true end if not in_cave then @@ -462,17 +460,17 @@ function loud_walking.generate(p_minp, p_maxp, seed) end end - if write then - vm:set_data(data) - minetest.generate_ores(vm, minp, maxp) - minetest.generate_decorations(vm, minp, maxp) - --vm:set_param2_data(p2data) - --vm:set_lighting({day = 15, night = 0}) + vm:set_data(data) + minetest.generate_ores(vm, minp, maxp) + minetest.generate_decorations(vm, minp, maxp) + --vm:set_param2_data(p2data) + --vm:set_lighting({day = 15, night = 0}) + if pod then vm:set_light_data(lightmap) - vm:calc_lighting(minp, maxp, false) - vm:update_liquids() - vm:write_to_map() end + vm:update_liquids() + vm:calc_lighting(minp, maxp, false) + vm:write_to_map() vm, a, heightmap, biomemap = nil, nil, nil, nil end diff --git a/nodes.lua b/nodes.lua index b109380..9f837c0 100644 --- a/nodes.lua +++ b/nodes.lua @@ -21,8 +21,23 @@ minetest.register_node("loud_walking:scrith", { sounds = default.node_sound_stone_defaults(), }) -local node = loud_walking.clone_node("default:glass") -node.groups = {} +minetest.register_node("loud_walking:sky_scrith", { + description = "Transparent Scrith", + drawtype = "glasslike", + paramtype = "light", + sunlight_propagates = true, + tiles = {"loud_walking_sky_glass.png"}, + light_source = 1, + use_texture_alpha = true, + is_ground_content = false, + groups = {}, + sounds = default.node_sound_stone_defaults(), +}) +local node = loud_walking.clone_node("loud_walking:sky_scrith") +node.tiles = {"loud_walking_cloud_glass.png"} +minetest.register_node("loud_walking:cloud_scrith", node) +local node = loud_walking.clone_node("loud_walking:sky_scrith") +node.tiles = {"loud_walking_glass_detail.png"} minetest.register_node("loud_walking:transparent_scrith", node) minetest.register_node("loud_walking:controls", { diff --git a/textures/loud_walking_cloud_glass.png b/textures/loud_walking_cloud_glass.png new file mode 100644 index 0000000..7532f3b Binary files /dev/null and b/textures/loud_walking_cloud_glass.png differ diff --git a/textures/loud_walking_glass_detail.png b/textures/loud_walking_glass_detail.png new file mode 100644 index 0000000..0a54d07 Binary files /dev/null and b/textures/loud_walking_glass_detail.png differ diff --git a/textures/loud_walking_sky_glass.png b/textures/loud_walking_sky_glass.png new file mode 100644 index 0000000..ad2c16c Binary files /dev/null and b/textures/loud_walking_sky_glass.png differ