Tim
2015-02-06 48e02b84526733eaa0f99ccc01de6d76ad1ba7fa
drop upgrade list items if dug (but protect other inventories)
1 files modified
10 ■■■■ changed files
technic/machines/register/common.lua 10 ●●●● patch | view | raw | blame | history
technic/machines/register/common.lua
@@ -138,18 +138,22 @@
    meta:set_int("tube_time", tube_time)
end
function technic.machine_can_dig(pos, player)
    local meta = minetest.get_meta(pos)
    local inv = meta:get_inventory()
    if not inv:is_empty("src") or not inv:is_empty("dst") or
       not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
    if not inv:is_empty("src") or not inv:is_empty("dst") then
        if player then
            minetest.chat_send_player(player:get_player_name(),
                S("Machine cannot be removed because it is not empty"))
        end
        return false
    else
        if not inv:is_empty("upgrade1") then
            minetest.item_drop(inv:get_stack("upgrade1", 1), "", pos)
        end
        if not inv:is_empty("upgrade2") then
            minetest.item_drop(inv:get_stack("upgrade2", 1), "", pos)
        end
        return true
    end
end