Add some cave decorations.

master
Duane Robertson 2016-04-04 02:34:05 -05:00
parent 6b1bd05279
commit e092d32465
11 changed files with 558 additions and 9 deletions

519
deco_caves.lua Normal file
View File

@ -0,0 +1,519 @@
----------------------
-- Cave Decorations --
----------------------
-- Mushrooms and Speleothems
-- These are instantiated by voxel.lua since the decoration manager
-- only works at the surface of the world.
local light_max = 9
loud_walking.time_factor = 10
minetest.register_node("loud_walking:huge_mushroom_cap", {
description = "Huge Mushroom Cap",
tiles = {"loud_walking_mushroom_giant_cap.png", "loud_walking_mushroom_giant_under.png", "loud_walking_mushroom_giant_cap.png"},
is_ground_content = false,
paramtype = "light",
drawtype = "nodebox",
node_box = { type = "fixed",
fixed = {
{-0.5, -0.5, -0.33, 0.5, -0.33, 0.33},
{-0.33, -0.5, 0.33, 0.33, -0.33, 0.5},
{-0.33, -0.5, -0.33, 0.33, -0.33, -0.5},
{-0.33, -0.33, -0.33, 0.33, -0.17, 0.33},
} },
light_source = 4,
groups = {fleshy=1, dig_immediate=3, flammable=2, plant=1, leafdecay=1},
})
minetest.register_node("loud_walking:giant_mushroom_cap", {
description = "Giant Mushroom Cap",
tiles = {"loud_walking_mushroom_giant_cap.png", "loud_walking_mushroom_giant_under.png", "loud_walking_mushroom_giant_cap.png"},
is_ground_content = false,
paramtype = "light",
drawtype = "nodebox",
node_box = { type = "fixed",
fixed = {
{-0.4, -0.5, -0.4, 0.4, 0.0, 0.4},
{-0.75, -0.5, -0.4, -0.4, -0.25, 0.4},
{0.4, -0.5, -0.4, 0.75, -0.25, 0.4},
{-0.4, -0.5, -0.75, 0.4, -0.25, -0.4},
{-0.4, -0.5, 0.4, 0.4, -0.25, 0.75},
} },
light_source = 8,
groups = {fleshy=1, dig_immediate=3, flammable=2, plant=1, leafdecay=1},
})
minetest.register_node("loud_walking:giant_mushroom_stem", {
description = "Giant Mushroom Stem",
tiles = {"loud_walking_mushroom_giant_stem.png", "loud_walking_mushroom_giant_stem.png", "loud_walking_mushroom_giant_stem.png"},
is_ground_content = false,
groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2, plant=1},
sounds = default.node_sound_wood_defaults(),
paramtype = "light",
drawtype = "nodebox",
node_box = { type = "fixed", fixed = { {-0.25, -0.5, -0.25, 0.25, 0.5, 0.25}, }},
})
-- Mushroom stems can be used as wood, ala Journey to the Center of the Earth.
minetest.register_craft({
output = "default:wood",
recipe = {
{"loud_walking:giant_mushroom_stem"}
}
})
-- Caps can be cooked and eaten.
minetest.register_node("loud_walking:mushroom_steak", {
description = "Mushroom Steak",
drawtype = "plantlike",
paramtype = "light",
tiles = {"loud_walking_mushroom_steak.png"},
inventory_image = "loud_walking_mushroom_steak.png",
on_use = minetest.item_eat(4),
groups = {dig_immediate = 3, attached_node = 1},
})
minetest.register_craft({
type = "cooking",
output = "loud_walking:mushroom_steak",
recipe = "loud_walking:huge_mushroom_cap",
cooktime = 2,
})
minetest.register_craft({
type = "cooking",
output = "loud_walking:mushroom_steak 2",
recipe = "loud_walking:giant_mushroom_cap",
cooktime = 2,
})
-- Glowing fungal stone provides an eerie light.
minetest.register_node("loud_walking:glowing_fungal_stone", {
description = "Glowing Fungal Stone",
tiles = {"default_stone.png^loud_walking_glowing_fungal.png",},
is_ground_content = true,
light_source = 8,
groups = {cracky=3, stone=1},
drop = {items={ {items={"default:cobble"},}, {items={"loud_walking:glowing_fungus",},},},},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("loud_walking:glowing_fungus", {
description = "Glowing Fungus",
drawtype = "plantlike",
paramtype = "light",
tiles = {"loud_walking_glowing_fungus.png"},
inventory_image = "loud_walking_glowing_fungus.png",
groups = {dig_immediate = 3, attached_node = 1},
})
-- The fungus can be made into juice and then into glowing glass.
minetest.register_node("loud_walking:moon_juice", {
description = "Moon Juice",
drawtype = "plantlike",
paramtype = "light",
tiles = {"loud_walking_moon_juice.png"},
inventory_image = "loud_walking_moon_juice.png",
groups = {dig_immediate = 3, attached_node = 1},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("loud_walking:moon_glass", {
description = "Moon Glass",
drawtype = "glasslike",
tiles = {"default_glass.png",},
inventory_image = minetest.inventorycube("default_glass.png"),
is_ground_content = true,
light_source = default.LIGHT_MAX,
groups = {cracky=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_craft({
output = "loud_walking:moon_juice",
recipe = {
{"loud_walking:glowing_fungus", "loud_walking:glowing_fungus", "loud_walking:glowing_fungus"},
{"loud_walking:glowing_fungus", "loud_walking:glowing_fungus", "loud_walking:glowing_fungus"},
{"loud_walking:glowing_fungus", "vessels:glass_bottle", "loud_walking:glowing_fungus"},
},
})
minetest.register_craft({
output = "loud_walking:moon_glass",
type = "shapeless",
recipe = {
"loud_walking:moon_juice",
"loud_walking:moon_juice",
"default:glass",
},
})
-- What's a cave without speleothems?
local spel = {
{type1="stalactite", type2="stalagmite", tile="default_stone.png"},
{type1="stalactite_slimy", type2="stalagmite_slimy", tile="default_stone.png^loud_walking_algae.png"},
{type1="stalactite_mossy", type2="stalagmite_mossy", tile="default_stone.png^loud_walking_moss.png"},
{type1="icicle_down", type2="icicle_up", desc="Icicle", tile="caverealms_thin_ice.png", drop="default:ice"},
}
for _, desc in pairs(spel) do
minetest.register_node("loud_walking:"..desc.type1, {
description = (desc.desc or "Stalactite"),
tiles = {desc.tile},
is_ground_content = true,
walkable = false,
paramtype = "light",
--light_source = 14,
drop = (desc.drop or "loud_walking:stalactite"),
drawtype = "nodebox",
node_box = { type = "fixed",
fixed = {
{-0.07, 0.0, -0.07, 0.07, 0.5, 0.07},
{-0.04, -0.25, -0.04, 0.04, 0.0, 0.04},
{-0.02, -0.5, -0.02, 0.02, 0.25, 0.02},
} },
groups = {rock=1, cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("loud_walking:"..desc.type2, {
description = (desc.desc or "Stalagmite"),
tiles = {desc.tile},
is_ground_content = true,
walkable = false,
paramtype = "light",
--light_source = 14,
drop = "loud_walking:stalagmite",
drawtype = "nodebox",
node_box = { type = "fixed",
fixed = {
{-0.07, -0.5, -0.07, 0.07, 0.0, 0.07},
{-0.04, 0.0, -0.04, 0.04, 0.25, 0.04},
{-0.02, 0.25, -0.02, 0.02, 0.5, 0.02},
} },
groups = {rock=1, cracky=3},
sounds = default.node_sound_stone_defaults(),
})
end
-- They can be made into cobblestone, to get them out of inventory.
minetest.register_craft({
output = "default:cobble",
recipe = {
{"", "", ""},
{"loud_walking:stalactite", "loud_walking:stalactite", ""},
{"loud_walking:stalactite", "loud_walking:stalactite", ""},
},
})
minetest.register_craft({
output = "default:cobble",
recipe = {
{"", "", ""},
{"loud_walking:stalagmite", "loud_walking:stalagmite", ""},
{"loud_walking:stalagmite", "loud_walking:stalagmite", ""},
},
})
minetest.register_node("loud_walking:glowing_dirt", {
description = "Glowing Dirt",
tiles = {"default_dirt.png"},
groups = {crumbly = 3, soil = 1},
light_source = default.LIGHT_MAX,
sounds = default.node_sound_dirt_defaults(),
soil = {
base = "loud_walking:glowing_dirt",
dry = "loud_walking:glowing_soil",
wet = "loud_walking:glowing_soil_wet"
},
})
minetest.register_node("loud_walking:glowing_soil", {
description = "Glowing Soil",
tiles = {"default_dirt.png^farming_soil.png", "default_dirt.png"},
drop = "loud_walking:glowing_dirt",
groups = {crumbly=3, not_in_creative_inventory=1, soil=2, grassland = 1, field = 1},
sounds = default.node_sound_dirt_defaults(),
light_source = default.LIGHT_MAX,
soil = {
base = "loud_walking:glowing_dirt",
dry = "loud_walking:glowing_soil",
wet = "loud_walking:glowing_soil_wet"
},
})
minetest.register_node("loud_walking:glowing_soil_wet", {
description = "Wet Glowing Soil",
tiles = {"default_dirt.png^farming_soil_wet.png", "default_dirt.png^farming_soil_wet_side.png"},
drop = "loud_walking:glowing_dirt",
groups = {crumbly=3, not_in_creative_inventory=1, soil=3, wet = 1, grassland = 1, field = 1},
sounds = default.node_sound_dirt_defaults(),
light_source = default.LIGHT_MAX,
soil = {
base = "loud_walking:glowing_dirt",
dry = "loud_walking:glowing_soil",
wet = "loud_walking:glowing_soil_wet"
},
})
minetest.register_craft({
output = "loud_walking:glowing_dirt",
type = "shapeless",
recipe = {
"loud_walking:moon_juice",
"default:dirt",
},
})
--thin (transparent) ice
minetest.register_node("loud_walking:thin_ice", {
description = "Thin Ice",
tiles = {"caverealms_thin_ice.png"},
is_ground_content = true,
groups = {cracky=3},
sounds = default.node_sound_glass_defaults(),
use_texture_alpha = true,
light_source = 1,
drawtype = "glasslike",
sunlight_propagates = true,
freezemelt = "default:water_source",
paramtype = "light",
})
minetest.register_node("loud_walking:stone_with_moss", {
description = "Cave Stone with Moss",
tiles = {"default_stone.png^loud_walking_moss.png"},
is_ground_content = true,
light_source = 1,
groups = {stone=1, crumbly=3},
drop = 'default:cobble',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.25},
}),
})
minetest.register_node("loud_walking:stone_with_lichen", {
description = "Cave Stone with Lichen",
tiles = {"default_stone.png^loud_walking_lichen.png"},
is_ground_content = true,
light_source = 1,
groups = {stone=1, crumbly=3},
drop = 'default:cobble',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.25},
}),
})
minetest.register_node("loud_walking:stone_with_algae", {
description = "Cave Stone with Algae",
tiles = {"default_stone.png^loud_walking_algae.png"},
is_ground_content = true,
light_source = 1,
groups = {stone=1, crumbly=3},
drop = 'default:cobble',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.25},
}),
})
minetest.register_node("loud_walking:stone_with_salt", {
description = "Cave Stone with Salt",
tiles = {"caverealms_salty2.png"},--{"caverealms_salty2.png^caverealms_salty.png", "caverealms_salty2.png", "caverealms_salty2.png^caverealms_salty_side.png"},
light_source = 9,
paramtype = "light",
use_texture_alpha = true,
drawtype = "glasslike",
sunlight_propagates = true,
is_ground_content = true,
groups = {stone=1, crumbly=3},
sounds = default.node_sound_glass_defaults(),
})
--Glow Obsidian
minetest.register_node("loud_walking:glow_obsidian", {
description = "Glowing Obsidian",
tiles = {"caverealms_glow_obsidian.png"},
is_ground_content = true,
groups = {stone=2, crumbly=1},
light_source = 7,
sounds = default.node_sound_stone_defaults({
footstep = {name="default_stone_footstep", gain=0.25},
}),
})
--Glow Obsidian 2 - has traces of lava
minetest.register_node("loud_walking:glow_obsidian_2", {
description = "Hot Glow Obsidian",
tiles = {"caverealms_glow_obsidian2.png"},
is_ground_content = true,
groups = {stone=2, crumbly=1, hot=1},
damage_per_second = 1,
light_source = 9,
sounds = default.node_sound_stone_defaults({
footstep = {name="default_stone_footstep", gain=0.25},
}),
})
--minetest.register_node("loud_walking:bright_air", {
-- drawtype = "glasslike",
-- tiles = {"technic_light.png"},
-- paramtype = "light",
-- groups = {not_in_creative_inventory=1},
-- drop = "",
-- walkable = false,
-- buildable_to = true,
-- sunlight_propagates = true,
-- light_source = LIGHT_MAX,
-- pointable = false,
--})
--define special flame so that it does not expire
minetest.register_node("loud_walking:constant_flame", {
description = "Fire",
drawtype = "plantlike",
tiles = {{
name="fire_basic_flame_animated.png",
animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},
}},
inventory_image = "fire_basic_flame.png",
light_source = 14,
groups = {igniter=2,dig_immediate=3,hot=3, not_in_creative_inventory=1},
drop = '',
walkable = false,
buildable_to = true,
damage_per_second = 4,
--after_place_node = function(pos, placer)
-- if pos.y > -7000 then
-- minetest.remove_node(pos)
-- end
--end,
})
--Hot Cobble - cobble with lava instead of mortar XD
minetest.register_node("loud_walking:hot_cobble", {
description = "Hot Cobble",
tiles = {"caverealms_hot_cobble.png"},
is_ground_content = true,
groups = {crumbly=2, hot=1},
damage_per_second = 1,
light_source = 3,
sounds = default.node_sound_stone_defaults({
footstep = {name="default_stone_footstep", gain=0.25},
}),
})
-- mushroom growth
minetest.register_abm({
nodenames = {"flowers:mushroom_brown", "flowers:mushroom_red"},
interval = 50 * loud_walking.time_factor,
chance = 100,
action = function(pos, node)
if pos.y > -50 then
return
end
local pos_up = {x=pos.x,y=pos.y+1,z=pos.z}
local node_up = minetest.get_node_or_nil(pos_up)
if not node_up then
return
end
if node_up.name ~= "air" then
return
end
local node_under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z})
if not node_under then
return
end
if minetest.get_item_group(node_under.name, "soil") ~= 0 and
minetest.get_node_light(pos_up, nil) <= light_max then
minetest.set_node(pos_up, {name = "loud_walking:huge_mushroom_cap"})
minetest.set_node(pos, {name = "loud_walking:giant_mushroom_stem"})
end
end
})
-- mushroom growth
minetest.register_abm({
nodenames = {"loud_walking:huge_mushroom_cap"},
interval = 100 * loud_walking.time_factor,
chance = 150,
action = function(pos, node)
if minetest.get_node_light(pos, nil) >= 14 then
minetest.set_node(pos, {name = "air"})
return
end
local pos_up = {x=pos.x,y=pos.y+1,z=pos.z}
local node_up = minetest.get_node_or_nil(pos_up)
if not node_up then
return
end
if node_up.name ~= "air" then
return
end
local node_under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z})
if not node_under or node_under.name ~= "loud_walking:giant_mushroom_stem" then
return
end
node_under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 2, z = pos.z})
if not node_under then
return
end
if minetest.get_item_group(node_under.name, "soil") ~= 0 and
minetest.get_node_light(pos_up, nil) <= light_max then
minetest.set_node(pos_up, {name = "loud_walking:giant_mushroom_cap"})
minetest.set_node(pos, {name = "loud_walking:giant_mushroom_stem"})
end
end
})
-- mushroom growth
minetest.register_abm({
nodenames = {"loud_walking:giant_mushroom_stem"},
interval = 5 * loud_walking.time_factor,
chance = 5,
action = function(pos, node)
local pos_up = {x=pos.x,y=pos.y+1,z=pos.z}
local node_up = minetest.get_node_or_nil(pos_up)
if not node_up then
return
end
if node_up.name ~= "air" then
return
end
if minetest.get_node_light(pos_up, nil) <= light_max then
minetest.set_node(pos_up, {name = "loud_walking:huge_mushroom_cap"})
end
end
})
-- mushroom spread
minetest.register_abm({
nodenames = {"loud_walking:giant_mushroom_cap", "loud_walking:huge_mushroom_cap"},
interval = 3 * loud_walking.time_factor,
chance = 40,
action = function(pos, node)
if minetest.get_node_light(pos, nil) >= 14 then
minetest.set_node(pos, {name = "air"})
return
end
local pos_down = pos
pos_down.y = pos_down.y - 1
local pos1, count = minetest.find_nodes_in_area_under_air(vector.subtract(pos_down, 4), vector.add(pos_down, 4), {"group:soil"})
if #pos1 < 1 then
return
end
local random = pos1[math.random(1, #pos1)]
random.y = random.y + 1
local mushroom_type
if math.random(1,2) == 1 then
mushroom_type = "flowers:mushroom_red"
else
mushroom_type = "flowers:mushroom_brown"
end
if minetest.get_node_light(random, nil) <= light_max then
minetest.set_node(random, {name = mushroom_type})
end
end
})

View File

@ -79,6 +79,7 @@ end
dofile(loud_walking.path .. "/nodes.lua")
dofile(loud_walking.path .. "/deco.lua")
dofile(loud_walking.path .. "/deco_caves.lua")
dofile(loud_walking.path .. "/mapgen.lua")

View File

@ -178,6 +178,7 @@ local function get_biome(px, pz)
end
local biome = biome_names[rarity][math.random(#biome_names[rarity])]
return biome
--return "glacier"
end
local function get_decoration(biome)
@ -267,7 +268,11 @@ function loud_walking.generate(p_minp, p_maxp, seed)
local terr = get_height(dx, dz, biomes[biome].terrain_scale, ocean, index)
local in_cave = false
if biome == "underground" then
terr = half - 5
end
local cave_height = 0
for y = minp.y, maxp.y do
local dy = y - minp.y
if pod then
@ -325,20 +330,32 @@ function loud_walking.generate(p_minp, p_maxp, seed)
elseif dy > terr + ground then
data[ivm] = node("air")
in_cave = false
elseif cave[index3d] ^ 2 > 0.1 + dy / half then
elseif cave[index3d] ^ 2 > (biome == "underground" and 0.5 or 1.3 - math.sin(dy / (half * 0.2))) then
if terr + ground >= dy and not in_cave and dy > terr + ground - 10 then
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
if not ocean and not swamp and not beach and math.random(6) == 1 then
data[ivm] = node("default:lava_source")
elseif sr > 6 then
data[ivm] = node(node_stone)
elseif ocean or swamp or beach then
data[ivm] = node(node_filler)
end
elseif ocean or swamp or beach and dy < half then
elseif (ocean or swamp or beach) and not in_cave and node_stone == "default:stone" and dy < half and math.random(20) == 1 then
data[ivm] = node("loud_walking:glowing_fungal_stone")
elseif (ocean or swamp or beach) and dy < half then
data[ivm] = node(node_water)
elseif cave_height == 2 and node_filler == "default:dirt" and data[ivm - 3] == node(node_stone) and math.random(40) == 1 then
data[ivm] = node("loud_walking:giant_mushroom_cap")
data[ivm - a.ystride] = node("loud_walking:giant_mushroom_stem")
data[ivm - 2 * a.ystride] = node("loud_walking:giant_mushroom_stem")
data[ivm - 3 * a.ystride] = node(node_filler)
elseif cave_height == 1 and node_filler == "default:dirt" and data[ivm - 3] == node(node_stone) and math.random(20) == 1 then
data[ivm] = node("loud_walking:huge_mushroom_cap")
data[ivm - a.ystride] = node("loud_walking:giant_mushroom_stem")
data[ivm - 2 * a.ystride] = node(node_filler)
elseif not in_cave and node_stone == "default:stone" and math.random(10) == 1 then
data[ivm] = node("loud_walking:stalagmite")
elseif not in_cave and node_stone == "default:ice" and math.random(10) == 1 then
data[ivm] = node("loud_walking:icicle_up")
else
data[ivm] = node("air")
end
@ -356,6 +373,13 @@ function loud_walking.generate(p_minp, p_maxp, seed)
write = true
else
data[ivm] = node(node_stone)
if in_cave and node_stone == "default:stone" and math.random(20) == 1 then
data[ivm] = node("loud_walking:glowing_fungal_stone")
elseif in_cave and not (ocean or swamp or beach) and node_stone == "default:stone" and math.random(10) == 1 then
data[ivm - a.ystride] = node("loud_walking:stalactite")
elseif in_cave and not (ocean or swamp or beach) and node_stone == "default:ice" and math.random(10) == 1 then
data[ivm - a.ystride] = node("loud_walking:icicle_down")
end
lightmap[ivm] = 0
in_cave = false
write = true
@ -366,6 +390,11 @@ function loud_walking.generate(p_minp, p_maxp, seed)
write = true
end
if in_cave then
cave_height = cave_height + 1
else
cave_height = 0
end
ivm = ivm + a.ystride
index3d = index3d + csize.x
end
@ -377,8 +406,8 @@ function loud_walking.generate(p_minp, p_maxp, seed)
for dz = 0, 75, 5 do
for dx = 0, 75, 5 do
if math.random(2) == 1 then
local x = minp.x + dx + math.random(0, 4)
local z = minp.z + dz + math.random(0, 4)
local x = minp.x + dx + math.random(5) - 1
local z = minp.z + dz + math.random(5) - 1
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)
@ -406,7 +435,7 @@ function loud_walking.generate(p_minp, p_maxp, seed)
minetest.generate_decorations(vm, minp, maxp)
--vm:set_param2_data(p2data)
--vm:set_lighting({day = 15, night = 0})
vm:set_light_data(lightmap)
--vm:set_light_data(lightmap)
vm:calc_lighting(minp, maxp, false)
vm:update_liquids()
vm:write_to_map()

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB