summaryrefslogtreecommitdiff
path: root/farming/beanpole.lua
diff options
context:
space:
mode:
Diffstat (limited to 'farming/beanpole.lua')
-rw-r--r--farming/beanpole.lua26
1 files changed, 24 insertions, 2 deletions
diff --git a/farming/beanpole.lua b/farming/beanpole.lua
index 5bd0448..1e81dac 100644
--- a/farming/beanpole.lua
+++ b/farming/beanpole.lua
@@ -64,6 +64,7 @@ end
minetest.register_craftitem("farming:beans", {
description = S("Green Beans"),
inventory_image = "farming_beans.png",
+ groups = {food_beans = 1, flammable = 2},
on_use = minetest.item_eat(1),
on_place = function(itemstack, placer, pointed_thing)
@@ -97,11 +98,32 @@ minetest.register_node("farming:beanpole", {
on_place = function(itemstack, placer, pointed_thing)
- if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
+ local pt = pointed_thing
+
+ -- check if pointing at a node
+ if not pt or pt.type ~= "node" then
+ return
+ end
+
+ local under = minetest.get_node(pt.under)
+
+ -- return if any of the nodes are not registered
+ if not minetest.registered_nodes[under.name] then
+ return
+ end
+
+ -- am I right-clicking on something that has a custom on_place set?
+ -- thanks to Krock for helping with this issue :)
+ local def = minetest.registered_nodes[under.name]
+ if def and def.on_rightclick then
+ return def.on_rightclick(pt.under, under, placer, itemstack)
+ end
+
+ if minetest.is_protected(pt.under, placer:get_player_name()) then
return
end
- local nodename = minetest.get_node(pointed_thing.under).name
+ local nodename = under.name
if minetest.get_item_group(nodename, "soil") < 2 then
return