Advertisement
Sapish

Library code: Mining turtle

Aug 24th, 2020 (edited)
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. step = 0
  2. term.clear()
  3. term.setCursorPos(1, 1)
  4. while true do
  5.     if turtle.detect() then
  6.         turtle.dig()
  7.         if turtle.forward() then
  8.             step = step +1
  9.             turtle.digUp()
  10.         end
  11.     end
  12.     itemCount = turtle.getItemCount(16)
  13.     fuelLeft = turtle.getFuelLevel()
  14.     if itemCount == 64 then
  15.         while step > 0 do
  16.             if turtle.back() then
  17.                 step = step - 1
  18.             end
  19.         end
  20.         for i = 1, 16 do
  21.             turtle.select(i)
  22.             turtle.dropUp()
  23.         end
  24.         turtle.select(1)
  25.         print('Bag Full')
  26.         break
  27.     elseif fuelLeft == step then
  28.         while step > 0 do
  29.             if turtle.back() then
  30.                 step = step - 1
  31.             end
  32.         end
  33.         for i = 1, 16 do
  34.             turtle.select(i)
  35.             turtle.dropUp()
  36.         end
  37.         turtle.select(1)
  38.         print('Out of fuel')
  39.         break
  40.     elseif turtle.detect() == false then
  41.         while step > 0 do
  42.             if turtle.back() then
  43.                 step = step - 1
  44.             end
  45.         end
  46.         for i = 1, 16 do
  47.             turtle.select(i)
  48.             turtle.dropUp()
  49.         end
  50.         turtle.select(1)
  51.         print('Reached opening')
  52.         break
  53.     end
  54. end
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement