gghf

collect

Jul 14th, 2022 (edited)
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.65 KB | None | 0 0
  1. -- definition
  2. local function collect()
  3.     local bFull = true
  4.     local nTotalItems = 0
  5.    
  6.     for n = 1, 16 do
  7.         local nCount = turtle.getItemCount(n)
  8.         if nCount == 0 then
  9.             bFull = false
  10.         end
  11.         nTotalItems = nTotalItems + nCount
  12.     end
  13.  
  14.     if nTotalItems > collected then
  15.         collected = nTotalItems
  16.         if math.fmod(collected + unloaded, 50) == 0 then
  17.             print("Mined " .. (collected + unloaded) .. " items.")
  18.         end
  19.     end
  20.  
  21.     if bFull then
  22.         print("No empty slots left.")
  23.         return false
  24.     end
  25.     return true
  26. end
  27.  
  28. -- export
  29. return { collect = collect }
Add Comment
Please, Sign In to add comment