Skip to content
Snippets Groups Projects
Commit 20261f20 authored by Duane Robertson's avatar Duane Robertson
Browse files

Biome work.

parent a656d379
No related branches found
No related tags found
No related merge requests found
Showing
with 115 additions and 44 deletions
......@@ -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
......@@ -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))
textures/loud_walking_algae.png

3.43 KiB

textures/loud_walking_birch_tree.png

2.8 KiB

textures/loud_walking_bird_of_paradise.png

352 B

textures/loud_walking_brain_coral.png

479 B

textures/loud_walking_controls.png

7.14 KiB

textures/loud_walking_dragon_eye.png

2.53 KiB

textures/loud_walking_fungal_tree.png

2.63 KiB

textures/loud_walking_fungal_tree_fruit.png

3.19 KiB

textures/loud_walking_fungal_tree_fruit_original.png

3.4 KiB

textures/loud_walking_fungal_tree_leaves.png

2.08 KiB

textures/loud_walking_gerbera.png

683 B

textures/loud_walking_glowing_fungal.png

3.9 KiB

textures/loud_walking_glowing_fungus.png

6.6 KiB

textures/loud_walking_hibiscus.png

1.13 KiB

textures/loud_walking_lichen.png

2.41 KiB

textures/loud_walking_lumin_tree.png

2.24 KiB

textures/loud_walking_moon_weed.png

736 B

textures/loud_walking_moss.png

2.63 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment