LostMiner

Untitled

Oct 28th, 2016
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ------Tunneling Automaton - V2------
  2.  
  3. ----Variables----
  4.  
  5. t = turtle
  6. orientation = 1
  7.  
  8. ----Basic Controls----
  9.  
  10. --Turning--
  11. function turnLeft()
  12.     if orientation == 4 then
  13.         orientation = 0
  14.     else
  15.         orientation = orientation + 1
  16.     end
  17.     t.turnLeft()
  18. end
  19. function turnRight()
  20.     if orientation == 1 then
  21.         orientation = 4
  22.     else
  23.         orientation = orientation - 1
  24.     end
  25.     t.turnRight()
  26. end
  27.  
  28. function reorient()
  29.     if orientation == 2 then
  30.         turnLeft()
  31.     elseif orientation == 3 then
  32.         turnLeft()
  33.         turnLeft()
  34.     elseif orientation == 4 then
  35.         turnRight()
  36.     end
  37. end
  38.  
  39. --Digging--
  40. function digUp()
  41.     t.digUp()
  42. end
  43. function digDown()
  44.     t.digDown()
  45. end
  46. function digForward()
  47.     t.digForward()
  48. end
  49. function digLeft()
  50.     turnLeft()
  51.     digForward()
  52. end
  53. function digRight()
  54.     turnRight()
  55.     digForward()
  56. end
  57.  
  58. --Moving--
  59. function moveUp()
  60.     t.up()
  61. end
  62. function moveDown()
  63.     t.down()
  64. end
  65. function moveForward()
  66.     t.forward()
  67. end
  68. function moveLeft()
  69.     turnLeft()
  70.     moveForward()
  71. end
  72. function moveRight()
  73.     turnRight()
  74.     moveFoward()
  75. end
  76.  
  77. --Digging and Moving--
  78. function goUp()
  79.     if t.detectUp() then
  80.         digUp()
  81.         moveUp()
  82.     else
  83.         moveUp()
  84.     end
  85. end
  86. function goDown()
  87.     if t.detectDown() then
  88.         digDown()
  89.         moveDown()
  90.     else
  91.         moveDown()
  92.     end
  93. end
  94. function goForward()
  95.     if t.detect() then
  96.         digForward()
  97.         moveForward()
  98.     else
  99.         moveForward()
  100.     end
  101. end
  102. function goRight()
  103.     turnRight()
  104.     if t.detect() then
  105.         digForward()
  106.         moveForward()
  107.     else
  108.         moveForward()
  109.     end
  110. end
  111. function goLeft()
  112.     turnLeft()
  113.     if t.detect() then
  114.         digForward()
  115.         moveForward()
  116.     else
  117.         moveForward()
  118.     end
  119. end
  120.  
  121. ----Inventory----
  122. --Check if any slots are free--
  123. function freeSlots()
  124.     num = 16
  125.     spaceLeft = false
  126.     while num > 0 do
  127.         if t.getItemCount(num) == 0 then
  128.             spaceLeft = true
  129.         end
  130.         num = num - 1
  131.     end
  132.     return spaceLeft
  133. end
  134.  
  135. function placeStorageChest()
  136.     t.select(1)
  137.     digUp()
  138.     t.placeUp()
  139. end
  140. function placeFuelChest()
  141.     t.select(2)
  142.     digUp()
  143.     t.placeUp()
  144. end
  145. function placeChunkLoader()
  146.     t.select(3)
  147.     digUp()
  148.     t.placeUp()
  149. end
  150.  
  151. function getFuel()
  152.     t.select(2)
  153.     t.suckUp(10)
  154. end
  155. function store()
  156.     num = 16
  157.     while num > 3 do
  158.         t.dropUp()
  159.         num = num - 1
  160.     end
  161. end
  162. function fuel()
  163.     t.select(2)
  164.     t.refuel()
  165. end
  166.  
  167. ----Mining----
  168. function shaft
  169. //ADD mining shaft, add check fuel left and refill, add chunk loaders
  170. ----Main Loop----
  171. function main()
  172.    
  173. end
  174. --Run--
  175. main()
Add Comment
Please, Sign In to add comment