Advertisement
LostMiner

Untitled

Oct 27th, 2016
74
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. function fuel(distance)
  10.     t.refuel()
  11. end
  12. function hole(distance)
  13.     while distance > 0 do
  14.         if t.detectDown() then
  15.             t.digDown()
  16.             t.down()
  17.         else
  18.             t.down()
  19.         end
  20.     distance = distance - 1
  21.     end
  22. end
  23. function dforward()
  24.     if t.detect() then
  25.         t.dig()
  26.         t.forward()
  27.     else
  28.         t.forward()
  29.     end
  30. end
  31. function turn()
  32.     t.turnRight()
  33. end
  34. function mineLayer()
  35.     num = 3
  36.     if mark then
  37.         while num > 0 do
  38.             dforward()
  39.             turn()
  40.             dforward()
  41.             num = num - 1
  42.         end
  43.         dforward()
  44.         turn()
  45.         t.digUp()
  46.         t.up()
  47.     else
  48.         while num > 0 do
  49.             dforward()
  50.             dforward()
  51.             turn()
  52.             num = num - 1
  53.         end
  54.         --dforward()--
  55.         t.digUp()
  56.         t.up()
  57.     end
  58. end
  59. function mine(distance)
  60.     mark = true
  61.     dforward()
  62.     turn()
  63.     while distance > 0 do
  64.         mineLayer(mark)
  65.         distance = distance - 1
  66.         mark = not mark
  67.     end
  68. end
  69. function spiral()
  70.     distance = distanceInput()
  71.     fuel(distance)
  72.     print("3x3 Spiral Initiated; No further input required")
  73.     hole(distance)
  74.     mine(distance)
  75. end
  76.  
  77. spiral()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement