edoreld

Untitled

Mar 9th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.74 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. coverHoles()
  101. end
  102.  
  103. function moveTo(dir,num)
  104. for i=1,num do
  105. redstone.setBundledOutput("left",dir)
  106. os.sleep(1.5)
  107. redstone.setBundledOutput("left",0)
  108. os.sleep(0.5)
  109. end
  110. end
  111.  
  112. while true do
  113. redstone.setBundledOutput("left",0)
  114. clearScreen()
  115. print("Frameship Terminal 0.2")
  116. print("==============================")
  117. print("1. Main mining program.")
  118. print("==============================")
  119. print("2. Retrieve Drills from Miners")
  120. print("3. Insert Drills into miners")
  121. print("4. Clean Up Cells")
  122. print("5: Insert cells into pumps")
  123. print("6. Cover holes")
  124. print("==============================")
  125. print("7. Initialize navigation protocols")
  126. print("0. Exit")
  127. write("Command> ")
  128. local choice = read()
  129.  
  130. if (choice == '1') then
  131. mainMiningProgram()
  132. elseif (choice == '2') then
  133. getDrills()
  134. elseif (choice == '3') then
  135. setDrills()
  136. elseif (choice == '4') then
  137. cleanUpCells()
  138. elseif (choice == '5') then
  139. setCells()
  140. elseif (choice == '6') then
  141. coverHoles()
  142. elseif (choice == '7') then
  143. while true do
  144. clearScreen()
  145. print("Navigation Subsystem")
  146. print("==============================")
  147. print ("1. Move North")
  148. print ("2. Move East")
  149. print ("3. Move South")
  150. print ("4. Move West")
  151. print ("5. Move Up")
  152. print ("6. Move Down")
  153. print ("0. Return to previous menu")
  154. write("Command> ")
  155. local choice = read()
  156.  
  157. if (choice ~= '0') then
  158. print("How many blocks in that direction?")
  159. write("Command> ")
  160. local numToMove = read()
  161.  
  162. if (choice == '1') then
  163. moveTo(north, numToMove)
  164. elseif (choice == '2') then
  165. moveTo(east, numToMove)
  166. elseif (choice == '3') then
  167. moveTo(south, numToMove)
  168. elseif (choice == '4') then
  169. moveTo(west, numToMove)
  170. elseif (choice == '5') then
  171. moveTo(up, numToMove)
  172. elseif (choice =='6') then
  173. moveTo(down, numToMove)
  174. end
  175. end
  176.  
  177. if (choice == '0') then
  178. break
  179. end
  180. end
  181. elseif (choice == '0') then
  182. clearScreen()
  183. break
  184. end
  185. end
Advertisement
Add Comment
Please, Sign In to add comment