mirror of
https://github.com/FaceDeer/dfcaverns.git
synced 2025-01-29 03:20:22 +01:00
switch from ABM to node timer for mapgen mycelium growth
This commit is contained in:
parent
7877f2cb4b
commit
bf507c3177
@ -60,7 +60,9 @@ local mushroom_cavern_floor = function(abs_cracks, humidity, vi, area, data, dat
|
|||||||
|
|
||||||
local rand = math.random() * math.min(abs_cracks, 1) * humidityfactor
|
local rand = math.random() * math.min(abs_cracks, 1) * humidityfactor
|
||||||
if rand < 0.0005 then
|
if rand < 0.0005 then
|
||||||
data[vi+ystride] = c_giant_mycelium
|
local mycelium_index = vi+ystride
|
||||||
|
data[mycelium_index] = c_giant_mycelium
|
||||||
|
minetest.get_node_timer(area:position(mycelium_index)):start(math.random(1,10))
|
||||||
elseif rand < 0.003 then
|
elseif rand < 0.003 then
|
||||||
local schematic = df_primordial_items.get_primordial_mushroom()
|
local schematic = df_primordial_items.get_primordial_mushroom()
|
||||||
local rotation = (math.random(1,4)-1)*90
|
local rotation = (math.random(1,4)-1)*90
|
||||||
@ -80,7 +82,9 @@ local mushroom_cavern_ceiling = function(abs_cracks, humidity, vi, area, data, d
|
|||||||
if abs_cracks < 0.3 then
|
if abs_cracks < 0.3 then
|
||||||
local rand = math.random() * humidityfactor
|
local rand = math.random() * humidityfactor
|
||||||
if rand < 0.002 then
|
if rand < 0.002 then
|
||||||
data[vi-ystride] = c_giant_mycelium
|
local mycelium_index = vi-ystride
|
||||||
|
data[mycelium_index] = c_giant_mycelium
|
||||||
|
minetest.get_node_timer(area:position(mycelium_index)):start(math.random(1,10))
|
||||||
elseif rand < 0.03 then
|
elseif rand < 0.03 then
|
||||||
df_primordial_items.spawn_ceiling_spire_vm(vi, area, data)
|
df_primordial_items.spawn_ceiling_spire_vm(vi, area, data)
|
||||||
elseif rand < 0.2 then
|
elseif rand < 0.2 then
|
||||||
@ -99,7 +103,9 @@ local mushroom_warren_ceiling = function(abs_cracks, vi, area, data, data_param2
|
|||||||
if abs_cracks < 0.2 then
|
if abs_cracks < 0.2 then
|
||||||
local rand = math.random()
|
local rand = math.random()
|
||||||
if rand < 0.002 then
|
if rand < 0.002 then
|
||||||
data[vi-ystride] = c_giant_mycelium
|
local mycelium_index = vi-ystride
|
||||||
|
data[mycelium_index] = c_giant_mycelium
|
||||||
|
minetest.get_node_timer(area:position(mycelium_index)):start(math.random(1,10))
|
||||||
elseif rand < 0.2 then
|
elseif rand < 0.2 then
|
||||||
data[vi-ystride] = c_orb
|
data[vi-ystride] = c_orb
|
||||||
data_param2[vi-ystride] = math.random(0,179)
|
data_param2[vi-ystride] = math.random(0,179)
|
||||||
@ -117,7 +123,9 @@ local mushroom_warren_floor = function(abs_cracks, vi, area, data, data_param2)
|
|||||||
end
|
end
|
||||||
local rand = math.random() * math.min(abs_cracks, 1)
|
local rand = math.random() * math.min(abs_cracks, 1)
|
||||||
if rand < 0.001 then
|
if rand < 0.001 then
|
||||||
data[vi+ystride] = c_giant_mycelium
|
local mycelium_index = vi+ystride
|
||||||
|
data[mycelium_index] = c_giant_mycelium
|
||||||
|
minetest.get_node_timer(area:position(mycelium_index)):start(math.random(1,10))
|
||||||
elseif rand < 0.03 then
|
elseif rand < 0.03 then
|
||||||
data[vi+ystride] = fungal_plants[math.random(1,5)]
|
data[vi+ystride] = fungal_plants[math.random(1,5)]
|
||||||
end
|
end
|
||||||
@ -348,6 +356,7 @@ local decorate_primordial = function(minp, maxp, seed, vm, node_arrays, area, da
|
|||||||
local rand_vi = vi + random_dir[math.random(1,4)]
|
local rand_vi = vi + random_dir[math.random(1,4)]
|
||||||
if data[rand_vi] == c_air then
|
if data[rand_vi] == c_air then
|
||||||
data[rand_vi] = c_giant_mycelium
|
data[rand_vi] = c_giant_mycelium
|
||||||
|
minetest.get_node_timer(area:position(rand_vi)):start(math.random(1,10))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -363,9 +363,25 @@ minetest.register_node("df_primordial_items:giant_hypha_apical_meristem", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- this version grows instantly via ABM, it is meant for mapgen usage.
|
-- this version grows instantly, it is meant for mapgen usage.
|
||||||
-- An ABM is used so that it will trigger only after the surrounding map chunks have
|
|
||||||
-- also been generated, in case it wants to grow into them.
|
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, re-trigger it.
|
||||||
|
for _, new_pos in ipairs(new_poses) do
|
||||||
|
table.insert(stack, new_pos)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
minetest.get_node_timer(pos):start(math.random(10,60))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("df_primordial_items:giant_hypha_apical_mapgen", {
|
minetest.register_node("df_primordial_items:giant_hypha_apical_mapgen", {
|
||||||
description = S("Giant Hypha Apical Meristem"),
|
description = S("Giant Hypha Apical Meristem"),
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -382,29 +398,13 @@ minetest.register_node("df_primordial_items:giant_hypha_apical_mapgen", {
|
|||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {oddly_breakable_by_hand = 1, choppy = 2, hypha = 1, not_in_creative_inventory = 1, light_sensitive_fungus = 13},
|
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(),
|
sounds = df_trees.node_sound_tree_soft_fungus_defaults(),
|
||||||
})
|
on_timer = function(pos, elapsed)
|
||||||
|
|
||||||
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
|
|
||||||
table.insert(stack, new_pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
label = "Mycelium mapgen growth",
|
|
||||||
nodenames = {"df_primordial_items:giant_hypha_apical_mapgen"},
|
|
||||||
interval = 1.0,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
grow_mycelium_immediately(pos)
|
grow_mycelium_immediately(pos)
|
||||||
end
|
end,
|
||||||
|
on_construct = function(pos)
|
||||||
|
minetest.get_node_timer(pos):start(1)
|
||||||
|
end,
|
||||||
|
on_destruct = function(pos)
|
||||||
|
minetest.get_node_timer(pos):stop()
|
||||||
|
end,
|
||||||
})
|
})
|
Loading…
Reference in New Issue
Block a user