return table
end
+
--
-- Lavacooling
--
neighbors = {"group:water"},
interval = 1,
chance = 1,
- action = function(pos, node, active_object_count, active_object_count_wider)
- default.cool_lava_flowing(pos, node, active_object_count, active_object_count_wider)
+ action = function(...)
+ default.cool_lava_flowing(...)
end,
})
neighbors = {"group:water"},
interval = 1,
chance = 1,
- action = function(pos, node, active_object_count, active_object_count_wider)
- default.cool_lava_source(pos, node, active_object_count, active_object_count_wider)
+ action = function(...)
+ default.cool_lava_source(...)
end,
})
+
--
-- Papyrus and cactus growing
--
+function default.grow_cactus(pos, node)
+ if node.param2 ~= 0 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
+ while node.name == "default:cactus" and height < 4 and node.param2 == 0 do
+ height = height+1
+ pos.y = pos.y+1
+ node = minetest.get_node(pos)
+ end
+ if height == 4
+ or node.name ~= "air" then
+ return
+ end
+ minetest.set_node(pos, {name="default:cactus"})
+ return true
+end
+
+function default.grow_papyrus(pos, node)
+ pos.y = pos.y-1
+ local name = minetest.get_node(pos).name
+ if name ~= "default:dirt_with_grass"
+ and name ~= "default:dirt" then
+ return
+ end
+ if not minetest.find_node_near(pos, 3, {"group:water"}) then
+ return
+ end
+ pos.y = pos.y+1
+ local height = 0
+ while node.name == "default:papyrus" and height < 4 do
+ height = height+1
+ pos.y = pos.y+1
+ node = minetest.get_node(pos)
+ end
+ if height == 4
+ or node.name ~= "air" then
+ return
+ end
+ minetest.set_node(pos, {name="default:papyrus"})
+ return true
+end
+
+-- wrapping the functions in abm action is necessary to make overriding them possible
minetest.register_abm({
nodenames = {"default:cactus"},
neighbors = {"group:sand"},
interval = 50,
chance = 20,
- action = function(pos, node)
- pos.y = pos.y-1
- local name = minetest.get_node(pos).name
- if minetest.get_item_group(name, "sand") ~= 0 then
- pos.y = pos.y+1
- local height = 0
- while minetest.get_node(pos).name == "default:cactus" and height < 4 do
- height = height+1
- pos.y = pos.y+1
- end
- if height < 4 then
- if minetest.get_node(pos).name == "air" then
- minetest.set_node(pos, {name="default:cactus"})
- end
- end
- end
- end,
+ action = function(...)
+ default.grow_cactus(...)
+ end
})
minetest.register_abm({
neighbors = {"default:dirt", "default:dirt_with_grass"},
interval = 50,
chance = 20,
- action = function(pos, node)
- pos.y = pos.y-1
- local name = minetest.get_node(pos).name
- if name == "default:dirt" or name == "default:dirt_with_grass" then
- if minetest.find_node_near(pos, 3, {"group:water"}) == nil then
- return
- end
- pos.y = pos.y+1
- local height = 0
- while minetest.get_node(pos).name == "default:papyrus" and height < 4 do
- height = height+1
- pos.y = pos.y+1
- end
- if height < 4 then
- if minetest.get_node(pos).name == "air" then
- minetest.set_node(pos, {name="default:papyrus"})
- end
- end
- end
- end,
+ action = function(...)
+ default.grow_papyrus(...)
+ end
})
+
--
-- dig upwards
--
end
end
+
--
-- Leafdecay
--