gghf icon

collect

gghf | PRO | 07/14/22 08:34:58 AM UTC (Edited) | 0 ⭐ | 200 👁️ | Never ⏰ | []
Lua |

650 B

|

None

|

0 👍

/

0 👎

-- definition
local function collect()
    local bFull = true
    local nTotalItems = 0
    
    for n = 1, 16 do
        local nCount = turtle.getItemCount(n)
        if nCount == 0 then
            bFull = false
        end
        nTotalItems = nTotalItems + nCount
    end
 
    if nTotalItems > collected then
        collected = nTotalItems
        if math.fmod(collected + unloaded, 50) == 0 then
            print("Mined " .. (collected + unloaded) .. " items.")
        end
    end
 
    if bFull then
        print("No empty slots left.")
        return false
    end
    return true
end
 
-- export
return { collect = collect }

Comments