Advertisement
Oysi

Turtle Miner 2.0

Mar 16th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1.  
  2. -- Script made by Oysi
  3.  
  4. local args = {...}
  5.  
  6. local x = tonumber(args[1]) or 1
  7. local y = tonumber(args[2]) or 1
  8. local z = tonumber(args[3]) or 1
  9.  
  10. function mineForward()
  11.     if turtle.detect() then
  12.         turtle.dig()
  13.     end
  14.     if not turtle.forward() then
  15.         sleep(0.1)
  16.         mineForward()
  17.         return true
  18.     end
  19. end
  20.  
  21. function mineUp()
  22.     if turtle.detectUp() then
  23.         turtle.digUp()
  24.     end
  25.     if not turtle.up() then
  26.         sleep(0.1)
  27.         mineUp()
  28.         return true
  29.     end
  30. end
  31.  
  32. function mineUpAndDown()
  33.     local i = 0
  34.     for k = 1, y - 1 do
  35.         i = k
  36.         if mineUp() then
  37.             break
  38.         end
  39.     end
  40.     for k = 1, i do
  41.         turtle.down()
  42.     end
  43. end
  44.  
  45. function mineForwardProblem()
  46.     local problem = mineForward()
  47.     if not problem then
  48.         mineUpAndDown()
  49.     end
  50. end
  51.  
  52. function turnLeft()
  53.     repeat until turtle.turnLeft()
  54. end
  55.  
  56. function turnRight()
  57.     repeat until turtle.turnRight()
  58. end
  59.  
  60. mineUpAndDown()
  61. for i = 1, x do
  62.     for j = 1, z - 1 do
  63.         mineForwardProblem()
  64.     end
  65.     local f = i%2 == 0 and turnLeft or turnRight
  66.     if i < x then
  67.         f()
  68.         mineForwardProblem()
  69.         f()
  70.     end
  71. end
  72. if x % 2 == 0 then
  73.     turnRight()
  74.     for i = 1, x - 1 do
  75.         mineForward()
  76.     end
  77.     turnRight()
  78. else
  79.     turnLeft()
  80.     for i = 1, x - 1 do
  81.         mineForward()
  82.     end
  83.     turnLeft()
  84.     for i = 1, z - 1 do
  85.         mineForward()
  86.     end
  87.     turnLeft()
  88.     turnLeft()
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement