LostMiner

Untitled

Oct 27th, 2016
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. t = turtle
  2.  
  3. function distanceInput()
  4.     print("Input Distance")
  5.     num = io.read
  6.     num = tonumber(num)
  7.     return num
  8. end
  9.  
  10. function hole(distance)
  11.     while distance > 0 do
  12.         if t.detectDown() then
  13.             t.digDown()
  14.             t.down()
  15.         else
  16.             t.down()
  17.     distance = distance - 1
  18.     end
  19. end
  20. function modulo(tile)
  21.     while tile > 8 do
  22.         tile = tile - 8
  23.     end
  24.     print("Currently at tile: ", tile)
  25.     return tile
  26. end
  27. function turn(num)
  28.     while num > 0 do
  29.         t.turnRight()
  30.         num = num - 1
  31.     end
  32. end
  33. function turnAround()
  34.     t.turnLeft()
  35.     t.turnLeft()
  36. end
  37. function dleft()
  38.     t.turnLeft()
  39.     if t.detect() then
  40.         t.dig()
  41.         t.forward()
  42.     else
  43.         t.forward()
  44.     end
  45.     t.turnRight()
  46. end
  47. function dright()
  48.     t.turnRight()
  49.     if t.detect() then
  50.         t.dig()
  51.         t.forward()
  52.     else
  53.         t.forward()
  54.     end
  55.     t.turnLeft()
  56. end
  57. function dback()
  58.     turnAround()
  59.     if t.detect() then
  60.         t.dig()
  61.         t.forward()
  62.     else
  63.         t.forward()
  64.     end
  65.     turnAround()
  66. end
  67. function bforward()
  68.     if t.detect() then
  69.         t.dig()
  70.         t.forward()
  71.     else
  72.         t.forward()
  73.     end
  74. end
  75. function mineLayer(module)
  76.     if module == 2 or module == 4 or module == 6 or module == 8 then
  77.         turn(module/2)
  78.         dleft()
  79.         dforward()
  80.         dback()
  81.         dback()
  82.         dright()
  83.         dright()
  84.         dforward()
  85.         dforward()
  86.         dback()
  87.         dleft()
  88.     else
  89.         turn((module+1)/2)
  90.         dforward()
  91.         dright()
  92.         dback()
  93.         dback()
  94.         dleft()
  95.         dleft()
  96.         dforward()
  97.         dright()
  98.     end
  99. end
  100. function mine(distance)
  101.     module = 0
  102.     while distance > 0 do
  103.         module = modulo(distance)
  104.         mineLayer(module)
  105.         t.up()
  106.         distance = distance - 1
  107.     end
  108. end
  109. function spiral()
  110.     distance = distanceInput()
  111.     print("3x3 Spiral Initiated; No further input required")
  112.     hole(distance)
  113.     mine(distance)
  114. end
Add Comment
Please, Sign In to add comment