Guest User

ComputerCraft CobbleGen

a guest
Sep 15th, 2012
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.99 KB | None | 0 0
  1. :COMPUTERCRAFT COBBLEGEN DISK CODE:
  2.  
  3.  
  4. :disk/startup:
  5. shell.run("clear")
  6. OS = string.sub(os.version(),1,1)
  7. print("CobbleGenInstaller for " .. os.version())
  8. print("Press enter to start program")
  9. read("")
  10. if OS == "C" then
  11. print("CraftOS detected")
  12. if fs.exists("turtleperc") then
  13. fs.delete("turtleperc")
  14. end
  15. if fs.exists("startup") then
  16. fs.delete("startup")
  17. end
  18. if fs.exists("help") then
  19. fs.delete("help")
  20. end
  21. if fs.exists("turtletotal") then
  22. fs.delete("turtletotal")
  23. end
  24. fs.copy("disk/craftos/total","turtletotal")
  25. fs.copy("disk/craftos/startup","startup")
  26. fs.copy("disk/craftos/perc","turtleperc")
  27. fs.copy("disk/craftos/help","help")
  28. print("Install complete. Remove disk and reboot.")
  29. print("Press enter to reboot")
  30. read("")
  31. os.reboot()
  32. end
  33. if OS == "T" then
  34. print("TurtleOS detected")
  35. if fs.exists("run") then
  36. fs.delete("run")
  37. end
  38. if fs.exists("startup") then
  39. fs.delete("startup")
  40. end
  41. if fs.exists("help") then
  42. fs.delete("help")
  43. end
  44. fs.copy("disk/turtleos/startup","startup")
  45. fs.copy("disk/turtleos/run","run")
  46. fs.copy("disk/turtleos/help","help")
  47. print("Install complete. Remove disk and press enter to reboot")
  48. read("")
  49. os.reboot()
  50. end
  51.  
  52.  
  53. :disk/turtleos/startup:
  54. shell.run("clear")
  55. print("TurtleOS: CobbleGen installed")
  56. print("Turtle ID: " .. os.computerID())
  57. if peripheral.getType("top") ~= "monitor" then
  58. print("Please attach a monitor above the turtle and press enter.")
  59. read("")
  60. os.reboot()
  61. end
  62. MonX, MonY = peripheral.call("top","getSize")
  63. if (MonX < 17) or (MonY < 11) then
  64. print("The recommended monitor size is 2x2 blocks")
  65. end
  66. if peripheral.getType("right") ~= "modem" then
  67. print("This software is only compatible with wireless mining turtles.")
  68. print("Shutting down in 10 seconds")
  69. sleep(10)
  70. os.shutdown()
  71. end
  72. print("")
  73. print("Programs available:")
  74. print("Run - Begin mining cobblestone from a generator.")
  75. print("Help - View information on setting up")
  76.  
  77.  
  78. :disk/turtleos/run/:
  79. SLOT = 1
  80. TOTAL = 1
  81. term.clear()
  82. term.setCursorPos(1,1)
  83. print("Enter Computer ID:")
  84. PC = tonumber(read())
  85. ID = os.computerID()
  86. rednet.open("right")
  87. top = peripheral.wrap("top")
  88. top.setTextScale(1)
  89. while true do
  90. while SLOT <= 9 do
  91. TOTAL = 0
  92. top.clear()
  93. top.setCursorPos(1,1)
  94. top.write("TURTLE " .. ID .. " STATUS:")
  95. for I = 1,9 do
  96. top.setCursorPos(1,(I + 1))
  97. top.write("Slot ")
  98. top.write(tostring(math.floor(I)))
  99. top.write(": ")
  100. if turtle.getItemCount(I) >= 64 then
  101. top.write("FULL")
  102. else
  103. top.write(tostring(math.floor(turtle.getItemCount(I))))
  104. end
  105. TOTAL = TOTAL + turtle.getItemCount(I)
  106. end
  107. top.setCursorPos(1,11)
  108. top.write("Total: ")
  109. top.write(tostring(math.floor(TOTAL)))
  110. rednet.send(PC,tostring(TOTAL))
  111. turtle.select(SLOT)
  112. if turtle.detect() then
  113. turtle.dig()
  114. end
  115. if turtle.getItemCount(SLOT) >= 64 then
  116. SLOT = SLOT + 1
  117. end
  118. end
  119. turtle.turnLeft()
  120. turtle.turnLeft()
  121. for O = 1,9 do
  122. turtle.select(O)
  123. turtle.drop()
  124. end
  125. turtle.turnRight()
  126. turtle.turnRight()
  127. SLOT = 1
  128. turtle.select(SLOT)
  129. end
  130.  
  131.  
  132. :disk/turtleos/help/:
  133. term.clear()
  134. term.setCursorPos(1,1)
  135. print("HELP:")
  136. print("Setup - Set up you turtle with the regenerating block in front, a 2x2 monitor above and a collection method behind. An easily accessible disk drive is a recommended option. This software only works with the Wireless Mining Turtle.")
  137. print("Rednet - Your turtle can link to a computer to share data, just install CobbleGen on the computer and enter the computer number when you run the turtle. If you wish the turtle to be standalone, just enter '0'.")
  138. print("Press enter to continue")
  139. read("")
  140. os.reboot()
  141.  
  142.  
  143. :disk/craftos/startup:
  144. shell.run("clear")
  145. print("CraftOS: CobbleGen TurtleBuddy Installed")
  146. print("Computer ID: " .. os.computerID())
  147. if peripheral.gettype("top") ~= "monitor" then
  148. print("Please attach a monitor above the computer and press enter.")
  149. read("")
  150. os.reboot()
  151. end
  152. if peripheral.getType("back") ~= "modem" then
  153. print("Please attach a modem behind the computer and press enter.")
  154. read("")
  155. os.reboot()
  156. end
  157. print("")
  158. print("Programs available:")
  159. print("TurtleTotal - Total blocks held by each turtle")
  160. print("TurtlePerc - % readings for each turtle")
  161. print("Help - View information on setting up")
  162.  
  163.  
  164. :disk/craftos/perc:
  165. perc = 0
  166. TURTLES = {}
  167. mon = peripheral.wrap("top")
  168. mon.clear()
  169. rednet.open("back")
  170. while true do
  171. print("Enter turtle IDs to add. Enter VIEW to see data")
  172. entry = read()
  173. if entry == "VIEW" then
  174. term.clear()
  175. break
  176. else
  177. TURTLES[(table.getn(TURTLES)) + 1] = tonumber(entry)
  178. term.clear()
  179. term.setCursorPos(1,1)
  180. term.write("Added: ")
  181. for O = 1,tablegetn(TURTLES) do
  182. term.write(TURTLES[O] .. ", ")
  183. end
  184. term.setCursorPos(1,2)
  185. end
  186. end
  187. term.setCursorPos(1,1)
  188. term.write("Viewing percentages for turtles ")
  189. for P = 1,table.getn(TURTLES) do
  190. term.write(TURTLES[P] .. ", ")
  191. end
  192. print("Hold Ctrl-T to terminate")
  193. while true do
  194. for I = 1,table.getn(TURTLES) do
  195. Q = 0
  196. repeat
  197. senderID, message, distance = rednet.receive(1)
  198. Q = Q + 1
  199. until (senderID == TURTLES [I]) or (Q == (5 * table.getn(TURTLES)))
  200. mon.setCursorPos(1,I)
  201. mon.clearLine()
  202. if Q == (5 * table.getn(TURTLES)) then
  203. mon.write("X")
  204. else
  205. perc = math.floor((math.floor(message) / 576) * 100)
  206. mon.write("Turtle " .. senderID .. ": " .. perc .. "%")
  207. end
  208. end
  209. end
  210.  
  211.  
  212. :disk/craftos/total:
  213. TURTLES = {}
  214. mon = peripheral.wrap("top")
  215. mon.clear()
  216. rednet.open("back")
  217. while true do
  218. print("Enter turtle IDs to add. Enter VIEW to see data")
  219. entry = read()
  220. if entry == "VIEW" then
  221. term.clear()
  222. break
  223. else
  224. TURTLES[(table.getn(TURTLES)) + 1] = tonumber(entry)
  225. term.clear()
  226. term.setCursorPos(1,1)
  227. term.write("Added: ")
  228. for O = 1,tablegetn(TURTLES) do
  229. term.write(TURTLES[O] .. ", ")
  230. end
  231. term.setCursorPos(1,2)
  232. end
  233. end
  234. term.setCursorPos(1,1)
  235. term.write("Viewing totals for turtles ")
  236. for P = 1,table.getn(TURTLES) do
  237. term.write(TURTLES[P] .. ", ")
  238. end
  239. print("Hold Ctrl-T to terminate")
  240. while true do
  241. for I = 1,table.getn(TURTLES) do
  242. Q = 0
  243. repeat
  244. senderID, message, distance = rednet.receive(1)
  245. Q = Q + 1
  246. until (senderID == TURTLES [I]) or (Q == (5 * table.getn(TURTLES)))
  247. mon.setCursorPos(1,I)
  248. mon.clearLine()
  249. if Q == (5 * table.getn(TURTLES)) then
  250. mon.write("X")
  251. else
  252. mon.write("Turtle " .. senderID .. ": " .. math.floor(message))
  253. end
  254. end
  255. end
  256.  
  257.  
  258. :disk/craftos/help:
  259. term.clear()
  260. term.setCursorPos(1,1)
  261. print("HELP:")
  262. print("After installing CobbleGen on CraftOS, you must use the same disk to install CobbleGen on TurtleOS. You may install it on as many different turtles as you like. When prompted after pressing 'Run' on the turtle menu, enter the ID of this computer (found on the menu) onto to turtle. It will then begin to mine cobblestone for you whilst relaying data back to this computer. To view the data choose an option and type in your turtle(s) ID.")
  263. print("Press enter to continue")
  264. read("")
  265. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment