add giant mycelium fungoidal structure

This commit is contained in:
FaceDeer 2019-08-11 19:33:50 -06:00
parent 62b33c126f
commit f2c1f54215
4 changed files with 255 additions and 0 deletions

View File

@ -69,6 +69,7 @@ local mushroom_cavern_ceiling = function(abs_cracks, humidity, vi, area, data, d
df_primordial_items.spawn_ceiling_spire_vm(vi, area, data)
elseif rand < 0.2 then
data[vi-ystride] = c_orb
data_param2[vi-ystride] = math.random(0,179)
end
end
end
@ -82,6 +83,7 @@ local mushroom_warren_ceiling = function(abs_cracks, vi, area, data, data_param2
if abs_cracks < 0.2 then
if math.random() < 0.2 then
data[vi-ystride] = c_orb
data_param2[vi-ystride] = math.random(0,179)
end
end
end

View File

@ -40,6 +40,7 @@ minetest.register_node("df_primordial_items:glow_orb_hanging", {
wield_image = "dfcaverns_mush_orb_vert.png",
groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1},
paramtype = "light",
paramtype2 = "degrotate",
drawtype = "plantlike",
buildable_to = true,
walkable = false,

View File

@ -0,0 +1,251 @@
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
local hub_thickness = 0.1875--0.25
local connector_thickness = 0.25--0.375
local node_box = {
type = "connected",
fixed = {-hub_thickness,-hub_thickness,-hub_thickness,hub_thickness,hub_thickness,hub_thickness},
connect_top = {-connector_thickness, 0, -connector_thickness, connector_thickness, 0.5, connector_thickness},
connect_bottom = {-connector_thickness, -0.5, -connector_thickness, connector_thickness, 0, connector_thickness},
connect_back = {-connector_thickness, -connector_thickness, 0, connector_thickness, connector_thickness, 0.5},
connect_right = {0, -connector_thickness, -connector_thickness, 0.5, connector_thickness, connector_thickness},
connect_front = {-connector_thickness, -connector_thickness, -0.5, connector_thickness, connector_thickness, 0},
connect_left = {-0.5, -connector_thickness, -connector_thickness, 0, connector_thickness, connector_thickness},
disconnected = {-connector_thickness,-connector_thickness,-connector_thickness,connector_thickness,connector_thickness,connector_thickness},
}
minetest.register_node("df_primordial_items:giant_hypha_root", {
description = S("Giant Hypha"),
tiles = {
{name="dfcaverns_mush_stalk_side.png"},
},
connects_to = {"group:soil", "group:hypha"},
connect_sides = { "top", "bottom", "front", "left", "back", "right" },
drawtype = "nodebox",
node_box = node_box,
paramtype = "light",
light_source = 2,
is_ground_content = false,
groups = {oddly_breakable_by_hand = 1, choppy = 2, hypha =1},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("df_primordial_items:giant_hypha", {
description = S("Giant Hypha"),
tiles = {
{name="dfcaverns_mush_stalk_side.png"},
},
connects_to = {"group:hypha"},
connect_sides = { "top", "bottom", "front", "left", "back", "right" },
drawtype = "nodebox",
node_box = node_box,
paramtype = "light",
light_source = 2,
is_ground_content = false,
groups = {oddly_breakable_by_hand = 1, choppy = 2, hypha =1},
sounds = default.node_sound_wood_defaults(),
})
local grow_mycelium = function(pos)
local nodes = {}
for x = -1, 1 do
nodes[x] = {}
for y = -1, 1 do
nodes[x][y] = {}
for z = -1, 1 do
local node = minetest.get_node({x=pos.x+x, y=pos.y+y, z=pos.z+z})
local state = {}
if minetest.get_item_group(node.name, "soil") > 0 then
state.soil = true
elseif minetest.get_item_group(node.name, "hypha") > 0 then
state.hypha = true
elseif minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].buildable_to then
state.buildable = true
end
nodes[x][y][z] = state
end
end
end
--TODO there's probably some clever way to turn this into a subroutine, but I'm tired right now and
--copy and pasting is easy and nobody's going to decide whether to hire or fire me based on this
--particular snippet of code so what the hell. I'll fix it later when that clever way comes to me.
local valid_targets = {}
if nodes[-1][0][0].buildable then
if
-- test for soil to directly support new growth
(nodes[-1][-1][0].soil or
nodes[-1][1][0].soil or
nodes[-1][0][-1].soil or
nodes[-1][0][1].soil or
-- test for soil "around the corner" to allow for growth over an edge
nodes[0][-1][0].soil or
nodes[0][1][0].soil or
nodes[0][0][-1].soil or
nodes[0][0][1].soil)
and not -- no adjacent hypha
(nodes[-1][-1][0].hypha or
nodes[-1][1][0].hypha or
nodes[-1][0][-1].hypha or
nodes[-1][0][1].hypha)
then
table.insert(valid_targets, {x=pos.x-1, y=pos.y, z=pos.z})
end
end
if nodes[1][0][0].buildable then
if
-- test for soil to directly support new growth
(nodes[1][-1][0].soil or
nodes[1][1][0].soil or
nodes[1][0][-1].soil or
nodes[1][0][1].soil or
-- test for soil "around the corner" to allow for growth over an edge
nodes[0][-1][0].soil or
nodes[0][1][0].soil or
nodes[0][0][-1].soil or
nodes[0][0][1].soil)
and not -- no adjacent hypha
(nodes[1][-1][0].hypha or
nodes[1][1][0].hypha or
nodes[1][0][-1].hypha or
nodes[1][0][1].hypha)
then
table.insert(valid_targets, {x=pos.x+1, y=pos.y, z=pos.z})
end
end
if nodes[0][-1][0].buildable then
if
-- test for soil to directly support new growth
(nodes[-1][-1][0].soil or
nodes[1][-1][0].soil or
nodes[0][-1][-1].soil or
nodes[0][-1][1].soil or
-- test for soil "around the corner" to allow for growth over an edge
nodes[-1][0][0].soil or
nodes[1][0][0].soil or
nodes[0][0][-1].soil or
nodes[0][0][1].soil)
and not -- no adjacent hypha
(nodes[-1][-1][0].hypha or
nodes[1][-1][0].hypha or
nodes[0][-1][-1].hypha or
nodes[0][-1][1].hypha)
then
table.insert(valid_targets, {x=pos.x, y=pos.y-1, z=pos.z})
end
end
if nodes[0][1][0].buildable then
if
-- test for soil to directly support new growth
(nodes[-1][1][0].soil or
nodes[1][1][0].soil or
nodes[0][1][-1].soil or
nodes[0][1][1].soil or
-- test for soil "around the corner" to allow for growth over an edge
nodes[-1][0][0].soil or
nodes[1][0][0].soil or
nodes[0][0][-1].soil or
nodes[0][0][1].soil)
and not -- no adjacent hypha
(nodes[-1][1][0].hypha or
nodes[1][1][0].hypha or
nodes[0][1][-1].hypha or
nodes[0][1][1].hypha)
then
table.insert(valid_targets, {x=pos.x, y=pos.y+1, z=pos.z})
end
end
if nodes[0][0][-1].buildable then
if
-- test for soil to directly support new growth
(nodes[-1][0][-1].soil or
nodes[1][0][-1].soil or
nodes[0][-1][-1].soil or
nodes[0][1][-1].soil or
-- test for soil "around the corner" to allow for growth over an edge
nodes[-1][0][0].soil or
nodes[1][0][0].soil or
nodes[0][-1][0].soil or
nodes[0][1][0].soil)
and not -- no adjacent hypha
(nodes[-1][0][-1].hypha or
nodes[1][0][-1].hypha or
nodes[0][-1][-1].hypha or
nodes[0][1][-1].hypha)
then
table.insert(valid_targets, {x=pos.x, y=pos.y, z=pos.z-1})
end
end
if nodes[0][0][1].buildable then
if
-- test for soil to directly support new growth
(nodes[-1][0][1].soil or
nodes[1][0][1].soil or
nodes[0][-1][1].soil or
nodes[0][1][1].soil or
-- test for soil "around the corner" to allow for growth over an edge
nodes[-1][0][0].soil or
nodes[1][0][0].soil or
nodes[0][-1][0].soil or
nodes[0][1][0].soil)
and not -- no adjacent hypha
(nodes[-1][0][1].hypha or
nodes[1][0][1].hypha or
nodes[0][-1][1].hypha or
nodes[0][1][1].hypha)
then
table.insert(valid_targets, {x=pos.x, y=pos.y, z=pos.z+1})
end
end
return valid_targets
end
minetest.register_node("df_primordial_items:giant_hypha_apical_meristem", {
description = S("Giant Hypha Apical Meristem"),
tiles = {
{name="dfcaverns_mush_stalk_side.png^[brighten"},
},
connects_to = {"group:hypha"},
connect_sides = { "top", "bottom", "front", "left", "back", "right" },
drawtype = "nodebox",
light_source = 6,
node_box = {
type = "connected",
fixed = {-0.25,-0.25,-0.25,0.25,0.25,0.25},
connect_top = {-0.375, 0, -0.375, 0.375, 0.5, 0.375},
connect_bottom = {-0.375, -0.5, -0.375, 0.375, 0, 0.375},
connect_back = {-0.375, -0.375, 0, 0.375, 0.375, 0.5},
connect_right = {0, -0.375, -0.375, 0.5, 0.375, 0.375},
connect_front = {-0.375, -0.375, -0.5, 0.375, 0.375, 0},
connect_left = {-0.5, -0.375, -0.375, 0, 0.375, 0.375},
disconnected = {-0.375,-0.375,-0.375,0.375,0.375,0.375},
},
paramtype = "light",
is_ground_content = false,
groups = {oddly_breakable_by_hand = 1, choppy = 2, hypha =1},
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(1.0)
end,
on_timer = function(pos, elapsed)
--if math.random() < 0.99 then
local targets = grow_mycelium(pos)
local target_count = #targets
if target_count > 0 then
minetest.set_node(targets[math.random(1,target_count)], {name="df_primordial_items:giant_hypha_apical_meristem"})
end
--end
if math.random() < 0.05 then
minetest.get_node_timer(pos):start(1.0) -- branch
elseif math.random() < 0.5 then
minetest.set_node(pos, {name="df_primordial_items:giant_hypha_root"})
else
minetest.set_node(pos, {name="df_primordial_items:giant_hypha"})
end
end,
})

View File

@ -10,3 +10,4 @@ dofile(MP.."/giant_fern.lua")
dofile(MP.."/fungal_nodes.lua")
dofile(MP.."/ceiling_fungus.lua")
dofile(MP.."/primordial_mushroom.lua")
dofile(MP.."/giant_mycelium.lua")