Advertisement
Guest User

mine

a guest
Nov 28th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. os.loadAPI("tAPIs")
  2. local depth = 0
  3. local treasure = {"minecraft:iron_ore" = true,"minecraft:coal_ore" = true,"minecraft:gold_ore" = true,"minecraft:diamond_ore" = true}
  4. local function junk() --defines function
  5.         local found, block = turtle.inspect()
  6.         if found and treasure[block.name] then
  7.                 turtle.dig()  
  8.         end
  9. end
  10. local function walls()
  11.     for w = 1,4 do
  12.         turtle.select(1)
  13.         turtle.inspect()
  14.         junk()
  15.         turtle.turnLeft()
  16.     end
  17. end
  18. tAPIs.fuel() --refuels
  19. turtle.digDown() --digs down so that detect doesnt return true
  20. for d = 1,2 do --digs down two blocks
  21.     turtle.down()
  22.     turtle.digDown()
  23.     depth = depth-1 --records depth
  24. end
  25. turtle.detectDown() --detects if block is under turtle
  26. while turtle.detectDown() ~= true do --if nothing under turtle then this runs
  27.     turtle.down()
  28.     depth = depth-1
  29.     walls()
  30.     turtle.digDown()
  31.     turtle.detectDown()
  32. end
  33.  
  34.  if turtle.detectDown() == true then --when turtle encounters bedrock or air, needs to be fixed for caves
  35.     tAPIs.fuel()
  36.     while depth < 0 do --loop to return to surface or starting position
  37.         turtle.up()
  38.         depth = depth+1 --records depth
  39.     end
  40. end
  41.  
  42. if depth == 0 then --when turtle reaches starting position place down a block and stop moving
  43.     turtle.select(2)
  44.     turtle.placeDown()
  45.     error()
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement