rearranging and renaming

This commit is contained in:
FaceDeer
2017-03-16 02:17:55 -06:00
parent 48f89c33c8
commit 08d85dd655
32 changed files with 35 additions and 40 deletions

106
trees/black_cap.lua Normal file
View File

@ -0,0 +1,106 @@
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
--stem
minetest.register_node("dfcaverns:black_cap_stem", {
description = S("Black Cap Stem"),
tiles = {"dfcaverns_black_cap_top.png","dfcaverns_black_cap_top.png","dfcaverns_black_cap_side.png",},
is_ground_content = true,
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
})
--cap
minetest.register_node("dfcaverns:black_cap", {
description = S("Black Cap"),
tiles = {"dfcaverns_black_cap_top.png","dfcaverns_black_cap_top.png","dfcaverns_black_cap_side.png^[transformR90",},
is_ground_content = true,
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
})
--gills
minetest.register_node("dfcaverns:black_cap_gills", {
description = S("Black Cap Gills"),
tiles = {"dfcaverns_black_cap_gills.png"},
is_ground_content = true,
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drawtype = "plantlike",
paramtype = "light",
drop = {
max_items = 1,
items = {
{
items = {'dfcaverns:black_cap_sapling'},
rarity = 10,
},
{
items = {'dfcaverns:black_cap_gills'},
}
}
},
})
-- sapling
minetest.register_node("dfcaverns:black_cap_sapling", {
description = S("Black Cap Spawn"),
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"dfcaverns_black_cap_sapling.png"},
inventory_image = "dfcaverns_black_cap_sapling.png",
wield_image = "dfcaverns_black_cap_sapling.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
},
groups = {snappy = 2, dig_immediate = 3, flammable = 2,
attached_node = 1, sapling = 1, light_sensitive_fungus = 11},
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(dfcaverns.config.black_cap_min_growth_delay,dfcaverns.config.black_cap_max_growth_delay))
end,
on_timer = function(pos)
minetest.set_node(pos, {name="air"})
dfcaverns.spawn_black_cap(pos)
end,
})
local c_stem = minetest.get_content_id("dfcaverns:black_cap_stem")
local c_cap = minetest.get_content_id("dfcaverns:black_cap")
local c_gills = minetest.get_content_id("dfcaverns:black_cap_gills")
dfcaverns.spawn_black_cap = function(pos)
local x, y, z = pos.x, pos.y, pos.z
local stem_height = math.random(1,5)
local cap_radius = math.random(2,3)
local maxy = y + stem_height + 3
local vm = minetest.get_voxel_manip()
local minp, maxp = vm:read_from_map(
{x = x - cap_radius, y = y, z = z - cap_radius},
{x = x + cap_radius, y = maxy + 3, z = z + cap_radius}
)
local area = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm:get_data()
subterrane:giant_shroom(area:indexp(pos), area, data, c_stem, c_cap, c_gills, stem_height, cap_radius)
vm:set_data(data)
vm:write_to_map()
vm:update_map()
end
dfcaverns.spawn_black_cap_vm = function(vi, area, data)
local stem_height = math.random(1,5)
local cap_radius = math.random(2,3)
subterrane:giant_shroom(vi, area, data, c_stem, c_cap, c_gills, stem_height, cap_radius)
end

216
trees/blood_thorn.lua Normal file
View File

@ -0,0 +1,216 @@
--------------------------------------------------
-- Blood thorn
-- Max trunk height 5
-- red with purple mottling
-- High density wood
-- Depth 3
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
minetest.register_node("dfcaverns:blood_thorn", {
description = S("Blood Thorn Trunk"),
tiles = {"dfcaverns_blood_thorn_top.png", "dfcaverns_blood_thorn_top.png",
"dfcaverns_blood_thorn_side.png", "dfcaverns_blood_thorn_side.png", "dfcaverns_blood_thorn_side.png", "dfcaverns_blood_thorn_side.png"},
paramtype2 = "facedir",
paramtype = "light",
groups = {choppy = 3, flammable = 2, light_sensitive_fungus = 11},
_dfcaverns_dead_node = "dfcaverns:blood_thorn_dead",
sounds = default.node_sound_wood_defaults(),
on_place = minetest.rotate_node,
})
minetest.register_node("dfcaverns:blood_thorn_dead", {
description = S("Dead Blood Thorn Trunk"),
tiles = {"dfcaverns_blood_thorn_top.png^[multiply:#804000", "dfcaverns_blood_thorn_top.png^[multiply:#804000",
"dfcaverns_blood_thorn_side.png^[multiply:#804000"},
paramtype2 = "facedir",
groups = {choppy = 3, flammable = 2},
sounds = default.node_sound_wood_defaults(),
on_place = minetest.rotate_node,
})
minetest.register_node("dfcaverns:blood_thorn_spike", {
description = S("Blood Thorn Spike"),
tiles = {
"dfcaverns_blood_thorn_spike_side.png^[transformR90",
"dfcaverns_blood_thorn_spike_side.png^[transformR270",
"dfcaverns_blood_thorn_spike_side.png",
"dfcaverns_blood_thorn_spike_side.png^[transformR180",
"dfcaverns_blood_thorn_spike_front.png",
"dfcaverns_blood_thorn_spike_front.png"
},
groups = {choppy = 3, flammable = 2, fall_damage_add_percent=100, light_sensitive_fungus = 11},
_dfcaverns_dead_node = "dfcaverns:blood_thorn_spike_dead",
sounds = default.node_sound_wood_defaults(),
drawtype = "nodebox",
climbable = true,
damage_per_second = 1,
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.1875, -0.1875, 0.1875, 0.1875, 0.1875, 0.5}, -- base
{-0.125, -0.125, -0.125, 0.125, 0.125, 0.1875}, -- mid
{-0.0625, -0.0625, -0.5, 0.0625, 0.0625, -0.125}, -- tip
}
},
})
minetest.register_node("dfcaverns:blood_thorn_spike_dead", {
description = S("Dead Blood Thorn Spike"),
tiles = {
"dfcaverns_blood_thorn_spike_side.png^[transformR90^[multiply:#804000",
"dfcaverns_blood_thorn_spike_side.png^[transformR270^[multiply:#804000",
"dfcaverns_blood_thorn_spike_side.png^[multiply:#804000",
"dfcaverns_blood_thorn_spike_side.png^[transformR180^[multiply:#804000",
"dfcaverns_blood_thorn_spike_front.png^[multiply:#804000",
"dfcaverns_blood_thorn_spike_front.png^[multiply:#804000"
},
groups = {choppy = 3, flammable = 2, fall_damage_add_percent=100},
sounds = default.node_sound_wood_defaults(),
drawtype = "nodebox",
climbable = true,
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.1875, -0.1875, 0.1875, 0.1875, 0.1875, 0.5}, -- base
{-0.125, -0.125, -0.125, 0.125, 0.125, 0.1875}, -- mid
{-0.0625, -0.0625, -0.5, 0.0625, 0.0625, -0.125}, -- tip
}
},
})
local spike_directions = {
{dir={x=0,y=0,z=1}, facedir=2},
{dir={x=0,y=0,z=-1}, facedir=0},
{dir={x=1,y=0,z=0}, facedir=3},
{dir={x=-1,y=0,z=0}, facedir=1}
}
-- This ensures consistent random maximum to bloodthorn growth
local max_bloodthorn_height = function(pos)
local next_seed = math.random(1, 1000000000)
math.randomseed(pos.x + pos.z * 2 ^ 8)
local output = math.random(3,6)
math.randomseed(next_seed)
return output
end
function dfcaverns.grow_blood_thorn(pos, node)
if node.param2 >= 4 then
return
end
pos.y = pos.y - 1
if minetest.get_item_group(minetest.get_node(pos).name, "sand") == 0 then
return
end
pos.y = pos.y + 1
local height = 0
local max_height = max_bloodthorn_height(pos)
while node.name == "dfcaverns:blood_thorn" and height < max_height do
height = height + 1
pos.y = pos.y + 1
node = minetest.get_node(pos)
end
if height == 7 or node.name ~= "air" then
return
end
minetest.set_node(pos, {name = "dfcaverns:blood_thorn"})
local dir = spike_directions[math.random(1,4)]
local spike_pos = vector.add(pos, dir.dir)
if minetest.get_node(spike_pos).name == "air" then
minetest.set_node(spike_pos, {name="dfcaverns:blood_thorn_spike", param2=dir.facedir})
end
dir = spike_directions[math.random(1,4)]
spike_pos = vector.add(pos, dir.dir)
if minetest.get_node(spike_pos).name == "air" then
minetest.set_node(spike_pos, {name="dfcaverns:blood_thorn_spike", param2=dir.facedir})
end
return true
end
minetest.register_abm({
label = "Grow Blood Thorn",
nodenames = {"dfcaverns:blood_thorn"},
catch_up = true,
interval = dfcaverns.config.blood_thorn_growth_interval,
chance = dfcaverns.config.blood_thorn_growth_chance,
action = function(pos, node)
dfcaverns.grow_blood_thorn(pos, node)
end
})
function dfcaverns.spawn_blood_thorn(pos)
local height = max_bloodthorn_height(pos)
local x, y, z = pos.x, pos.y, pos.z
local maxy = y + height -- Trunk top
local vm = minetest.get_voxel_manip()
local minp, maxp = vm:read_from_map(
{x = x - 1, y = y, z = z - 1},
{x = x + 1, y = maxy, z = z + 1}
)
local area = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm:get_data()
local data_param2 = vm:get_param2_data()
dfcaverns.spawn_blood_thorn_vm(area:indexp(pos), area, data, data_param2, height)
vm:set_data(data)
vm:set_param2_data(data_param2)
vm:write_to_map()
vm:update_map()
end
local c_air = minetest.get_content_id("air")
local c_ignore = minetest.get_content_id("ignore")
local c_blood_thorn = minetest.get_content_id("dfcaverns:blood_thorn")
local c_blood_thorn_spike = minetest.get_content_id("dfcaverns:blood_thorn_spike")
dfcaverns.spawn_blood_thorn_vm = function(vi, area, data, data_param2, height)
local pos = area:position(vi)
if height == nil then height = max_bloodthorn_height(pos) end
local x = pos.x
local y = pos.y
local z = pos.z
local maxy = y + height -- Trunk top
for yy = y, maxy do
local vi = area:index(x, yy, z)
local node_id = data[vi]
if node_id == c_air or node_id == c_ignore then
data[vi] = c_blood_thorn
local dir = spike_directions[math.random(1,4)]
local spike_pos = {x = pos.x + dir.dir.x, y = yy, z = pos.z + dir.dir.z}
vi = area:indexp(spike_pos)
if data[vi] == c_air or data[vi] == c_c_ignore then
data[vi] = c_blood_thorn_spike
data_param2[vi] = dir.facedir
end
dir = spike_directions[math.random(1,4)]
spike_pos = {x = pos.x + dir.dir.x, y = yy, z = pos.z + dir.dir.z}
vi = area:indexp(spike_pos)
if data[vi] == c_air or data[vi] == c_c_ignore then
data[vi] = c_blood_thorn_spike
data_param2[vi] = dir.facedir
end
else
break
end
end
end

184
trees/fungiwood.lua Normal file
View File

@ -0,0 +1,184 @@
--------------------------------------------------
-- Fungiwood
-- fine grain
-- Max trunk height 8
-- depth 1-2
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
minetest.register_node("dfcaverns:fungiwood", {
description = S("Fungiwood Trunk"),
tiles = {"dfcaverns_fungiwood.png"},
paramtype2 = "facedir",
is_ground_content = false,
groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3},
sounds = default.node_sound_wood_defaults(),
on_place = minetest.rotate_node
})
minetest.register_node("dfcaverns:fungiwood_shelf",{
description = S("Fungiwood Shelf"),
tiles = {"dfcaverns_fungiwood.png", "dfcaverns_fungiwood_shelf_underside.png", "dfcaverns_fungiwood.png"},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.5, 0.375, -0.5, 0.5, 0.5, 0.5}, -- NodeBox1
{-0.5, 0.3125, -0.0625, 0.5, 0.375, 0.0625}, -- NodeBox2
{-0.0625, 0.3125, -0.5, 0.0625, 0.375, 0.5}, -- NodeBox3
}
},
is_ground_content = false,
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
drop = {
max_items = 1,
items = {
{items = {"dfcaverns:fungiwood_sapling"}, rarity = 20},
{items = {"dfcaverns:fungiwood_shelf"}}
}
},
sounds = default.node_sound_leaves_defaults(),
after_place_node = default.after_place_leaves,
})
minetest.register_node("dfcaverns:fungiwood_sapling", {
description = S("Fungiwood Spawn"),
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"dfcaverns_fungiwood_sapling.png"},
inventory_image = "dfcaverns_fungiwood_sapling.png",
wield_image = "dfcaverns_fungiwood_sapling.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
},
groups = {snappy = 2, dig_immediate = 3, flammable = 2,
attached_node = 1, sapling = 1, light_sensitive_fungus = 11},
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(dfcaverns.config.fungiwood_min_growth_delay,dfcaverns.config.fungiwood_max_growth_delay))
end,
on_timer = function(pos)
minetest.set_node(pos, {name="air"})
dfcaverns.spawn_fungiwood(pos)
end,
})
local c_air = minetest.get_content_id("air")
local c_ignore = minetest.get_content_id("ignore")
local c_fungiwood = minetest.get_content_id("dfcaverns:fungiwood")
local c_fungiwood_shelf = minetest.get_content_id("dfcaverns:fungiwood_shelf")
function dfcaverns.spawn_fungiwood(pos)
local x, y, z = pos.x, pos.y, pos.z
local height = math.random(6, 10)
local maxy = y + height -- Trunk top
local vm = minetest.get_voxel_manip()
local minp, maxp = vm:read_from_map(
{x = x - 3, y = y, z = z - 3},
{x = x + 3, y = maxy, z = z + 3}
)
local area = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm:get_data()
dfcaverns.spawn_fungiwood_vm(area:indexp(pos), area, data, height)
vm:set_data(data)
vm:write_to_map()
vm:update_map()
end
dfcaverns.spawn_fungiwood_vm = function(vi, area, data, height)
if height == nil then height = math.random(6, 10) end
local pos = area:position(vi)
local x = pos.x
local y = pos.y
local z = pos.z
local maxy = y + height -- Trunk top
-- Upper branches layer
local dev = 3
for yy = maxy - 2, maxy do
for zz = z - dev, z + dev do
local vi = area:index(x - dev, yy, zz)
local via = area:index(x - dev, yy + 1, zz)
for xx = x - dev, x + dev do
if math.random() < 0.95 - dev * 0.05 then
local node_id = data[vi]
if node_id == c_air or node_id == c_ignore then
data[vi] = c_fungiwood_shelf
end
end
vi = vi + 1
via = via + 1
end
end
dev = dev - 1
end
-- Lower branches layer
local my = 0
for i = 1, 20 do -- Random 2x2 squares of shelf
local xi = x + math.random(-3, 2)
local yy = maxy + math.random(-6, -5)
local zi = z + math.random(-3, 2)
if yy > my then
my = yy
end
for zz = zi, zi+1 do
local vi = area:index(xi, yy, zz)
local via = area:index(xi, yy + 1, zz)
for xx = xi, xi + 1 do
local node_id = data[vi]
if node_id == c_air or node_id == c_ignore then
data[vi] = c_fungiwood_shelf
end
vi = vi + 1
via = via + 1
end
end
end
dev = 2
for yy = my + 1, my + 2 do
for zz = z - dev, z + dev do
local vi = area:index(x - dev, yy, zz)
local via = area:index(x - dev, yy + 1, zz)
for xx = x - dev, x + dev do
if math.random() < 0.95 - dev * 0.05 then
local node_id = data[vi]
if node_id == c_air or node_id == c_ignore then
data[vi] = c_fungiwood_shelf
end
end
vi = vi + 1
via = via + 1
end
end
dev = dev - 1
end
-- Trunk
for yy = y, maxy do
local vi = area:index(x, yy, z)
local node_id = data[vi]
if node_id == c_air or node_id == c_ignore or
node_id == c_fungiwood_shelf then
data[vi] = c_fungiwood
end
end
end

104
trees/goblin_cap.lua Normal file
View File

@ -0,0 +1,104 @@
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
--stem
minetest.register_node("dfcaverns:goblin_cap_stem", {
description = S("Goblin Cap Stem"),
tiles = {"dfcaverns_goblin_cap_stem.png"},
is_ground_content = true,
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
})
--cap
minetest.register_node("dfcaverns:goblin_cap", {
description = S("Goblin Cap"),
tiles = {"dfcaverns_goblin_cap.png"},
is_ground_content = true,
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
})
--gills
minetest.register_node("dfcaverns:goblin_cap_gills", {
description = S("Goblin Cap Gills"),
tiles = {"dfcaverns_goblin_cap_gills.png"},
is_ground_content = true,
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drawtype = "plantlike",
paramtype = "light",
drop = {
max_items = 1,
items = {
{
items = {'dfcaverns:goblin_cap_sapling'},
rarity = 15,
},
{
items = {'dfcaverns:goblin_cap_gills'},
}
}
},
})
-- sapling
minetest.register_node("dfcaverns:goblin_cap_sapling", {
description = S("Goblin Cap Spawn"),
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"dfcaverns_goblin_cap_sapling.png"},
inventory_image = "dfcaverns_goblin_cap_sapling.png",
wield_image = "dfcaverns_goblin_cap_sapling.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
},
groups = {snappy = 2, dig_immediate = 3, flammable = 2,
attached_node = 1, sapling = 1, light_sensitive_fungus = 11},
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(dfcaverns.config.goblin_cap_min_growth_delay,dfcaverns.config.goblin_cap_max_growth_delay))
end,
on_timer = function(pos)
minetest.set_node(pos, {name="air"})
dfcaverns.spawn_goblin_cap(pos)
end,
})
local c_stem = minetest.get_content_id("dfcaverns:goblin_cap_stem")
local c_cap = minetest.get_content_id("dfcaverns:goblin_cap")
local c_gills = minetest.get_content_id("dfcaverns:goblin_cap_gills")
dfcaverns.spawn_goblin_cap = function(pos)
local x, y, z = pos.x, pos.y, pos.z
local stem_height = math.random(1,3)
local cap_radius = math.random(3,6)
local maxy = y + stem_height + 3
local vm = minetest.get_voxel_manip()
local minp, maxp = vm:read_from_map(
{x = x - cap_radius, y = y, z = z - cap_radius},
{x = x + cap_radius, y = maxy + 3, z = z + cap_radius}
)
local area = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm:get_data()
subterrane:giant_shroom(area:indexp(pos), area, data, c_stem, c_cap, c_gills, stem_height, cap_radius)
vm:set_data(data)
vm:write_to_map()
vm:update_map()
end
dfcaverns.spawn_goblin_cap_vm = function(vi, area, data)
local stem_height = math.random(1,3)
local cap_radius = math.random(3,6)
subterrane:giant_shroom(vi, area, data, c_stem, c_cap, c_gills, stem_height, cap_radius)
end

128
trees/nether_cap.lua Normal file
View File

@ -0,0 +1,128 @@
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
--stem
minetest.register_node("dfcaverns:nether_cap_stem", {
description = S("Nether Cap Stem"),
tiles = {"dfcaverns_nether_cap_stem.png"},
is_ground_content = true,
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, puts_out_fire = 1, cools_lava = 1},
sounds = default.node_sound_wood_defaults(),
})
--cap
minetest.register_node("dfcaverns:nether_cap", {
description = S("Nether Cap"),
tiles = {"dfcaverns_nether_cap.png"},
is_ground_content = true,
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, puts_out_fire = 1, cools_lava = 1 },
sounds = default.node_sound_wood_defaults(),
})
--gills
minetest.register_node("dfcaverns:nether_cap_gills", {
description = S("Nether Cap Gills"),
tiles = {"dfcaverns_nether_cap_gills.png"},
is_ground_content = true,
groups = {snappy = 3, leafdecay = 3, leaves = 1, puts_out_fire = 1, cools_lava = 1},
sounds = default.node_sound_leaves_defaults(),
drawtype = "plantlike",
paramtype = "light",
drop = {
max_items = 1,
items = {
{
items = {'dfcaverns:nether_cap_sapling'},
rarity = 10,
},
{
items = {'dfcaverns:nether_cap_gills'},
}
}
},
})
-- sapling
minetest.register_node("dfcaverns:nether_cap_sapling", {
description = S("Nether Cap Spawn"),
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"dfcaverns_nether_cap_sapling.png"},
inventory_image = "dfcaverns_nether_cap_sapling.png",
wield_image = "dfcaverns_nether_cap_sapling.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
},
groups = {snappy = 2, dig_immediate = 3,
attached_node = 1, sapling = 1, light_sensitive_fungus = 11},
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(dfcaverns.config.nether_cap_min_growth_delay,dfcaverns.config.nether_cap_max_growth_delay))
end,
on_timer = function(pos)
minetest.set_node(pos, {name="air"})
dfcaverns.spawn_nether_cap(pos)
end,
})
local c_stem = minetest.get_content_id("dfcaverns:nether_cap_stem")
local c_cap = minetest.get_content_id("dfcaverns:nether_cap")
local c_gills = minetest.get_content_id("dfcaverns:nether_cap_gills")
dfcaverns.spawn_nether_cap = function(pos)
local x, y, z = pos.x, pos.y, pos.z
local stem_height = math.random(1,3)
local cap_radius = math.random(2,3)
local maxy = y + stem_height + 3
local vm = minetest.get_voxel_manip()
local minp, maxp = vm:read_from_map(
{x = x - cap_radius, y = y, z = z - cap_radius},
{x = x + cap_radius, y = maxy + 3, z = z + cap_radius}
)
local area = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm:get_data()
subterrane:giant_shroom(area:indexp(pos), area, data, c_stem, c_cap, c_gills, stem_height, cap_radius)
vm:set_data(data)
vm:write_to_map()
vm:update_map()
end
dfcaverns.spawn_nether_cap_vm = function(vi, area, data)
local stem_height = math.random(1,3)
local cap_radius = math.random(2,3)
subterrane:giant_shroom(vi, area, data, c_stem, c_cap, c_gills, stem_height, cap_radius)
end
minetest.register_abm{
label = "nether cap water freezing",
nodenames = {"default:water_source", "default:river_water_source",},
neighbors = {"dfcaverns:nether_cap_stem", "dfcaverns:nether_cap", "dfcaverns:nether_cap_gills"},
interval = 1,
chance = 5,
catch_up = true,
action = function(pos)
minetest.swap_node(pos, {name="default:ice"})
end,
}
minetest.register_abm{
label = "nether cap flowing water freezing",
nodenames = {"default:water_flowing", "default:river_water_flowing"},
neighbors = {"dfcaverns:nether_cap_stem", "dfcaverns:nether_cap", "dfcaverns:nether_cap_gills"},
interval = 1,
chance = 1,
catch_up = true,
action = function(pos)
minetest.swap_node(pos, {name="default:snow"})
end,
}

242
trees/spore_tree.lua Normal file
View File

@ -0,0 +1,242 @@
--------------------------------------------------
-- Spore Tree
-- Teal
-- raining spores
-- Max trunk height 5
-- depth 2-3
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
minetest.register_node("dfcaverns:spore_tree", {
description = S("Spore Tree"),
tiles = {"dfcaverns_spore_tree_top.png", "dfcaverns_spore_tree_top.png", "dfcaverns_spore_tree.png"},
paramtype2 = "facedir",
is_ground_content = false,
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
on_place = minetest.rotate_node,
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
minetest.set_node(pos, {name="air"})
minetest.spawn_tree(pos, dfcaverns.spore_tree_model)
end,
})
minetest.register_node("dfcaverns:spore_tree_frond", {
description = S("Spore Tree Frond"),
waving = 1,
tiles = {"dfcaverns_spore_tree.png"},
is_ground_content = false,
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
walkable = false,
climbable = true,
drawtype = "nodebox",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625},
{-0.0625, -0.0625, -0.5, 0.0625, 0.0625, 0.5},
{-0.5, -0.0625, -0.0625, 0.5, 0.0625, 0.0625},
}
},
sounds = default.node_sound_leaves_defaults(),
after_place_node = default.after_place_leaves,
})
minetest.register_node("dfcaverns:spore_tree_pod", {
description = S("Spore Tree Fruiting Body"),
waving = 1,
tiles = {"dfcaverns_spore_tree.png"},
is_ground_content = false,
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
walkable = false,
climbable = true,
drawtype = "nodebox",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625},
{-0.0625, -0.0625, -0.5, 0.0625, 0.0625, 0.5},
{-0.5, -0.0625, -0.0625, 0.5, 0.0625, 0.0625},
{-0.25, -0.25, -0.25, 0.25, 0.25, 0.25},
}
},
drop = {
max_items = 1,
items = {
{
items = {'dfcaverns:spore_tree_sapling'},
rarity = 10,
},
{
items = {'dfcaverns:spore_tree_frond'},
}
}
},
sounds = default.node_sound_leaves_defaults(),
after_place_node = default.after_place_leaves,
})
minetest.register_node("dfcaverns:spore_tree_sapling", {
description = S("Spore Tree Spawn"),
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"dfcaverns_spore_tree_sapling.png"},
inventory_image = "dfcaverns_spore_tree_sapling.png",
wield_image = "dfcaverns_spore_tree_sapling.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
},
groups = {snappy = 2, dig_immediate = 3, flammable = 2,
attached_node = 1, sapling = 1, light_sensitive_fungus = 11},
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(dfcaverns.config.spore_tree_min_growth_delay, dfcaverns.config.spore_tree_max_growth_delay))
end,
on_timer = function(pos)
minetest.set_node(pos, {name="air"})
dfcaverns.spawn_spore_tree(pos)
end,
})
--fcaverns.spore_tree_def={
-- axiom="TTdddA",
-- rules_a="[&&&Tdd&&FF][&&&++++Tdd&&FF][&&&----Tdd&&FF]",
-- rules_d="T",
-- trunk="dfcaverns:spore_tree",
-- leaves="dfcaverns:spore_tree_frond",
-- leaves2="dfcaverns:spore_tree_pod",
-- leaves2_chance=30,
-- angle=30,
-- iterations=2,
-- random_level=0,
-- trunk_type="single",
-- thin_branches=true,
--}
local c_air = minetest.get_content_id("air")
local c_ignore = minetest.get_content_id("ignore")
local c_spore_pod = minetest.get_content_id("dfcaverns:spore_tree_pod")
local c_tree = minetest.get_content_id("dfcaverns:spore_tree")
local c_spore_frond = minetest.get_content_id("dfcaverns:spore_tree_frond")
dfcaverns.spawn_spore_tree_vm = function(vi, data, area, height, size, iters, has_fruiting_bodies)
if height == nil then height = math.random(3,6) end
if size == nil then size = 2 end
if iters == nil then iters = 10 end
if has_fruiting_bodies == nil then has_fruiting_bodies = math.random() < 0.5 end
local pos = area:position(vi)
local x, y, z = pos.x, pos.y, pos.z
local has_fruiting_bodies = true
-- Trunk
data[area:index(x, y, z)] = c_tree -- Force-place lowest trunk node to replace sapling
for yy = y + 1, y + height - 1 do
local vi = area:index(x, yy, z)
local node_id = data[vi]
if node_id == c_air or node_id == c_ignore or node_id == c_spore_frond then
data[vi] = c_tree
end
end
-- Force leaves near the trunk
for z_dist = -1, 1 do
for y_dist = -size, 1 do
local vi = area:index(x - 1, y + height + y_dist, z + z_dist)
for x_dist = -1, 1 do
if data[vi] == c_air or data[vi] == c_ignore then
if has_fruiting_bodies and math.random() < 0.3 then
data[vi] = c_spore_pod
else
data[vi] = c_spore_frond
end
end
vi = vi + 1
end
end
end
-- Randomly add fronds in 2x2x2 clusters.
for i = 1, iters do
local clust_x = x + math.random(-size, size - 1)
local clust_y = y + height + math.random(-size, 0)
local clust_z = z + math.random(-size, size - 1)
for xi = 0, 1 do
for yi = 0, 1 do
for zi = 0, 1 do
local vi = area:index(clust_x + xi, clust_y + yi, clust_z + zi)
if data[vi] == c_air or data[vi] == c_ignore then
if has_fruiting_bodies and math.random() < 0.3 then
data[vi] = c_spore_pod
else
data[vi] = c_spore_frond
end
end
end
end
end
end
end
dfcaverns.spawn_spore_tree = function(pos)
local x, y, z = pos.x, pos.y, pos.z
local height = math.random(4, 5)
local vm = minetest.get_voxel_manip()
local minp, maxp = vm:read_from_map(
{x = x - 2, y = y, z = z - 2},
{x = x + 2, y = y + height + 1, z = z + 2}
)
local area = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm:get_data()
dfcaverns.spawn_spore_tree_vm(area:indexp(pos), data, area)
vm:set_data(data)
vm:write_to_map()
vm:update_map()
end
minetest.register_abm{
label = "spore tree raining spores",
nodenames = {"dfcaverns:spore_tree_pod"},
interval = 1,
chance = 30,
catch_up = false,
action = function(pos)
minetest.add_particle({
pos = pos,
velocity = {x=math.random() * 0.2 - 0.1, y=-1, z=math.random() * 0.2 - 0.1},
acceleration = {x=0, y=0, z=0},
expirationtime = 3,
size = 10,
collisiondetection = false,
vertical = false,
texture = "farming_wheat_seed.png",
})
end,
}

104
trees/tower_cap.lua Normal file
View File

@ -0,0 +1,104 @@
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
--stem
minetest.register_node("dfcaverns:tower_cap_stem", {
description = S("Tower Cap Stem"),
tiles = {"dfcaverns_tower_cap.png"},
is_ground_content = true,
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
})
--cap
minetest.register_node("dfcaverns:tower_cap", {
description = S("Tower Cap"),
tiles = {"dfcaverns_tower_cap.png"},
is_ground_content = true,
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
})
--gills
minetest.register_node("dfcaverns:tower_cap_gills", {
description = S("Tower Cap Gills"),
tiles = {"dfcaverns_tower_cap_gills.png"},
is_ground_content = true,
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drawtype = "plantlike",
paramtype = "light",
drop = {
max_items = 1,
items = {
{
items = {'dfcaverns:tower_cap_sapling'},
rarity = 20,
},
{
items = {'dfcaverns:tower_cap_gills'},
}
}
},
})
-- sapling
minetest.register_node("dfcaverns:tower_cap_sapling", {
description = S("Tower Cap Spawn"),
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"dfcaverns_tower_cap_sapling.png"},
inventory_image = "dfcaverns_tower_cap_sapling.png",
wield_image = "dfcaverns_tower_cap_sapling.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
},
groups = {snappy = 2, dig_immediate = 3, flammable = 2,
attached_node = 1, sapling = 1, light_sensitive_fungus = 11},
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(dfcaverns.config.tower_cap_min_growth_delay,dfcaverns.config.tower_cap_max_growth_delay))
end,
on_timer = function(pos)
minetest.set_node(pos, {name="air"})
dfcaverns.spawn_tower_cap(pos)
end,
})
local c_stem = minetest.get_content_id("dfcaverns:tower_cap_stem")
local c_cap = minetest.get_content_id("dfcaverns:tower_cap")
local c_gills = minetest.get_content_id("dfcaverns:tower_cap_gills")
dfcaverns.spawn_tower_cap = function(pos)
local x, y, z = pos.x, pos.y, pos.z
local stem_height = math.random(4,10)
local cap_radius = math.random(4,6)
local maxy = y + stem_height + 3
local vm = minetest.get_voxel_manip()
local minp, maxp = vm:read_from_map(
{x = x - cap_radius, y = y, z = z - cap_radius},
{x = x + cap_radius, y = maxy + 3, z = z + cap_radius}
)
local area = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm:get_data()
subterrane:giant_shroom(area:indexp(pos), area, data, c_stem, c_cap, c_gills, stem_height, cap_radius)
vm:set_data(data)
vm:write_to_map()
vm:update_map()
end
dfcaverns.spawn_tower_cap_vm = function(vi, area, data)
local stem_height = math.random(4,10)
local cap_radius = math.random(4,6)
subterrane:giant_shroom(vi, area, data, c_stem, c_cap, c_gills, stem_height, cap_radius)
end

152
trees/tunnel_tube.lua Normal file
View File

@ -0,0 +1,152 @@
--------------------------------------------------
-- Tunnel tube
-- Magenta
-- curving trunk
-- Max trunk height 8
-- depth 2-3
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
minetest.register_node("dfcaverns:tunnel_tube", {
description = S("Tunnel Tube"),
tiles = {"dfcaverns_tunnel_tube.png"},
paramtype2 = "facedir",
drawtype = "nodebox",
paramtype = "light",
groups = {choppy = 3, oddly_breakable_by_hand=1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
on_place = minetest.rotate_node,
node_box = {
type = "fixed",
fixed = {
{-8/16,-8/16,-8/16,-4/16,8/16,8/16},
{4/16,-8/16,-8/16,8/16,8/16,8/16},
{-4/16,-8/16,-8/16,4/16,8/16,-4/16},
{-4/16,-8/16,8/16,4/16,8/16,4/16},
},
},
})
minetest.register_node("dfcaverns:tunnel_tube_fruiting_body", {
description = S("Tunnel Tube Fruiting Body"),
tiles = {"dfcaverns_tunnel_tube.png^[multiply:#b09090"},
paramtype2 = "facedir",
groups = {choppy = 3, oddly_breakable_by_hand=1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
on_place = minetest.rotate_node,
drop = {
max_items = 3,
items = {
{
items = {'dfcaverns:tunnel_tube_sapling'},
rarity = 2,
},
{
items = {'dfcaverns:tunnel_tube_sapling'},
rarity = 2,
},
{
items = {'dfcaverns:tunnel_tube_sapling'},
rarity = 2,
},
}
},
})
minetest.register_node("dfcaverns:tunnel_tube_sapling", {
description = S("Tunnel Tube Spawn"),
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"dfcaverns_tunnel_tube_sapling.png"},
inventory_image = "dfcaverns_tunnel_tube_sapling.png",
wield_image = "dfcaverns_tunnel_tube_sapling.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
},
groups = {snappy = 2, dig_immediate = 3, flammable = 2,
attached_node = 1, sapling = 1, light_sensitive_fungus = 11},
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(dfcaverns.config.tunnel_tube_min_growth_delay,dfcaverns.config.tunnel_tube_max_growth_delay))
end,
on_timer = function(pos)
minetest.set_node(pos, {name="air"})
dfcaverns.spawn_tunnel_tube(pos)
end,
})
local tunnel_tube_directions = {
{x=1,y=0,z=0},
{x=-1,y=0,z=0},
{x=0,y=0,z=1},
{x=0,y=0,z=-1},
-- {x=1,y=0,z=1}, -- diagonals work, but they don't look as nice as orthogonals
-- {x=-1,y=0,z=1},
-- {x=1,y=0,z=-1},
-- {x=-1,y=0,z=-1},
}
local tunnel_tube_curvature = {0,0,0,0,1,1,1,2,2,3,4}
dfcaverns.spawn_tunnel_tube = function(pos)
local direction = tunnel_tube_directions[math.random(1,4)]
local height = math.random(6,10)
local x, y, z = pos.x, pos.y, pos.z
local top_pos = vector.add(pos, vector.multiply(direction, tunnel_tube_curvature[height]))
top_pos.y = y + height - 1
local vm = minetest.get_voxel_manip()
local minp, maxp = vm:read_from_map(pos, top_pos)
local area = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm:get_data()
local param2_data = vm:get_param2_data()
dfcaverns.spawn_tunnel_tube_vm(area:indexp(pos), area, data, param2_data, height, direction)
vm:set_data(data)
vm:set_param2_data(param2_data)
vm:write_to_map()
vm:update_map()
end
local c_air = minetest.get_content_id("air")
local c_ignore = minetest.get_content_id("ignore")
local c_tunnel_tube = minetest.get_content_id("dfcaverns:tunnel_tube")
local c_tunnel_tube_fruiting_body = minetest.get_content_id("dfcaverns:tunnel_tube_fruiting_body")
dfcaverns.spawn_tunnel_tube_vm = function(vi, area, data, param2_data, height, direction)
if not height then height = math.random(6, 10) end
if not direction then direction = tunnel_tube_directions[math.random(1,4)] end
local pos = area:position(vi)
local y = pos.y
local previous_vi = vi
for i = 1, height do
pos.y = y + i - 1
vi = area:indexp(vector.add(pos, vector.multiply(direction, tunnel_tube_curvature[i])))
if data[vi] == c_air or data[vi] == c_ignore then
previous_vi = vi
if i ~= height then
data[vi] = c_tunnel_tube
param2_data[vi] = 0
else
data[vi] = c_tunnel_tube_fruiting_body
end
else
data[previous_vi] = c_tunnel_tube_fruiting_body
break
end
end
end