edoreld

Untitled

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