SHARE
TWEET

dig.lua

a guest Feb 24th, 2020 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. turtle.refuel(1)
  2. local range = math.floor(math.sqrt(turtle.getFuelLevel()))
  3. local steps = 0
  4. local turn = false
  5. local badb = {"minecraft:air", "minecraft:water", "minecraft:lava"}
  6. function isBad(name)
  7.     for i = 1, table.getn(badb), 1 do
  8.         if badb[i] == name then
  9.             return true
  10.         end
  11.     end
  12.     return false
  13. end
  14. while turtle.getFuelLevel() > 0 do
  15.     while turtle.dig() do
  16.     end
  17.     turtle.digDown()
  18.     turtle.forward()
  19.     local success, meta, err = turtle.inspectUp()
  20.     if not success or isBad(meta.name) then
  21.         turtle.placeUp()
  22.     end  
  23.     steps = steps + 1
  24.     if steps < range then
  25.         turtle.turnLeft()
  26.         success, meta = turtle.inspect()
  27.         if not success or isBad(meta.name) then
  28.             turtle.place()
  29.         end
  30.         turtle.turnRight()
  31.     end
  32.     if steps > (range * range) - range then
  33.         turtle.turnRight()
  34.         success, meta = turtle.inspect()
  35.         if not success or isBad(meta.name) then
  36.             turtle.place()
  37.         end
  38.         turtle.turnLeft()
  39.     end
  40.     if steps % range == 0 then
  41.         success, meta = turtle.inspect()
  42.         if not success or isBad(meta.name) then
  43.             turtle.place()
  44.         end
  45.         if turn then
  46.             turtle.turnLeft()
  47.         else
  48.             turtle.turnRight()
  49.         end
  50.         while turtle.dig() do
  51.         end    
  52.         turtle.digDown()
  53.         turtle.forward()
  54.         if turn then
  55.             turtle.turnLeft()
  56.         else
  57.             turtle.turnRight()
  58.         end
  59.         turn = not turn
  60.      end
  61. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top