Flowers: Add waterlily right-click checks
authortenplus1 <tenplus1@users.noreply.github.com>
Thu, 21 Sep 2017 14:18:08 +0000 (15:18 +0100)
committersfan5 <sfan5@live.de>
Sun, 19 Nov 2017 22:03:38 +0000 (23:03 +0100)
Check for on_rightclick functions of nodes when holding a waterlily.

mods/flowers/init.lua

index 57112c16bc5fdb7fe7d93c5e28bad63ce77a27eb..b584939777b2dc2ad2455b47ffd63b6f7615eeaf 100644 (file)
@@ -276,12 +276,17 @@ minetest.register_node("flowers:waterlily", {
 
        on_place = function(itemstack, placer, pointed_thing)
                local pos = pointed_thing.above
-               local node = minetest.get_node(pointed_thing.under).name
-               local def = minetest.registered_nodes[node]
+               local node = minetest.get_node(pointed_thing.under)
+               local def = minetest.registered_nodes[node.name]
                local player_name = placer:get_player_name()
 
+               if def and def.on_rightclick then
+                       return def.on_rightclick(pointed_thing.under, node, placer, itemstack,
+                                       pointed_thing)
+               end
+
                if def and def.liquidtype == "source" and
-                               minetest.get_item_group(node, "water") > 0 then
+                               minetest.get_item_group(node.name, "water") > 0 then
                        if not minetest.is_protected(pos, player_name) then
                                minetest.set_node(pos, {name = "flowers:waterlily",
                                        param2 = math.random(0, 3)})