Forbid digging milkers with buckets in them master
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Sat, 27 Jun 2020 22:37:17 +0000 (00:37 +0200)
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Sat, 27 Jun 2020 22:37:17 +0000 (00:37 +0200)
init.lua

index b5426ab..2661bda 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -67,8 +67,12 @@ local function on_construct(pos)
 end
 
 local function can_dig(pos)
+       local node = minetest.get_node(pos)
    local meta = minetest.get_meta(pos)
    local inv = meta:get_inventory()
+       if node.name == "feedlot:milker" then
+               return inv:is_empty("main") and inv:is_empty("bucket")
+       end
    return inv:is_empty("main")
 end
 
@@ -125,7 +129,7 @@ local function feed_animals (pos, elapsed)
        local meta = minetest.get_meta(pos)
        local inv = meta:get_inventory()
 
-
+       
        local fake_player = feedlotFakePlayer.create(pos, "fake_player")
 
        local radius = 3
@@ -149,7 +153,7 @@ local function feed_animals (pos, elapsed)
                                        if node.name == "feedlot:milker" and not inv:room_for_item("main", "mobs:bucket_milk") then
                                                return false
                                        end
-                                       obj:get_luaentity():on_rightclick(fake_player)                                  
+                                       obj:get_luaentity():on_rightclick(fake_player)
                                end
                        end
                end