edoreld

frameminer

Mar 7th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.92 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. for i=1,waitTime do
  96. clearScreen()
  97. print("Waiting for cells...")
  98. print("Time remaining: "..waitTime-i)
  99. os.sleep(1)
  100. end
  101. end
  102. getDrills()
  103. os.sleep(100)
  104. coverHoles()
  105. end
  106.  
  107. function moveTo(dir,num)
  108. for i=1,num do
  109. redstone.setBundledOutput("left",dir)
  110. os.sleep(1.5)
  111. redstone.setBundledOutput("left",0)
  112. os.sleep(0.5)
  113. end
  114. end
  115.  
  116. while true do
  117. redstone.setBundledOutput("left",0)
  118. clearScreen()
  119. print("Frameship Terminal 0.2")
  120. print("==============================")
  121. print("1. Main mining program.")
  122. print("==============================")
  123. print("2. Retrieve Drills from Miners")
  124. print("3. Insert Drills into miners")
  125. print("4: Insert cells into pumps")
  126. print("5. Cover holes")
  127. print("==============================")
  128. print("6. 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. setCells()
  141. elseif (choice == '5') then
  142. coverHoles()
  143. elseif (choice == '6') 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