Flowers: Fix waterlily on-place itemstack code
authorparamat <mat.gregory@virginmedia.com>
Tue, 19 Jul 2016 21:26:02 +0000 (22:26 +0100)
committerparamat <mat.gregory@virginmedia.com>
Sat, 23 Jul 2016 03:56:49 +0000 (04:56 +0100)
Add 'record_protection_violation()'

mods/flowers/init.lua

index 2ec661e1589f5ffb0d96a2a7cddada97ff5ae6d0..83a05fade4cbadecc8f002b9e26b53bab797fec9 100644 (file)
@@ -243,16 +243,20 @@ minetest.register_node("flowers:waterlily", {
                local def = minetest.registered_nodes[node]
                local player_name = placer:get_player_name()
 
-               if def and def.liquidtype == "source" and minetest.get_item_group(node, "water") > 0 then
+               if def and def.liquidtype == "source" and
+                               minetest.get_item_group(node, "water") > 0 then
                        if not minetest.is_protected(pos, player_name) then
-                               minetest.set_node(pos, {name = "flowers:waterlily", param2 = math.random(0, 3)})
+                               minetest.set_node(pos, {name = "flowers:waterlily",
+                                       param2 = math.random(0, 3)})
+                               if not minetest.setting_getbool("creative_mode") then
+                                       itemstack:take_item()
+                               end
                        else
-                               minetest.chat_send_player(player_name, "This area is protected")
-                       end
-                       if not minetest.setting_getbool("creative_mode") then
-                               itemstack:take_item()
+                               minetest.chat_send_player(player_name, "Node is protected")
+                               minetest.record_protection_violation(pos, player_name)
                        end
                end
+
                return itemstack
        end
 })