edoreld

Untitled

Mar 8th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.68 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. wait(45,"cells")
  100. getCells()
  101. getDrills()
  102. os.sleep(100)
  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: Insert cells into pumps")
  125. print("5. Cover holes")
  126. print("==============================")
  127. print("6. Initialize navigation protocols")
  128. print("0. Exit")
  129. write("Command> ")
  130. local choice = read()
  131.  
  132. if (choice == '1') then
  133. mainMiningProgram()
  134. elseif (choice == '2') then
  135. getDrills()
  136. elseif (choice == '3') then
  137. setDrills()
  138. elseif (choice == '4') then
  139. setCells()
  140. elseif (choice == '5') then
  141. coverHoles()
  142. elseif (choice == '6') 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