edoreld

Untitled

Mar 9th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. -- Vars
  2.  
  3. local north = colors.yellow
  4. local east = colors.lime
  5. local south = colors.pink
  6. local west = colors.gray
  7. local up = colors.purple
  8. local down = colors.blue
  9.  
  10.  
  11. -- Misc Functions
  12.  
  13. function clearScreen()
  14. term.clear()
  15. term.setCursorPos(1,1)
  16. end
  17.  
  18. function wait(num,what)
  19. for i=1,num do
  20. clearScreen()
  21. print("Waiting for "..what)
  22. print("Time remaining: "..num-i)
  23. os.sleep(1)
  24. end
  25. end
  26.  
  27. -- Setting & Getting functions
  28.  
  29. function getDrills()
  30. clearScreen()
  31. for i=1,8 do
  32. print("Retrieving drill #"..i)
  33. redstone.setBundledOutput("left",colors.lightBlue)
  34. os.sleep(0.5)
  35. redstone.setBundledOutput("left",0)
  36. os.sleep(0.5)
  37. end
  38. end
  39.  
  40. function setDrills()
  41. clearScreen()
  42. for i=1,8 do
  43. print ("Deploying drill #"..i)
  44. redstone.setBundledOutput("left",colors.magenta)
  45. os.sleep(0.5)
  46. redstone.setBundledOutput("left",0)
  47. os.sleep(0.5)
  48. end
  49. end
  50.  
  51. function cleanUpCells()
  52. clearScreen()
  53. for i=1,8 do
  54. print("Retrieving cell #"..i)
  55. redstone.setBundledOutput("left",colors.brown)
  56. os.sleep(0.5)
  57. redstone.setBundledOutput("left",0)
  58. os.sleep(0.5)
  59. end
  60. end
  61.  
  62. function setCells()
  63. clearScreen()
  64. for i=1,8 do
  65. print("Deploying cell stack #"..i)
  66. redstone.setBundledOutput("left",colors.white)
  67. os.sleep(0.5)
  68. redstone.setBundledOutput("left",0)
  69. os.sleep(0.5)
  70. end
  71. end
  72.  
  73. function coverHoles()
  74. clearScreen()
  75. for i=1,64 do
  76. print("Deploying sand #"..i)
  77. redstone.setBundledOutput("left",colors.orange)
  78. os.sleep(1)
  79. redstone.setBundledOutput("left",0)
  80. os.sleep(1)
  81. end
  82. end
  83.  
  84. function mainMiningProgram()
  85. clearScreen()
  86. setDrills()
  87. clearScreen()
  88. wait(30,"drills")
  89. for i=1,1536 do
  90. clearScreen()
  91. print("Mining...")
  92. print("Time remaining: "..1536-i)
  93. if (i % 256 == 0) and (i ~= 0) then
  94. setCells()
  95. end
  96. os.sleep(1)
  97. end
  98. getDrills()
  99. wait(45,"drills")
  100. cleanUpCells()
  101. coverHoles()
  102. end
  103.  
  104. function moveTo(dir,num)
  105. for i=1,num do
  106. redstone.setBundledOutput("left",dir)
  107. os.sleep(1.5)
  108. redstone.setBundledOutput("left",0)
  109. os.sleep(0.5)
  110. end
  111. end
  112.  
  113. while true do
  114. redstone.setBundledOutput("left",0)
  115. clearScreen()
  116. print("Frameship Terminal 0.2")
  117. print("==============================")
  118. print("1. Main mining program.")
  119. print("==============================")
  120. print("2. Retrieve Drills from Miners")
  121. print("3. Insert Drills into miners")
  122. print("4. Clean Up Cells")
  123. print("5: Insert cells into pumps")
  124. print("6. Cover holes")
  125. print("==============================")
  126. print("7. Initialize navigation protocols")
  127. print("0. Exit")
  128. write("Command> ")
  129. local choice = read()
  130.  
  131. if (choice == '1') then
  132. mainMiningProgram()
  133. elseif (choice == '2') then
  134. getDrills()
  135. elseif (choice == '3') then
  136. setDrills()
  137. elseif (choice == '4') then
  138. cleanUpCells()
  139. elseif (choice == '5') then
  140. setCells()
  141. elseif (choice == '6') then
  142. coverHoles()
  143. elseif (choice == '7') then
  144. while true do
  145. clearScreen()
  146. print("Navigation Subsystem")
  147. print("==============================")
  148. print ("1. Move North")
  149. print ("2. Move East")
  150. print ("3. Move South")
  151. print ("4. Move West")
  152. print ("5. Move Up")
  153. print ("6. Move Down")
  154. print ("0. Return to previous menu")
  155. write("Command> ")
  156. local choice = read()
  157.  
  158. if (choice ~= '0') then
  159. print("How many blocks in that direction?")
  160. write("Command> ")
  161. local numToMove = read()
  162.  
  163. if (choice == '1') then
  164. moveTo(north, numToMove)
  165. elseif (choice == '2') then
  166. moveTo(east, numToMove)
  167. elseif (choice == '3') then
  168. moveTo(south, numToMove)
  169. elseif (choice == '4') then
  170. moveTo(west, numToMove)
  171. elseif (choice == '5') then
  172. moveTo(up, numToMove)
  173. elseif (choice =='6') then
  174. moveTo(down, numToMove)
  175. end
  176. end
  177.  
  178. if (choice == '0') then
  179. break
  180. end
  181. end
  182. elseif (choice == '0') then
  183. clearScreen()
  184. break
  185. end
  186. end
Advertisement
Add Comment
Please, Sign In to add comment