add slow plant growth in non-tilled soil

This commit is contained in:
FaceDeer 2017-03-16 15:55:53 -06:00
parent e15fb67afb
commit c05373d273
3 changed files with 34 additions and 8 deletions

View File

@ -41,7 +41,7 @@ minetest.register_abm{
-- white/yellow -- white/yellow
minetest.register_node("dfcaverns:cobble_floor_fungus", { minetest.register_node("dfcaverns:cobble_with_floor_fungus", {
description = S("Cobblestone With Floor Fungus"), description = S("Cobblestone With Floor Fungus"),
tiles = {"default_cobble.png^dfcaverns_floor_fungus.png", "default_cobble.png", "default_cobble.png^dfcaverns_floor_fungus_side.png"}, tiles = {"default_cobble.png^dfcaverns_floor_fungus.png", "default_cobble.png", "default_cobble.png^dfcaverns_floor_fungus_side.png"},
drops = "default:cobble", drops = "default:cobble",
@ -54,12 +54,12 @@ minetest.register_node("dfcaverns:cobble_floor_fungus", {
minetest.register_abm{ minetest.register_abm{
label = "dfcaverns:floor_fungus_spread", label = "dfcaverns:floor_fungus_spread",
nodenames = {"default:cobble"}, nodenames = {"default:cobble"},
neighbors = {"dfcaverns:cobble_floor_fungus"}, neighbors = {"dfcaverns:cobble_with_floor_fungus"},
interval = 30, interval = 30,
chance = 10, chance = 10,
catch_up = true, catch_up = true,
action = function(pos) action = function(pos)
minetest.swap_node(pos, {name="dfcaverns:cobble_floor_fungus"}) minetest.swap_node(pos, {name="dfcaverns:cobble_with_floor_fungus"})
end, end,
} }

View File

@ -79,22 +79,45 @@ dfcaverns.register_seed = function(name, description, image, stage_one)
}) })
end end
local grow_underground_plant = function(pos, node)
local node_def = minetest.registered_nodes[node.name]
local next_stage = node_def._dfcaverns_next_stage
if next_stage then
local next_def = minetest.registered_nodes[next_stage]
minetest.swap_node(pos, {name=next_stage, param2 = next_def.place_param2 or node.param2})
end
end
dfcaverns.register_grow_abm = function(names, interval, chance) dfcaverns.register_grow_abm = function(names, interval, chance)
minetest.register_abm({ minetest.register_abm({
nodenames = names, nodenames = names,
interval = interval, interval = interval,
chance = chance, chance = chance,
catch_up = true,
neighbors = {"farming:soil_wet"},
action = function(pos, node) action = function(pos, node)
pos.y = pos.y-1 pos.y = pos.y-1
if minetest.get_node(pos).name ~= "farming:soil_wet" then if minetest.get_node(pos).name ~= "farming:soil_wet" then
return return
end end
local node_def = minetest.registered_nodes[node.name]
local next_stage = node_def._dfcaverns_next_stage
if next_stage then
local next_def = minetest.registered_nodes[next_stage]
pos.y = pos.y+1 pos.y = pos.y+1
minetest.swap_node(pos, {name=next_stage, param2 = next_def.place_param2 or node.param2}) grow_underground_plant(pos, node)
end
})
minetest.register_abm({
nodenames = names,
interval = interval * 10,
chance = chance,
catch_up = true,
neighbors = {"default:dirt", "dfcaverns:dirt_with_cave_moss", "dfcaverns:cobble_with_floor_fungus"},
action = function(pos, node)
pos.y = pos.y-1
if minetest.get_node(pos).name == "default:dirt" or
minetest.get_node(pos).name == "dfcaverns:dirt_with_cave_moss" or
minetest.get_node(pos).name == "dfcaverns:cobble_with_floor_fungus" then
pos.y = pos.y+1
grow_underground_plant(pos, node)
end end
end end
}) })

3
sounds/license.txt Normal file
View File

@ -0,0 +1,3 @@
https://freesound.org/people/DrMinky/sounds/167073/
https://freesound.org/people/HonorHunter/sounds/271666/
https://freesound.org/people/DrMinky/sounds/167074/