-- Loud Walking deco.lua -- Copyright Duane Robertson (duane@duanerobertson.com), 2017 -- Distributed under the LGPLv2.1 (https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html) dofile(loud_walking.path..'/schematics.lua') local dangerous = true loud_walking.decorations = {} do for _, odeco in pairs(minetest.registered_decorations) do if not odeco.schematic then local deco = {} if odeco.biomes then deco.biomes = {} if type(odeco.biomes) == 'table' then for _, b in pairs(odeco.biomes) do deco.biomes[b] = true end elseif type(odeco.biomes) == 'string' then deco.biomes[odeco.biomes] = 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 = math.max(0.001, (odeco.noise_params.scale + odeco.noise_params.offset) / 4) 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 end loud_walking.biomes = {} local biomes = loud_walking.biomes local biome_names = {} do local biome_mod = { cold_desert = { danger = 2, y_min = 1, }, cold_desert_ocean = { danger = 2, y_min = -loud_walking.max_height, y_max = 0, }, coniferous_forest = { danger = 0, y_min = 1, }, coniferous_forest_ocean = { danger = 0, y_min = -loud_walking.max_height, y_max = 0, }, deciduous_forest = { danger = 0, }, deciduous_forest_ocean = { danger = 0, y_min = -loud_walking.max_height, }, deciduous_forest_shore = { danger = 0, }, desert = { danger = 2, y_min = 1, }, desert_ocean = { danger = 2, y_min = -loud_walking.max_height, y_max = 0, }, --glacier = { y_min = 1, node_water_top = 'loud_walking:thin_ice', depth_water_top = 1, }, glacier = { danger = 2, y_min = 1, depth_water_top = 1, }, glacier_ocean = { danger = 2, y_min = -loud_walking.max_height, y_max = 0, }, grassland = { danger = 0, y_min = 1, }, grassland_ocean = { danger = 0, y_min = -loud_walking.max_height, y_max = 0, }, icesheet = { danger = 2, y_min = 1, }, icesheet_ocean = { danger = 2, y_min = -loud_walking.max_height, y_max = 0, }, rainforest = { danger = 1, node_riverbed = 'default:dirt', }, rainforest_ocean = { danger = 1, y_min = -loud_walking.max_height, node_riverbed = 'default:dirt', }, rainforest_swamp = { danger = 1,}, sandstone_desert = { danger = 2, y_min = 1, }, sandstone_desert_ocean = { danger = 2, y_min = -loud_walking.max_height, y_max = 0, }, savanna = { danger = 1, }, savanna_ocean = { danger = 1, y_min = -loud_walking.max_height, }, savanna_shore = { danger = 1, }, snowy_grassland = { danger = 1, y_min = 1, }, snowy_grassland_ocean = { danger = 1, y_min = -loud_walking.max_height, y_max = 0, }, --taiga = { y_min = 1, node_water_top = 'loud_walking:thin_ice', depth_water_top = 1, }, taiga = { danger = 1, y_min = 1, depth_water_top = 1, }, taiga_ocean = { danger = 1, y_min = -loud_walking.max_height, y_max = 0, }, --tundra = { node_river_water = "loud_walking:thin_ice", }, --tundra_beach = { node_river_water = "loud_walking:thin_ice", }, --tundra = { node_top = 'default:snowblock', depth_top = 1, y_min = 1, node_water_top = 'loud_walking:thin_ice', depth_water_top = 1, }, tundra = { danger = 2, node_top = 'default:snowblock', depth_top = 1, y_min = 1, depth_water_top = 1, }, tundra_ocean = { danger = 2, y_min = -loud_walking.max_height, y_max = 0, }, underground = {}, } do local tree_biomes = {} tree_biomes["deciduous_forest"] = {"apple_tree", 'aspen_tree'} tree_biomes["coniferous_forest"] = {"pine_tree"} tree_biomes["taiga"] = {"pine_tree"} tree_biomes["rainforest"] = {"jungle_tree"} tree_biomes["rainforest_swamp"] = {"jungle_tree"} tree_biomes["coniferous_forest"] = {"pine_tree"} tree_biomes["savanna"] = {"acacia_tree"} for i, obiome in pairs(minetest.registered_biomes) do local biome = table.copy(obiome) biome.special_trees = tree_biomes[biome.name] biome.terrain_scale = 1 biomes[biome.name] = biome biome_names[#biome_names+1] = biome.name if string.find(biome.name, "ocean") then biome.terrain_scale = 2 end if string.find(biome.name, "swamp") then biome.terrain_scale = 0.5 end if string.find(biome.name, "beach") then biome.terrain_scale = 0.5 end if string.find(biome.name, "^underground$") then biome.node_top = "default:stone" end --if type(biome.depth_water_top) == 'string' then -- print('** '..biome.name) --end for n, bi in pairs(biome_mod) do for i, rbi in pairs(biomes) do if rbi.name == n then for j, prop in pairs(bi) do biomes[i][j] = prop end end end end end end biomes['tundra_beach'] = nil biomes['grassland_dunes'] = nil biomes['coniferous_forest_dunes'] = nil biomes['deciduous_forest_shore'] = nil biomes['savanna_shore'] = nil biomes["desertstone_grassland"] = { name = "desertstone_grassland", --node_dust = "", node_top = "default:dirt_with_grass", depth_top = 1, node_filler = "default:dirt", depth_filler = 1, node_stone = "default:desert_stone", node_riverbed = "default:sand", depth_riverbed = 2, --node_water_top = "", --depth_water_top = , --node_water = "", --node_river_water = "", y_min = 6, y_max = loud_walking.max_height, heat_point = 80, humidity_point = 55, terrain_scale = 1, } if dangerous then biomes["toxic_forest"] = { name = "toxic_forest", node_top = "loud_walking:polluted_dirt", danger = 3, depth_top = 1, node_filler = "loud_walking:polluted_dirt", depth_filler = 1, node_riverbed = "loud_walking:polluted_dirt", depth_riverbed = 1, node_water = "loud_walking:water_poison_source", node_river_water = "loud_walking:water_poison_source", special_trees = {"decaying_tree"}, y_min = 1, y_max = loud_walking.max_height, heat_point = 20, humidity_point = 50, terrain_scale = 0.75, } biomes["toxic_forest_ocean"] = { name = "toxic_forest_ocean", node_top = "loud_walking:polluted_dirt", danger = 3, depth_top = 1, node_filler = "loud_walking:polluted_dirt", depth_filler = 1, node_riverbed = "loud_walking:polluted_dirt", depth_riverbed = 1, node_water = "loud_walking:water_poison_source", node_river_water = "loud_walking:water_poison_source", y_min = -10, y_max = 0, heat_point = 20, humidity_point = 50, terrain_scale = 1, } biomes["draconic"] = { name = "draconic", --node_dust = "", node_top = "loud_walking:cracked_stone", depth_top = 1, node_filler = "loud_walking:granite", depth_filler = 1, node_stone = "loud_walking:granite", --node_water_top = "", --depth_water_top = , --node_water = "", node_river_water = "loud_walking:basalt", node_riverbed = "loud_walking:basalt", depth_riverbed = 2, danger = 3, y_min = 1, y_max = loud_walking.max_height, heat_point = 80, humidity_point = 20, terrain_scale = 1, } biomes["draconic_ocean"] = { name = "draconic_ocean", --node_dust = "", node_top = "loud_walking:granite", depth_top = 1, danger = 3, node_filler = "loud_walking:granite", depth_filler = 3, node_stone = "loud_walking:granite", y_min = -20, y_max = 0, heat_point = 80, humidity_point = 20, terrain_scale = 1, } biomes["bizarre"] = { name = "bizarre", --node_dust = "", node_top = "loud_walking:dirt_with_odd_grass", depth_top = 1, node_filler = "default:dirt", depth_filler = 1, node_stone = "loud_walking:basalt", --node_water_top = "", --depth_water_top = , --node_water = "", --node_river_water = "loud_walking:basalt", --node_riverbed = "loud_walking:basalt", --depth_riverbed = 2, special_trees = {'fur_tree'}, danger = 3, y_min = 1, y_max = loud_walking.max_height, heat_point = 60, humidity_point = 70, terrain_scale = 1, } biomes["bizarre_ocean"] = { name = "bizarre_ocean", --node_dust = "", node_top = "default:sand", depth_top = 1, danger = 3, node_filler = "default:sand", depth_filler = 3, node_stone = "loud_walking:basalt", y_min = -20, y_max = 0, heat_point = 60, humidity_point = 70, } end loud_walking.decorations[#loud_walking.decorations+1] = { deco_type = "simple", place_on = {"default:dirt_with_grass"}, sidelen = 80, fill_ratio = 0.1, biomes = {"desertstone_grassland", }, y_min = 1, y_max = loud_walking.max_height, decoration = "default:junglegrass", } 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) local function register_decoration(deco, place_on, biomes, chance) 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 = place_on, biomes = bi, fill_ratio = chance, decoration = deco, } end if dangerous then --register_decoration('default:lava_source', 'loud_walking:cracked_stone', {'draconic'}, 0.0005) register_decoration('loud_walking:blackened_shrub', 'loud_walking:polluted_dirt', {'toxic_forest'}, 0.05) register_decoration('flowers:mushroom_red', 'loud_walking:polluted_dirt', {'toxic_forest'}, 0.05) register_decoration('loud_walking:strange_plant_1', 'loud_walking:dirt_with_odd_grass', {'bizarre'}, 0.05) register_decoration('loud_walking:strange_plant_2', 'loud_walking:dirt_with_odd_grass', {'bizarre'}, 0.05) for i = 1, 4 do register_decoration('loud_walking:stone_spike_'..i, 'loud_walking:cracked_stone', {'draconic'}, 0.02 / i) end end local function get_decoration(biome_name) for i, deco in pairs(loud_walking.decorations) do if not deco.biomes or deco.biomes[biome_name] then if deco.deco_type == "simple" then if deco.fill_ratio and math.random(1000) - 1 < deco.fill_ratio * 1000 then if type(deco.decoration) == 'string' then return deco.decoration elseif type(deco.decoration) == 'table' then return deco.decoration[math.random(#deco.decoration)] end end end end end end loud_walking.get_decoration = get_decoration