Guest User

mine

a guest
Nov 28th, 2015
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. os.loadAPI("tAPIs") --loads fuel function
  2. local depth = 0 --sets variable to return back to surface
  3. function junk() --defines function
  4.     if turtle.inspect() == "minecraft:iron_ore" then --determines if item is valuable
  5.         turtle.dig()   
  6.     end
  7. end
  8. function walls() --checks all four walls and determines if anything is worth mining
  9.     for w = 1,4 do --runs four times
  10.         turtle.select(1) --selects first slot
  11.         turtle.inspect() --compares front object to first slot
  12.         junk()
  13.         turtle.turnLeft() --turns left for next wall
  14.     end
  15. end
  16. tAPIs.fuel() --refuels
  17. turtle.digDown() --digs down so that detect doesnt return true
  18. for d = 1,2 do --digs down two blocks
  19.     turtle.down()
  20.     turtle.digDown()
  21.     depth = depth-1 --records depth
  22. end
  23. turtle.detectDown() --detects if block is under turtle
  24. while turtle.detectDown() ~= true do --if nothing under turtle then this runs
  25.     turtle.down()
  26.     depth = depth-1
  27.     walls()
  28.     turtle.digDown()
  29.     turtle.detectDown()
  30. end
  31.  
  32.  if turtle.detectDown() == true then --when turtle encounters bedrock or air, needs to be fixed for caves
  33.     tAPIs.fuel()
  34.     while depth < 0 do --loop to return to surface or starting position
  35.         turtle.up()
  36.         depth = depth+1 --records depth
  37.     end
  38. end
  39.  
  40. if depth == 0 then --when turtle reaches starting position place down a block and stop moving
  41.     turtle.select(2)
  42.     turtle.placeDown()
  43.     error()
  44. end
Advertisement
Add Comment
Please, Sign In to add comment