Biome work.
69
mapgen.lua
|
@ -18,10 +18,11 @@ local cave_noise = {offset = 0, scale = 1,
|
||||||
seed = -3977, spread = {x = 30, y = 30, z = 30}, octaves = 3,
|
seed = -3977, spread = {x = 30, y = 30, z = 30}, octaves = 3,
|
||||||
persist = 0.8, lacunarity = 2}
|
persist = 0.8, lacunarity = 2}
|
||||||
|
|
||||||
|
loud_walking.biomes = {}
|
||||||
|
local biomes = loud_walking.biomes
|
||||||
local biome_names = {}
|
local biome_names = {}
|
||||||
biome_names["common"] = {}
|
biome_names["common"] = {}
|
||||||
biome_names["uncommon"] = {}
|
biome_names["uncommon"] = {}
|
||||||
local biomes = {}
|
|
||||||
do
|
do
|
||||||
local biome_terrain_scale = {}
|
local biome_terrain_scale = {}
|
||||||
biome_terrain_scale["coniferous_forest"] = 0.75
|
biome_terrain_scale["coniferous_forest"] = 0.75
|
||||||
|
@ -59,12 +60,9 @@ do
|
||||||
biome.special_trees = tree_biomes[biome.name]
|
biome.special_trees = tree_biomes[biome.name]
|
||||||
biomes[biome.name] = biome
|
biomes[biome.name] = biome
|
||||||
biome_names[rarity][#biome_names[rarity]+1] = biome.name
|
biome_names[rarity][#biome_names[rarity]+1] = biome.name
|
||||||
--print(dump(biome))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function place_schematic(pos, schem, center)
|
local function place_schematic(pos, schem, center)
|
||||||
local yslice = {}
|
local yslice = {}
|
||||||
if schem.yslice_prob then
|
if schem.yslice_prob then
|
||||||
|
@ -183,23 +181,16 @@ local function get_biome(px, pz)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_decoration(biome)
|
local function get_decoration(biome)
|
||||||
for i, deco in pairs(minetest.registered_decorations) do
|
for i, deco in pairs(loud_walking.decorations) do
|
||||||
local biome_match = false
|
if not deco.biomes or deco.biomes[biome] then
|
||||||
if deco.biomes then
|
--local range = (string.find(biome, "rain") and deco.flower) and 500 or 1000
|
||||||
for _, b in pairs(deco.biomes) do
|
local range = 1000
|
||||||
if biome == b then
|
if deco.deco_type == "simple" then
|
||||||
biome_match = true
|
if deco.fill_ratio and math.random(range) - 1 < deco.fill_ratio * 1000 then
|
||||||
|
return deco.decoration
|
||||||
end
|
end
|
||||||
end
|
else
|
||||||
else
|
-- nop
|
||||||
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
|
|
||||||
end
|
end
|
||||||
end
|
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 pz = math.floor((minp.z + 32) / csize.z)
|
||||||
local biome = get_biome(px, pz)
|
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_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_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 depth_filler = biomes[biome].depth_filler or 1
|
||||||
local node_stone = biomes[biome].node_stone or "default:stone"
|
local node_stone = biomes[biome].node_stone or "default:stone"
|
||||||
local ocean = string.find(biome, "ocean") and true or false
|
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)
|
data[ivm] = node(glass)
|
||||||
elseif dz >= 35 and dz <= 45 and dx >= 35 and dx <= 45 and dy == csize.y - 5 then
|
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)
|
||||||
elseif not in_cave and dy == terr + ground + 1 and dy > half then
|
elseif not in_cave and (ocean or swamp or beach) and dy > terr + ground and dy <= half and dy == terr + ground + 1 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
|
|
||||||
-- ** water decorations **
|
-- ** water decorations **
|
||||||
--local deco = get_decoration(biome)
|
--local deco = get_decoration(biome)
|
||||||
--if deco then
|
--if deco then
|
||||||
-- data[ivm] = node(deco)
|
-- data[ivm] = node(deco)
|
||||||
--end
|
--end
|
||||||
--write = true
|
--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
|
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
|
in_cave = false
|
||||||
elseif dy > terr + ground then
|
elseif dy > terr + ground then
|
||||||
data[ivm] = node("air")
|
data[ivm] = node("air")
|
||||||
in_cave = false
|
in_cave = false
|
||||||
elseif cave[index3d] ^ 2 > 0.1 + dy / half then
|
elseif cave[index3d] ^ 2 > 0.1 + dy / half then
|
||||||
if terr + ground >= dy and not in_cave and dy > terr + ground - 10 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
|
elseif dy == 1 then
|
||||||
local sr = math.random(9)
|
local sr = math.random(9)
|
||||||
if not ocean and not swamp and not beach and sr == 1 then
|
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
|
elseif ocean or swamp or beach then
|
||||||
data[ivm] = node(node_filler)
|
data[ivm] = node(node_filler)
|
||||||
end
|
end
|
||||||
elseif ocean or swamp or beach then
|
elseif ocean or swamp or beach and dy < half then
|
||||||
data[ivm] = node("default:water_source")
|
data[ivm] = node(node_water)
|
||||||
else
|
else
|
||||||
data[ivm] = node("air")
|
data[ivm] = node("air")
|
||||||
end
|
end
|
||||||
in_cave = true
|
in_cave = true
|
||||||
lightmap[ivm] = 0
|
lightmap[ivm] = 0
|
||||||
elseif dy > terr + ground - depth_top then
|
elseif dy > terr + ground - depth_top then
|
||||||
data[ivm] = node(top)
|
data[ivm] = node(node_top)
|
||||||
lightmap[ivm] = 0
|
lightmap[ivm] = 0
|
||||||
in_cave = false
|
in_cave = false
|
||||||
write = true
|
write = true
|
||||||
elseif dy > terr + ground - depth_filler - depth_top then
|
elseif dy > terr + ground - depth_filler - depth_top then
|
||||||
data[ivm] = node("default:dirt")
|
data[ivm] = node(node_filler)
|
||||||
lightmap[ivm] = 0
|
lightmap[ivm] = 0
|
||||||
in_cave = false
|
in_cave = false
|
||||||
write = true
|
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 y = minp.y + get_height(x - minp.x, z - minp.z, biomes[biome].terrain_scale, ocean) + ground
|
||||||
|
|
||||||
local ivm = a:index(x, y, z)
|
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
|
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)]
|
local tree_type = biomes[biome].special_trees[math.random(#biomes[biome].special_trees)]
|
||||||
if tree_type then
|
if tree_type then
|
||||||
local schem = loud_walking.schematics[tree_type][math.random(#loud_walking.schematics[tree_type])]
|
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)
|
player:setpos(pos)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
--print(node.name)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
90
nodes.lua
|
@ -43,13 +43,9 @@ minetest.register_node("loud_walking:controls", {
|
||||||
puncher:set_hp(puncher:get_hp() - sr)
|
puncher:set_hp(puncher:get_hp() - sr)
|
||||||
elseif sr < 6 then
|
elseif sr < 6 then
|
||||||
local pos = puncher:getpos()
|
local pos = puncher:getpos()
|
||||||
if sr == 3 then
|
pos.x = pos.x + (math.random(-50, 50) * 160)
|
||||||
pos.x = pos.x + (math.random(-50, 50) * 160)
|
pos.y = pos.y + (math.random(-50, 50) * 160)
|
||||||
elseif sr == 4 then
|
pos.z = pos.z + (math.random(-50, 50) * 160)
|
||||||
pos.y = pos.y + (math.random(-50, 50) * 160)
|
|
||||||
elseif sr == 5 then
|
|
||||||
pos.z = pos.z + (math.random(-50, 50) * 160)
|
|
||||||
end
|
|
||||||
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
|
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)
|
puncher:setpos(pos)
|
||||||
end
|
end
|
||||||
|
@ -83,3 +79,83 @@ minetest.register_node("loud_walking:controls", {
|
||||||
end
|
end
|
||||||
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))
|
||||||
|
|
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 352 B |
After Width: | Height: | Size: 479 B |
After Width: | Height: | Size: 7.1 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 683 B |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 6.6 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 736 B |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 633 B |
|
@ -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.
|