fixing up fungus light sensitivity, tree growth code

This commit is contained in:
FaceDeer 2020-01-30 00:57:29 -07:00
parent 27afe3e383
commit ff1d5d0af2
20 changed files with 255 additions and 116 deletions

View File

@ -183,6 +183,9 @@ df_farming.register_seed = function(name, description, image, stage_one, grow_ti
end
df_farming.grow_underground_plant = function(pos, plant_name, elapsed)
if df_farming.kill_if_sunlit(pos) then
return
end
local node_def = minetest.registered_nodes[plant_name]
local next_stage = node_def._dfcaverns_next_stage
if next_stage then
@ -198,7 +201,33 @@ df_farming.grow_underground_plant = function(pos, plant_name, elapsed)
end
end
df_farming.kill_if_sunlit = function(pos, node)
return false
end
if df_farming.config.light_kills_fungus then
local kill_if_sunlit = function(pos, node)
if not node then
node = minetest.get_node(pos)
end
local node_def = minetest.registered_nodes[node.name]
local light_sensitive_fungus_level = node_def.groups.light_sensitive_fungus
-- This should never be the case, but I've received a report of it happening anyway in the ABM so guarding against it.
if not light_sensitive_fungus_level then return false end
local dead_node = node_def._dfcaverns_dead_node or "df_farming:dead_fungus"
-- 11 is the value adjacent to a torch
local light_level = minetest.get_node_light(pos, 0.5) -- check at 0.5 to get how bright it would be here at noon,
-- prevents fungus from growing on the surface world by happenstance
if light_level and light_level > light_sensitive_fungus_level then
minetest.set_node(pos, {name=dead_node, param2 = node.param2})
return true
end
return false
end
df_farming.kill_if_sunlit = kill_if_sunlit
minetest.register_abm({
label = "df_farming:kill_light_sensitive_fungus",
nodenames = {"group:light_sensitive_fungus"},
@ -206,15 +235,7 @@ if df_farming.config.light_kills_fungus then
interval = 30,
chance = 5,
action = function(pos, node)
local node_def = minetest.registered_nodes[node.name]
local light_sensitive_fungus_level = node_def.groups.light_sensitive_fungus
if not light_sensitive_fungus_level then return end -- This should never be the case, but I've received a report of it happening anyway so guarding against it.
local dead_node = node_def._dfcaverns_dead_node or "df_farming:dead_fungus"
-- 11 is the value adjacent to a torch
local light_level = minetest.get_node_light(pos)
if light_level and light_level > light_sensitive_fungus_level then
minetest.set_node(pos, {name=dead_node, param2 = node.param2})
end
kill_if_sunlit(pos, node)
end
})
end

View File

@ -14,7 +14,7 @@ minetest.register_node("df_primordial_items:fungal_grass_1", {
tiles = {"dfcaverns_mush_grass_01.png"},
inventory_image = "dfcaverns_mush_grass_01.png",
wield_image = "dfcaverns_mush_grass_01.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_fungal_plant = 1},
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_fungal_plant = 1, light_sensitive_fungus = 11},
paramtype = "light",
drawtype = "plantlike",
buildable_to = true,
@ -32,7 +32,7 @@ minetest.register_node("df_primordial_items:fungal_grass_2", {
tiles = {"dfcaverns_mush_grass_02.png"},
inventory_image = "dfcaverns_mush_grass_02.png",
wield_image = "dfcaverns_mush_grass_02.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_fungal_plant = 1},
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_fungal_plant = 1, light_sensitive_fungus = 11},
paramtype = "light",
drawtype = "plantlike",
buildable_to = true,
@ -53,7 +53,7 @@ minetest.register_node("df_primordial_items:glow_orb", {
tiles = {"dfcaverns_mush_orb.png"},
inventory_image = "dfcaverns_mush_orb.png",
wield_image = "dfcaverns_mush_orb.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_fungal_plant = 1},
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_fungal_plant = 1, light_sensitive_fungus = 13},
paramtype = "light",
drawtype = "plantlike",
buildable_to = true,
@ -72,7 +72,7 @@ minetest.register_node("df_primordial_items:glow_orb_stalks", {
tiles = {"dfcaverns_mush_stalks.png"},
inventory_image = "dfcaverns_mush_stalks.png",
wield_image = "dfcaverns_mush_stalks.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_fungal_plant = 1},
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_fungal_plant = 1, light_sensitive_fungus = 13},
paramtype = "light",
drawtype = "plantlike",
buildable_to = true,
@ -91,7 +91,7 @@ minetest.register_node("df_primordial_items:glow_pods", {
tiles = {"dfcaverns_mush_pods.png"},
inventory_image = "dfcaverns_mush_pods.png",
wield_image = "dfcaverns_mush_pods.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_fungal_plant = 1},
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_fungal_plant = 1, light_sensitive_fungus = 13},
paramtype = "light",
drawtype = "plantlike",
buildable_to = true,
@ -113,6 +113,7 @@ minetest.register_node("df_primordial_items:dirt_with_mycelium", {
tiles = {"dfcaverns_mush_soil.png"},
groups = {crumbly = 3, soil = 1},
is_ground_content = false,
paramtype = "light",
drops = "default:dirt",
sounds = default.node_sound_dirt_defaults(),
light_source = 3,
@ -126,10 +127,7 @@ minetest.register_abm{
chance = 50,
catch_up = true,
action = function(pos)
local above_def = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name]
if above_def and (above_def.buildable_to == true or above_def.walkable == false) then
minetest.swap_node(pos, {name="df_mapitems:dirt_with_mycelium"})
end
end,
}

View File

@ -270,7 +270,8 @@ minetest.register_node("df_primordial_items:fern_sapling", {
tiles = {"dfcaverns_jungle_fern_03.png"},
inventory_image = "dfcaverns_jungle_fern_03.png",
wield_image = "dfcaverns_jungle_fern_03.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1},
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, sapling = 1, light_sensitive_fungus = 13},
_dfcaverns_dead_node = "default:dry_shrub",
paramtype = "light",
drawtype = "plantlike",
buildable_to = true,
@ -280,10 +281,28 @@ minetest.register_node("df_primordial_items:fern_sapling", {
use_texture_alpha = true,
sunlight_propagates = true,
on_construct = function(pos)
--TODO timer
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
return
end
minetest.get_node_timer(pos):start(math.random(
df_trees.config.tree_min_growth_delay,
df_trees.config.tree_max_growth_delay))
end,
on_destruct = function(pos)
minetest.get_node_timer(pos):stop()
end,
on_timer = function(pos, elapsed)
if df_farming and df_farming.kill_if_sunlit(pos) then
return
end
if minetest.get_node_light(pos) > 6 then
local fern = df_primordial_items.get_fern_schematic()
local rotation = rotations[math.random(1,#rotations)]
minetest.set_node(pos, {name="air"}) -- clear sapling so fern can replace it
mapgen_helper.place_schematic(pos, fern, rotation)
else
minetest.get_node_timer(pos):start(df_trees.config.tree_min_growth_delay)
end
end,
})

View File

@ -320,6 +320,10 @@ minetest.register_node("df_primordial_items:giant_hypha_apical_meristem", {
minetest.get_node_timer(pos):stop()
end,
on_timer = function(pos, elapsed)
if df_farming and df_farming.kill_if_sunlit(pos) then
return
end
if elapsed > max_growth_delay then
-- We've been unloaded for a while, need to do multiple growth iterations.
local iterations = math.floor(elapsed / avg_growth_delay) -- the number of iterations we've missed
@ -370,12 +374,13 @@ minetest.register_node("df_primordial_items:giant_hypha_apical_mapgen", {
connects_to = {"group:hypha"},
connect_sides = { "top", "bottom", "front", "left", "back", "right" },
drawtype = "nodebox",
_dfcaverns_dead_node = "df_primordial_items:giant_hypha_root",
light_source = 6,
node_box = get_node_box(0.25, 0.375),
paramtype = "light",
is_ground_content = false,
groups = {oddly_breakable_by_hand = 1, choppy = 2, hypha = 1, not_in_creative_inventory = 1},
groups = {oddly_breakable_by_hand = 1, choppy = 2, hypha = 1, not_in_creative_inventory = 1, light_sensitive_fungus = 13},
sounds = df_trees.node_sound_tree_soft_fungus_defaults(),
})
@ -383,6 +388,7 @@ local grow_mycelium_immediately = function(pos)
local stack = {pos}
while #stack > 0 do
local pos = table.remove(stack)
if not (df_farming and df_farming.kill_if_sunlit(pos)) then
local new_poses = grow_mycelium(pos, "df_primordial_items:giant_hypha_apical_mapgen")
if new_poses then -- if we hit the end of the world, just stop. There'll be a mapgen meristem left here, the abm will re-trigger it when the player gets close.
for _, new_pos in ipairs(new_poses) do
@ -391,6 +397,7 @@ local grow_mycelium_immediately = function(pos)
end
end
end
end
minetest.register_abm({
label = "Mycelium mapgen growth",

View File

@ -105,14 +105,21 @@ minetest.register_node("df_primordial_items:jungle_mushroom_sapling", {
sunlight_propagates = true,
on_construct = function(pos)
minetest.get_node_timer(pos):start(
math.random(
df_trees.config.nether_cap_delay_multiplier*df_trees.config.tree_min_growth_delay,
df_trees.config.nether_cap_delay_multiplier*df_trees.config.tree_max_growth_delay)
)
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
return
end
minetest.get_node_timer(pos):start(math.random(
df_trees.config.tree_min_growth_delay,
df_trees.config.tree_max_growth_delay))
end,
on_destruct = function(pos)
minetest.get_node_timer(pos):stop()
end,
on_timer = function(pos)
if df_farming and df_farming.kill_if_sunlit(pos) then
return
end
minetest.set_node(pos, {name="air"})
df_primordial_items.spawn_jungle_mushroom(pos)
end,

View File

@ -17,7 +17,8 @@ minetest.register_node("df_primordial_items:fern_1", {
tiles = {"dfcaverns_jungle_fern_01.png"},
inventory_image = "dfcaverns_jungle_fern_01.png",
wield_image = "dfcaverns_jungle_fern_01.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1},
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1, light_sensitive_fungus = 13},
_dfcaverns_dead_node = "default:dry_shrub",
visual_scale = 1.69,
paramtype = "light",
drawtype = "plantlike",
@ -37,7 +38,8 @@ minetest.register_node("df_primordial_items:fern_2", {
visual_scale = 1.69,
inventory_image = "dfcaverns_jungle_fern_02.png",
wield_image = "dfcaverns_jungle_fern_02.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1},
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1, light_sensitive_fungus = 13},
_dfcaverns_dead_node = "default:dry_shrub",
paramtype = "light",
drawtype = "plantlike",
buildable_to = true,
@ -58,7 +60,8 @@ minetest.register_node("df_primordial_items:glow_plant_1", {
tiles = {"dfcaverns_jungle_flower_01.png"},
inventory_image = "dfcaverns_jungle_flower_01.png",
wield_image = "dfcaverns_jungle_flower_01.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1},
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1, light_sensitive_fungus = 13},
_dfcaverns_dead_node = "default:dry_shrub",
paramtype = "light",
drawtype = "plantlike",
buildable_to = true,
@ -77,7 +80,8 @@ minetest.register_node("df_primordial_items:glow_plant_2", {
tiles = {"dfcaverns_jungle_glow_plant_01.png"},
inventory_image = "dfcaverns_jungle_glow_plant_01.png",
wield_image = "dfcaverns_jungle_glow_plant_01.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1},
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1, light_sensitive_fungus = 13},
_dfcaverns_dead_node = "default:dry_shrub",
paramtype = "light",
drawtype = "plantlike",
buildable_to = true,
@ -96,7 +100,8 @@ minetest.register_node("df_primordial_items:glow_plant_3", {
tiles = {"dfcaverns_jungle_glow_plant_02.png"},
inventory_image = "dfcaverns_jungle_glow_plant_02.png",
wield_image = "dfcaverns_jungle_glow_plant_02.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1},
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1, light_sensitive_fungus = 13},
_dfcaverns_dead_node = "default:dry_shrub",
paramtype = "light",
drawtype = "plantlike",
buildable_to = true,
@ -119,7 +124,8 @@ minetest.register_node("df_primordial_items:jungle_grass_1", {
tiles = {"dfcaverns_jungle_grass_01.png"},
inventory_image = "dfcaverns_jungle_grass_01.png",
wield_image = "dfcaverns_jungle_grass_01.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1},
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1, light_sensitive_fungus = 13},
_dfcaverns_dead_node ="default:dry_grass_3",
paramtype = "light",
drawtype = "plantlike",
buildable_to = true,
@ -137,7 +143,8 @@ minetest.register_node("df_primordial_items:jungle_grass_2", {
tiles = {"dfcaverns_jungle_grass_02.png"},
inventory_image = "dfcaverns_jungle_grass_02.png",
wield_image = "dfcaverns_jungle_grass_02.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1},
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1, light_sensitive_fungus = 13},
_dfcaverns_dead_node ="default:dry_grass_4",
paramtype = "light",
drawtype = "plantlike",
buildable_to = true,
@ -156,7 +163,8 @@ minetest.register_node("df_primordial_items:jungle_grass_3", {
tiles = {"dfcaverns_jungle_grass_03.png"},
inventory_image = "dfcaverns_jungle_grass_03.png",
wield_image = "dfcaverns_jungle_grass_03.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1},
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1, light_sensitive_fungus = 13},
_dfcaverns_dead_node ="default:dry_grass_4",
paramtype = "light",
drawtype = "plantlike",
buildable_to = true,
@ -203,10 +211,10 @@ minetest.register_node("df_primordial_items:jungle_mushroom_1", {
description = S("Primordial Jungle Mushroom"),
_doc_items_longdesc = df_primordial_items.doc.small_mushroom_desc,
_doc_items_usagehelp = df_primordial_items.doc.small_mushroom_usage,
tiles = {"dfcaverns_jungle_mushroom_01.png"},
inventory_image = "dfcaverns_jungle_mushroom_01.png",
wield_image = "dfcaverns_jungle_mushroom_01.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1},
tiles = {"dfcaverns_jungle_mushroom_01.png^[multiply:#f3df2a"},
inventory_image = "dfcaverns_jungle_mushroom_01.png^[multiply:#f3df2a",
wield_image = "dfcaverns_jungle_mushroom_01.png^[multiply:#f3df2a",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1, light_sensitive_fungus = 11},
paramtype = "light",
drawtype = "plantlike",
buildable_to = true,
@ -218,13 +226,13 @@ minetest.register_node("df_primordial_items:jungle_mushroom_1", {
})
minetest.register_node("df_primordial_items:jungle_mushroom_2", {
description = S("Primordial Jungle Mushroom"),
description = S("Large Primordial Jungle Mushroom"),
_doc_items_longdesc = df_primordial_items.doc.small_mushroom_desc,
_doc_items_usagehelp = df_primordial_items.doc.small_mushroom_usage,
tiles = {"dfcaverns_jungle_mushroom_02.png"},
inventory_image = "dfcaverns_jungle_mushroom_02.png",
wield_image = "dfcaverns_jungle_mushroom_02.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1},
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, primordial_jungle_plant = 1, light_sensitive_fungus = 11},
paramtype = "light",
drawtype = "plantlike",
buildable_to = true,
@ -243,7 +251,9 @@ minetest.register_node("df_primordial_items:dirt_with_jungle_grass", {
_doc_items_longdesc = df_primordial_items.doc.dirt_with_jungle_grass_desc,
_doc_items_usagehelp = df_primordial_items.doc.dirt_with_jungle_grass_usage,
tiles = {"dfcaverns_jungle_plant_grass_node_01.png"},
groups = {crumbly = 3, soil = 1},
paramtype = "light",
groups = {crumbly = 3, soil = 1, light_sensitive_fungus = 13},
_dfcaverns_dead_node = "default:dirt",
is_ground_content = false,
drops = "default:dirt",
sounds = default.node_sound_dirt_defaults(),
@ -270,6 +280,7 @@ minetest.register_node("df_primordial_items:plant_matter", {
_doc_items_usagehelp = df_primordial_items.doc.plant_matter_usage,
tiles = {"dfcaverns_jungle_plant_matter_01.png"},
is_ground_content = false,
paramtype = "light",
groups = {crumbly = 3, soil = 1},
sounds = default.node_sound_dirt_defaults(),
on_timer = function(pos)
@ -279,6 +290,18 @@ minetest.register_node("df_primordial_items:plant_matter", {
end,
})
minetest.register_node("df_primordial_items:packed_roots", {
description = S("Packed Primordial Jungle Roots"),
_doc_items_longdesc = df_primordial_items.doc.packed_roots_desc,
_doc_items_usagehelp = df_primordial_items.doc.packed_roots_usage,
tiles = {"dfcaverns_jungle_plant_packed_roots_01.png"},
paramtype2 = "facedir",
is_ground_content = false,
groups = {choppy = 2, oddly_breakable_by_hand = 2},
sounds = default.node_sound_wood_defaults(),
})
if minetest.get_modpath("trail") and trail and trail.register_trample_node then
local HARDPACK_PROBABILITY = minetest.settings:get("trail_hardpack_probability") or 0.5 -- Chance walked dirt/grass is worn and compacted to trail:trail.
local HARDPACK_COUNT = minetest.settings:get("trail_hardpack_count") or 5 -- Number of times the above chance needs to be passed for soil to compact.
@ -293,23 +316,12 @@ if minetest.get_modpath("trail") and trail and trail.register_trample_node then
trail.register_trample_node("df_primordial_items:plant_matter", {
trampled_node_def_override = {description = S("Primordial Plant Matter with Footprint"),},
footprint_opacity = 128,
hard_pack_node_name = "trail:trail",
hard_pack_node_name = "df_primordial_items:packed_roots",
hard_pack_probability = HARDPACK_PROBABILITY,
hard_pack_count = HARDPACK_COUNT,
})
end
minetest.register_node("df_primordial_items:packed_roots", {
description = S("Packed Primordial Jungle Roots"),
_doc_items_longdesc = df_primordial_items.doc.packed_roots_desc,
_doc_items_usagehelp = df_primordial_items.doc.packed_roots_usage,
tiles = {"dfcaverns_jungle_plant_packed_roots_01.png"},
paramtype2 = "facedir",
is_ground_content = false,
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_craft({
type = "fuel",
recipe = "df_primordial_items:packed_roots",

View File

@ -217,10 +217,6 @@ df_primordial_items.spawn_jungle_tree_vm = function(height, vi, area, data)
branch(vi + (height-1)*ystride) -- topper
end
--TODO: separate setting
local min_growth_delay = tonumber(minetest.settings:get("dfcaverns_mycelium_min_growth_delay")) or 240
local max_growth_delay = tonumber(minetest.settings:get("dfcaverns_mycelium_max_growth_delay")) or 400
minetest.register_node("df_primordial_items:jungletree_sapling", {
description = S("Primordial Jungle Tree Sapling"),
_doc_items_longdesc = df_primordial_items.doc.tree_desc,
@ -228,7 +224,8 @@ minetest.register_node("df_primordial_items:jungletree_sapling", {
tiles = {"dfcaverns_jungle_sapling.png"},
inventory_image = "dfcaverns_jungle_sapling.png",
wield_image = "dfcaverns_jungle_sapling.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, sapling = 1},
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1, sapling = 1, light_sensitive_fungus = 13},
_dfcaverns_dead_node = "default:dry_shrub",
paramtype = "light",
drawtype = "plantlike",
buildable_to = true,
@ -238,12 +235,24 @@ minetest.register_node("df_primordial_items:jungletree_sapling", {
use_texture_alpha = true,
sunlight_propagates = true,
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(min_growth_delay, max_growth_delay))
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
return
end
minetest.get_node_timer(pos):start(math.random(
df_trees.config.tree_min_growth_delay,
df_trees.config.tree_max_growth_delay))
end,
on_destruct = function(pos)
minetest.get_node_timer(pos):stop()
end,
on_timer = function(pos, elapsed)
if df_farming and df_farming.kill_if_sunlit(pos) then
return
end
if minetest.get_node_light(pos) > 6 then
df_primordial_items.spawn_jungle_tree(pos)
else
minetest.get_node_timer(pos):start(df_trees.config.tree_min_growth_delay)
end
end,
})

View File

@ -1,4 +1,4 @@
name = df_primordial_items
description = A collection of flora found in the "primordial" cavern layer of DF Caverns
depends = default, mapgen_helper, subterrane, df_underworld_items, df_trees
optional_depends = trail
optional_depends = trail, df_farming

View File

@ -684,10 +684,6 @@ df_primordial_items.get_primordial_mushroom = function()
return bc_mushroom_21
end
--TODO: separate setting
local min_growth_delay = tonumber(minetest.settings:get("dfcaverns_mycelium_min_growth_delay")) or 240
local max_growth_delay = tonumber(minetest.settings:get("dfcaverns_mycelium_max_growth_delay")) or 400
minetest.register_node("df_primordial_items:mush_sapling", {
description = S("Primordial Mushroom Spawn"),
_doc_items_longdesc = df_primordial_items.doc.giant_mushroom_desc,
@ -705,12 +701,20 @@ minetest.register_node("df_primordial_items:mush_sapling", {
use_texture_alpha = true,
sunlight_propagates = true,
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(min_growth_delay, max_growth_delay))
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
return
end
minetest.get_node_timer(pos):start(math.random(
df_trees.config.tree_min_growth_delay,
df_trees.config.tree_max_growth_delay))
end,
on_destruct = function(pos)
minetest.get_node_timer(pos):stop()
end,
on_timer = function(pos, elapsed)
if df_farming and df_farming.kill_if_sunlit(pos) then
return
end
local mushroom = df_primordial.get_primordial_mushroom()
local rotation = (math.random(1,4)-1)*90
minetest.set_node(pos, {name="air"}) -- clear sapling so mushroom can replace it

View File

@ -1,2 +1,5 @@
dfcaverns_mycelium_min_growth_delay (Minimum mycelium growth delay) int 240
dfcaverns_mycelium_max_growth_delay (Maximum mycelium growth delay) int 400
dfcaverns_jungle_min_growth_delay (Minimum growth delay for large jungle plants) int 300
dfcaverns_jungle_max_growth_delay (Maximum growth delay for large jungle plants) int 1500

View File

@ -154,9 +154,15 @@ minetest.register_node("df_trees:black_cap_sapling", {
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
local below_node_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
if minetest.get_item_group(below_node_name, "soil") > 0 or minetest.get_item_group(below_node_name, "coal") > 0 then
minetest.get_node_timer(pos):start(math.random(
df_trees.config.black_cap_delay_multiplier*df_trees.config.tree_min_growth_delay,
df_trees.config.black_cap_delay_multiplier*df_trees.config.tree_max_growth_delay))
end
end,
on_destruct = function(pos)
minetest.get_node_timer(pos):stop()
end,
on_timer = function(pos)

View File

@ -185,6 +185,11 @@ local max_bloodthorn_height = function(pos)
end
function df_trees.grow_blood_thorn(pos, node)
if df_farming and df_farming.kill_if_sunlit(pos) then
return
end
-- node is tipped over
if node.param2 >= 4 then
return
end

View File

@ -126,15 +126,21 @@ minetest.register_node("df_trees:fungiwood_sapling", {
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
local below_node = minetest.get_node(vector.add(pos, {x=0,y=-1,z=0}))
if minetest.get_item_group(below_node.name, "soil") > 0 then
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
return
end
minetest.get_node_timer(pos):start(math.random(
df_trees.config.fungiwood_delay_multiplier*df_trees.config.tree_min_growth_delay,
df_trees.config.fungiwood_delay_multiplier*df_trees.config.tree_max_growth_delay))
end
end,
on_destruct = function(pos)
minetest.get_node_timer(pos):stop()
end,
on_timer = function(pos)
if df_farming and df_farming.kill_if_sunlit(pos) then
return
end
minetest.set_node(pos, {name="air"})
df_trees.spawn_fungiwood(pos)
end,

View File

@ -206,15 +206,22 @@ minetest.register_node("df_trees:goblin_cap_sapling", {
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
local below_node = minetest.get_node(vector.add(pos, {x=0,y=-1,z=0}))
if minetest.get_item_group(below_node.name, "soil") > 0 then
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
return
end
minetest.get_node_timer(pos):start(math.random(
df_trees.config.goblin_cap_delay_multiplier*df_trees.config.tree_min_growth_delay,
df_trees.config.goblin_cap_delay_multiplier*df_trees.config.tree_max_growth_delay))
end
end,
on_destruct = function(pos)
minetest.get_node_timer(pos):stop()
end,
on_timer = function(pos)
if df_farming and df_farming.kill_if_sunlit(pos) then
return
end
minetest.set_node(pos, {name="air"})
if minetest.find_node_near({x=pos.x, y=pos.y-1, z=pos.z}, 1, {"group:straw"}) then
if math.random() < 0.5 then

View File

@ -1,4 +1,4 @@
name = df_trees
description = Adds various types of underground fungal "trees". Light kills their saplings, they only grow in the dark.
depends = default
optional_depends = intllib, doc, moreblocks, stairs, vessels, basic_materials, farming, doors, beds
optional_depends = intllib, doc, moreblocks, stairs, vessels, basic_materials, farming, doors, beds, df_farming

View File

@ -9,7 +9,7 @@ minetest.register_node("df_trees:nether_cap_stem", {
_doc_items_usagehelp = df_trees.doc.nether_cap_usage,
tiles = {"dfcaverns_nether_cap_stem.png"},
is_ground_content = false,
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, puts_out_fire = 1, cools_lava = 1, freezes_water = 1},
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, puts_out_fire = 1, cools_lava = 1, freezes_water = 1, nether_cap = 1},
sounds = default.node_sound_wood_defaults(),
})
@ -20,7 +20,7 @@ minetest.register_node("df_trees:nether_cap", {
_doc_items_usagehelp = df_trees.doc.nether_cap_usage,
tiles = {"dfcaverns_nether_cap.png"},
is_ground_content = false,
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, puts_out_fire = 1, cools_lava = 1, freezes_water = 1 },
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, puts_out_fire = 1, cools_lava = 1, freezes_water = 1, nether_cap = 1},
sounds = default.node_sound_wood_defaults({
footstep = {name = "default_snow_footstep", gain = 0.2},
}),
@ -34,7 +34,7 @@ minetest.register_node("df_trees:nether_cap_gills", {
tiles = {"dfcaverns_nether_cap_gills.png"},
is_ground_content = false,
light_source = 6,
groups = {snappy = 3, leafdecay = 3, leaves = 1, puts_out_fire = 1, cools_lava = 1, freezes_water = 1},
groups = {snappy = 3, leafdecay = 3, leaves = 1, puts_out_fire = 1, cools_lava = 1, freezes_water = 1, nether_cap = 1},
sounds = default.node_sound_leaves_defaults(),
drawtype = "plantlike",
paramtype = "light",
@ -114,12 +114,24 @@ minetest.register_node("df_trees:nether_cap_sapling", {
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
local node_below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
if minetest.get_item_group(node_below_name, "cools_lava") == 0 or minetest.get_item_group(node_below_name, "nether_cap") > 0 then
return
end
minetest.get_node_timer(pos):start(math.random(
df_trees.config.nether_cap_delay_multiplier*df_trees.config.tree_min_growth_delay,
df_trees.config.nether_cap_delay_multiplier*df_trees.config.tree_max_growth_delay))
end,
on_destruct = function(pos)
minetest.get_node_timer(pos):stop()
end,
on_timer = function(pos)
if df_farming and df_farming.kill_if_sunlit(pos) then
return
end
minetest.set_node(pos, {name="air"})
df_trees.spawn_nether_cap(pos)
end,

View File

@ -223,13 +223,6 @@ local register_spindlestem_type = function(item_suffix, colour_name, colour_code
end
end
local seedling_construct = function(pos)
local below_node = minetest.get_node(vector.add(pos, {x=0,y=-1,z=0}))
if minetest.get_item_group(below_node.name, "soil") > 0 then
minetest.get_node_timer(pos):start(growth_delay())
end
end
minetest.register_node("df_trees:spindlestem_seedling", {
description = S("Spindlestem Spawn"),
_doc_items_longdesc = df_trees.doc.spindlestem_desc,
@ -252,9 +245,21 @@ minetest.register_node("df_trees:spindlestem_seedling", {
},
on_place = stem_on_place,
on_construct = seedling_construct,
on_construct = function(pos)
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
return
end
minetest.get_node_timer(pos):start(growth_delay())
end,
on_destruct = function(pos)
minetest.get_node_timer(pos):stop()
end,
on_timer = function(pos)
if df_farming and df_farming.kill_if_sunlit(pos) then
return
end
on_timer = function(pos, elapsed)
local cap_item = minetest.get_name_from_content_id(get_spindlestem_cap_type(pos))
local node = minetest.get_node(pos)
minetest.set_node(pos, {name=cap_item, param2 = node.param2})

View File

@ -168,15 +168,21 @@ minetest.register_node("df_trees:spore_tree_sapling", {
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
local below_node = minetest.get_node(vector.add(pos, {x=0,y=-1,z=0}))
if minetest.get_item_group(below_node.name, "soil") > 0 then
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
return
end
minetest.get_node_timer(pos):start(math.random(
df_trees.config.spore_tree_delay_multiplier*df_trees.config.tree_min_growth_delay,
df_trees.config.spore_tree_delay_multiplier*df_trees.config.tree_max_growth_delay))
end
end,
on_destruct = function(pos)
minetest.get_node_timer(pos):stop()
end,
on_timer = function(pos)
if df_farming and df_farming.kill_if_sunlit(pos) then
return
end
minetest.set_node(pos, {name="air"})
df_trees.spawn_spore_tree(pos)
end,

View File

@ -137,15 +137,21 @@ minetest.register_node("df_trees:tower_cap_sapling", {
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
local below_node = minetest.get_node(vector.add(pos, {x=0,y=-1,z=0}))
if minetest.get_item_group(below_node.name, "soil") > 0 then
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
return
end
minetest.get_node_timer(pos):start(math.random(
df_trees.config.tower_cap_delay_multiplier*df_trees.config.tree_min_growth_delay,
df_trees.config.tower_cap_delay_multiplier*df_trees.config.tree_max_growth_delay))
end
end,
on_destruct = function(pos)
minetest.get_node_timer(pos):stop()
end,
on_timer = function(pos)
if df_farming and df_farming.kill_if_sunlit(pos) then
return
end
minetest.set_node(pos, {name="air"})
df_trees.spawn_tower_cap(pos)
end,

View File

@ -303,15 +303,21 @@ minetest.register_node("df_trees:tunnel_tube_sapling", {
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
local below_node = minetest.get_node(vector.add(pos, {x=0,y=-1,z=0}))
if minetest.get_item_group(below_node.name, "soil") > 0 then
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") == 0 then
return
end
minetest.get_node_timer(pos):start(math.random(
df_trees.config.tunnel_tube_delay_multiplier*df_trees.config.tree_min_growth_delay,
df_trees.config.tunnel_tube_delay_multiplier*df_trees.config.tree_max_growth_delay))
end
end,
on_destruct = function(pos)
minetest.get_node_timer(pos):stop()
end,
on_timer = function(pos)
if df_farming and df_farming.kill_if_sunlit(pos) then
return
end
minetest.set_node(pos, {name="air"})
df_trees.spawn_tunnel_tube(pos)
end,