edoreld

Untitled

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