diff --git a/mapgen.lua b/mapgen.lua index e968744..6b17af5 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -18,10 +18,11 @@ local cave_noise = {offset = 0, scale = 1, seed = -3977, 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 = {} biome_names["common"] = {} biome_names["uncommon"] = {} -local biomes = {} do local biome_terrain_scale = {} biome_terrain_scale["coniferous_forest"] = 0.75 @@ -59,12 +60,9 @@ do biome.special_trees = tree_biomes[biome.name] biomes[biome.name] = biome biome_names[rarity][#biome_names[rarity]+1] = biome.name - --print(dump(biome)) end end - - local function place_schematic(pos, schem, center) local yslice = {} if schem.yslice_prob then @@ -183,23 +181,16 @@ local function get_biome(px, pz) end local function get_decoration(biome) - for i, deco in pairs(minetest.registered_decorations) do - local biome_match = false - if deco.biomes then - for _, b in pairs(deco.biomes) do - if biome == b then - biome_match = true + for i, deco in pairs(loud_walking.decorations) do + if not deco.biomes or deco.biomes[biome] then + --local range = (string.find(biome, "rain") and deco.flower) and 500 or 1000 + local range = 1000 + if deco.deco_type == "simple" then + if deco.fill_ratio and math.random(range) - 1 < deco.fill_ratio * 1000 then + return deco.decoration end - end - else - biome_match = true - end - - if biome_match and deco.deco_type == "simple" then - if deco.fill_ratio and math.random(1000) < deco.fill_ratio * 1000 then - return deco.decoration - elseif math.random(1000) < 6 then - return deco.decoration + else + -- nop end end end @@ -236,9 +227,12 @@ function loud_walking.generate(p_minp, p_maxp, seed) local pz = math.floor((minp.z + 32) / csize.z) local biome = get_biome(px, pz) - local top = biomes[biome].node_top or "default:dirt_with_grass" + local node_top = biomes[biome].node_top or "default:dirt_with_grass" local node_filler = biomes[biome].node_filler or "default:dirt" + local node_water_top = biomes[biome].node_water_top or "default:water_source" + local node_water = biomes[biome].node_water or "default:water_source" local depth_top = biomes[biome].depth_top or 1 + local depth_water_top = biomes[biome].node_water_top or 1 local depth_filler = biomes[biome].depth_filler or 1 local node_stone = biomes[biome].node_stone or "default:stone" local ocean = string.find(biome, "ocean") and true or false @@ -309,28 +303,31 @@ function loud_walking.generate(p_minp, p_maxp, seed) data[ivm] = node(glass) elseif dz >= 35 and dz <= 45 and dx >= 35 and dx <= 45 and dy == csize.y - 5 then data[ivm] = node(glass) - elseif not in_cave and dy == terr + ground + 1 and dy > half then - 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 + 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 elseif (ocean or swamp or beach) and dy > terr + ground and dy <= half then - data[ivm] = node("default:water_source") + data[ivm] = node(node_water) in_cave = false elseif dy > terr + ground then data[ivm] = node("air") in_cave = false elseif cave[index3d] ^ 2 > 0.1 + dy / half then if terr + ground >= dy and not in_cave and dy > terr + ground - 10 then - data[ivm] = node(node_filler) + data[ivm] = node(node_top) elseif dy == 1 then local sr = math.random(9) if not ocean and not swamp and not beach and sr == 1 then @@ -340,20 +337,20 @@ function loud_walking.generate(p_minp, p_maxp, seed) elseif ocean or swamp or beach then data[ivm] = node(node_filler) end - elseif ocean or swamp or beach then - data[ivm] = node("default:water_source") + elseif ocean or swamp or beach and dy < half then + data[ivm] = node(node_water) else data[ivm] = node("air") end in_cave = true lightmap[ivm] = 0 elseif dy > terr + ground - depth_top then - data[ivm] = node(top) + 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("default:dirt") + data[ivm] = node(node_filler) lightmap[ivm] = 0 in_cave = false write = true @@ -385,9 +382,8 @@ function loud_walking.generate(p_minp, p_maxp, seed) local y = minp.y + get_height(x - minp.x, z - minp.z, biomes[biome].terrain_scale, ocean) + ground local ivm = a:index(x, y, z) - if (data[ivm + a.ystride] == node("air") or (swamp and data[ivm + a.ystride] == node("default:water_source"))) and (data[ivm] == node("default:dirt") or data[ivm] == node("default:dirt_with_grass") or data[ivm] == node("default:dirt_with_snow")) then + if (swamp or data[ivm + a.ystride] ~= node("default:water_source")) and (data[ivm] == node("default:dirt") or data[ivm] == node("default:dirt_with_grass") or data[ivm] == node("default:dirt_with_snow")) then if biomes[biome].special_trees then - --print(dump(biomes[biome].special_trees)) local tree_type = biomes[biome].special_trees[math.random(#biomes[biome].special_trees)] if tree_type then local schem = loud_walking.schematics[tree_type][math.random(#loud_walking.schematics[tree_type])] @@ -433,6 +429,5 @@ function loud_walking.respawn(player) player:setpos(pos) return true end - --print(node.name) end end diff --git a/nodes.lua b/nodes.lua index df77c95..1421b3e 100644 --- a/nodes.lua +++ b/nodes.lua @@ -43,13 +43,9 @@ minetest.register_node("loud_walking:controls", { puncher:set_hp(puncher:get_hp() - sr) elseif sr < 6 then local pos = puncher:getpos() - if sr == 3 then - pos.x = pos.x + (math.random(-50, 50) * 160) - elseif sr == 4 then - pos.y = pos.y + (math.random(-50, 50) * 160) - elseif sr == 5 then - pos.z = pos.z + (math.random(-50, 50) * 160) - end + pos.x = pos.x + (math.random(-50, 50) * 160) + pos.y = pos.y + (math.random(-50, 50) * 160) + pos.z = pos.z + (math.random(-50, 50) * 160) if pos.x > -31000 and pos.x < 31000 and pos.y > -31000 and pos.y < 31000 and pos.z > -31000 and pos.z < 31000 then puncher:setpos(pos) end @@ -83,3 +79,83 @@ minetest.register_node("loud_walking:controls", { end end }) + +loud_walking.decorations = {} +do + for i, odeco in pairs(minetest.registered_decorations) do + local deco = {} + if odeco.biomes then + deco.biomes = {} + for _, b in pairs(odeco.biomes) do + deco.biomes[b] = true + end + end + + deco.deco_type = odeco.deco_type + deco.decoration = odeco.decoration + deco.schematic = odeco.schematic + deco.fill_ratio = odeco.fill_ratio + + if odeco.noise_params then + deco.fill_ratio = (odeco.noise_params.scale + odeco.noise_params.offset) + end + + local nod = minetest.registered_nodes[deco.decoration] + if nod and nod.groups and nod.groups.flower then + deco.flower = true + end + + loud_walking.decorations[#loud_walking.decorations+1] = deco + end +end + +local function register_flower(name, desc, biomes, chance) + local groups = {} + groups.snappy = 3 + groups.flammable = 2 + groups.flower = 1 + groups.flora = 1 + groups.attached_node = 1 + + minetest.register_node("loud_walking:" .. name, { + description = desc, + drawtype = "plantlike", + waving = 1, + tiles = {"loud_walking_" .. name .. ".png"}, + inventory_image = "loud_walking_" .. name .. ".png", + wield_image = "flowers_" .. name .. ".png", + sunlight_propagates = true, + paramtype = "light", + walkable = false, + buildable_to = true, + stack_max = 99, + groups = groups, + sounds = default.node_sound_leaves_defaults(), + selection_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}, + } + }) + + local bi = {} + if biomes then + bi = {} + for _, b in pairs(biomes) do + bi[b] = true + end + end + + loud_walking.decorations[#loud_walking.decorations+1] = { + deco_type = "simple", + place_on = {"default:dirt_with_grass"}, + biomes = bi, + fill_ratio = chance, + flower = true, + decoration = "loud_walking:"..name, + } +end + +register_flower("orchid", "Orchid", {"rainforest", "rainforest_swamp"}, 0.025) +register_flower("bird_of_paradise", "Bird of Paradise", {"rainforest", "desertstone_grassland"}, 0.025) +register_flower("gerbera", "Gerbera", {"savanna", "rainforest", "desertstone_grassland"}, 0.005) +print(dump(loud_walking.decorations)) diff --git a/textures/loud_walking_algae.png b/textures/loud_walking_algae.png new file mode 100644 index 0000000..2e75111 Binary files /dev/null and b/textures/loud_walking_algae.png differ diff --git a/textures/loud_walking_birch_tree.png b/textures/loud_walking_birch_tree.png new file mode 100644 index 0000000..1a3b99a Binary files /dev/null and b/textures/loud_walking_birch_tree.png differ diff --git a/textures/loud_walking_bird_of_paradise.png b/textures/loud_walking_bird_of_paradise.png new file mode 100644 index 0000000..e0534c0 Binary files /dev/null and b/textures/loud_walking_bird_of_paradise.png differ diff --git a/textures/loud_walking_brain_coral.png b/textures/loud_walking_brain_coral.png new file mode 100644 index 0000000..0e7de78 Binary files /dev/null and b/textures/loud_walking_brain_coral.png differ diff --git a/textures/loud_walking_controls.png b/textures/loud_walking_controls.png new file mode 100644 index 0000000..9d62f17 Binary files /dev/null and b/textures/loud_walking_controls.png differ diff --git a/textures/loud_walking_dragon_eye.png b/textures/loud_walking_dragon_eye.png new file mode 100644 index 0000000..ec9294d Binary files /dev/null and b/textures/loud_walking_dragon_eye.png differ diff --git a/textures/loud_walking_fungal_tree.png b/textures/loud_walking_fungal_tree.png new file mode 100644 index 0000000..ea0f75a Binary files /dev/null and b/textures/loud_walking_fungal_tree.png differ diff --git a/textures/loud_walking_fungal_tree_fruit.png b/textures/loud_walking_fungal_tree_fruit.png new file mode 100644 index 0000000..b4e6eb3 Binary files /dev/null and b/textures/loud_walking_fungal_tree_fruit.png differ diff --git a/textures/loud_walking_fungal_tree_fruit_original.png b/textures/loud_walking_fungal_tree_fruit_original.png new file mode 100644 index 0000000..faf8c9f Binary files /dev/null and b/textures/loud_walking_fungal_tree_fruit_original.png differ diff --git a/textures/loud_walking_fungal_tree_leaves.png b/textures/loud_walking_fungal_tree_leaves.png new file mode 100644 index 0000000..58ebb53 Binary files /dev/null and b/textures/loud_walking_fungal_tree_leaves.png differ diff --git a/textures/loud_walking_gerbera.png b/textures/loud_walking_gerbera.png new file mode 100644 index 0000000..3fae697 Binary files /dev/null and b/textures/loud_walking_gerbera.png differ diff --git a/textures/loud_walking_glowing_fungal.png b/textures/loud_walking_glowing_fungal.png new file mode 100644 index 0000000..1f93d4c Binary files /dev/null and b/textures/loud_walking_glowing_fungal.png differ diff --git a/textures/loud_walking_glowing_fungus.png b/textures/loud_walking_glowing_fungus.png new file mode 100644 index 0000000..62abcfd Binary files /dev/null and b/textures/loud_walking_glowing_fungus.png differ diff --git a/textures/loud_walking_hibiscus.png b/textures/loud_walking_hibiscus.png new file mode 100644 index 0000000..509ee17 Binary files /dev/null and b/textures/loud_walking_hibiscus.png differ diff --git a/textures/loud_walking_lichen.png b/textures/loud_walking_lichen.png new file mode 100644 index 0000000..446836d Binary files /dev/null and b/textures/loud_walking_lichen.png differ diff --git a/textures/loud_walking_lumin_tree.png b/textures/loud_walking_lumin_tree.png new file mode 100644 index 0000000..4578023 Binary files /dev/null and b/textures/loud_walking_lumin_tree.png differ diff --git a/textures/loud_walking_moon_weed.png b/textures/loud_walking_moon_weed.png new file mode 100644 index 0000000..b672a6a Binary files /dev/null and b/textures/loud_walking_moon_weed.png differ diff --git a/textures/loud_walking_moss.png b/textures/loud_walking_moss.png new file mode 100644 index 0000000..ea0f75a Binary files /dev/null and b/textures/loud_walking_moss.png differ diff --git a/textures/loud_walking_mushroom_giant_cap.png b/textures/loud_walking_mushroom_giant_cap.png new file mode 100644 index 0000000..53bc43e Binary files /dev/null and b/textures/loud_walking_mushroom_giant_cap.png differ diff --git a/textures/loud_walking_mushroom_giant_stem.png b/textures/loud_walking_mushroom_giant_stem.png new file mode 100644 index 0000000..9139777 Binary files /dev/null and b/textures/loud_walking_mushroom_giant_stem.png differ diff --git a/textures/loud_walking_mushroom_giant_under.png b/textures/loud_walking_mushroom_giant_under.png new file mode 100644 index 0000000..d9a9d3d Binary files /dev/null and b/textures/loud_walking_mushroom_giant_under.png differ diff --git a/textures/loud_walking_orchid.png b/textures/loud_walking_orchid.png new file mode 100644 index 0000000..5e1b699 Binary files /dev/null and b/textures/loud_walking_orchid.png differ diff --git a/textures/loud_walking_pillar_coral.png b/textures/loud_walking_pillar_coral.png new file mode 100644 index 0000000..0c5b515 Binary files /dev/null and b/textures/loud_walking_pillar_coral.png differ diff --git a/textures/loud_walking_pillar_coral_side.png b/textures/loud_walking_pillar_coral_side.png new file mode 100644 index 0000000..b9eb5d6 Binary files /dev/null and b/textures/loud_walking_pillar_coral_side.png differ diff --git a/textures/loud_walking_pillar_coral_top.png b/textures/loud_walking_pillar_coral_top.png new file mode 100644 index 0000000..8bbbd3d Binary files /dev/null and b/textures/loud_walking_pillar_coral_top.png differ diff --git a/textures/loud_walking_staghorn_coral.png b/textures/loud_walking_staghorn_coral.png new file mode 100644 index 0000000..05857aa Binary files /dev/null and b/textures/loud_walking_staghorn_coral.png differ diff --git a/textures/texture_licenses.txt b/textures/texture_licenses.txt new file mode 100644 index 0000000..f81a55a --- /dev/null +++ b/textures/texture_licenses.txt @@ -0,0 +1 @@ +The alien controls are based on a work by Steve LeMaster (http://obnoxiousnox.deviantart.com/art/Alien-control-panel-264724297), and used with permission.