Flowers: Cleaning of waterlily's placement 1028/head
authorkilbith <jeanpatrick.guerrero@gmail.com>
Thu, 7 Apr 2016 11:10:18 +0000 (13:10 +0200)
committerparamat <mat.gregory@virginmedia.com>
Fri, 8 Apr 2016 00:13:14 +0000 (01:13 +0100)
mods/flowers/init.lua

index 85fa36efc18be408f4351098dedbbe9b2c2da2cc..f5e6d2cf8ece56b49bb81fda91e3b40779fba150 100644 (file)
@@ -217,6 +217,7 @@ minetest.register_node("flowers:waterlily", {
        liquids_pointable = true,
        walkable = false,
        buildable_to = true,
+       sunlight_propagates = true,
        groups = {snappy = 3, flower = 1},
        sounds = default.node_sound_leaves_defaults(),
        node_box = {
@@ -228,22 +229,12 @@ minetest.register_node("flowers:waterlily", {
                fixed = {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5}
        },
 
-       after_place_node = function(pos, placer, itemstack, pointed_thing)
-               local find_water = minetest.find_nodes_in_area({x = pos.x - 1, y = pos.y, z = pos.z - 1},
-                       {x = pos.x + 1, y = pos.y, z = pos.z + 1}, "default:water_source")
-               local find_river_water = minetest.find_nodes_in_area({x = pos.x - 1, y = pos.y, z = pos.z - 1},
-                       {x = pos.x + 1, y = pos.y, z = pos.z + 1}, "default:river_water_source")
-               if #find_water ~= 0 then
-                       minetest.set_node(pos, {name = "default:water_source"})
-                       pos.y = pos.y + 1
-                       minetest.set_node(pos, {name = "flowers:waterlily", param2 = math.random(0, 3)})
-               elseif #find_river_water ~= 0 then
-                       minetest.set_node(pos, {name = "default:river_water_source"})
-                       pos.y = pos.y + 1
+       on_place = function(_, _, pointed_thing)
+               local pos = pointed_thing.above
+               local node = minetest.get_node(pointed_thing.under).name
+               local def = minetest.registered_nodes[node]
+               if def and def.liquidtype == "source" and minetest.get_item_group(node, "water") > 0 then
                        minetest.set_node(pos, {name = "flowers:waterlily", param2 = math.random(0, 3)})
-               else
-                       minetest.remove_node(pos)
-                       return true
                end
        end
 })