This is the git diff of the replacement abm that I wrote to grow papyrus the way the map generator places it (papyrus on a water node and dirt under the water):
Code: Select all
diff --git a/mods/default/functions.lua b/mods/default/functions.lua
index 4f5f85d..5a35c6e 100644
--- a/mods/default/functions.lua
+++ b/mods/default/functions.lua
@@ -241,26 +241,34 @@ minetest.register_abm({
minetest.register_abm({
nodenames = {"default:papyrus"},
- neighbors = {"default:dirt", "default:dirt_with_grass"},
+ neighbors = {"group:water"},
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
+ -- Check that the node under it is a member of the "water" group
+ local p = {x = pos.x, y = pos.y - 1, z = pos.z}
+ local under = minetest.get_node(p).name
+ local rc = minetest.registered_nodes[under].groups.water
+ if not rc then
+ return
+ end
+
+ -- Check that there is dirt under the water
+ p.y = p.y - 1
+ under = minetest.get_node(p).name
+ if under ~= "default:dirt" then
+ return
+ end
+
+ -- Process to grow the papyrus
+ local height = 0
+ while minetest.get_node(pos).name == "default:papyrus" and height < 4 do
+ height = height+1
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
+ if height < 4 then
+ if minetest.get_node(pos).name == "air" then
+ minetest.set_node(pos, {name="default:papyrus"})
end
end
end,
It seems to work but I'm still too new to both minetest and lua to be sure about side effects.
Edit:
About the melon again, the wild melon that you find behaves like jungle grass when you interact with it. While the melon from a seed that you planted yourself behaves like a pumpkin: you can't walk through it, can step on it, sounds like wood when you punch it... The melons on the top of a "hobbit hole" are like pumpkins too.
Edit 2:
There is the same difference between the wild cabbage and the cultivated one.