Advertisement
Mackan90096

turtlecontroller2

Mar 6th, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. -- Settings --
  2. bgcolor = 16384 -- Backgroundcolor Default = 16384 (red)
  3. textcolor = 32768 -- Textcolor Default = 32768 (Black)
  4. mside = "top" -- Side of modem.
  5. turtleid = 89 -- Id of your controlled turtle
  6. version = "[1.1]"
  7. sleep = 3
  8. -- End of settings --
  9.  
  10. rednet.open(mside)
  11.  
  12. function selectinventory()
  13. term.clear()
  14. term.setCursorPos(1,1)
  15. write("Please input a number from 1-16 (Input 17 to go back): ")
  16. local input = read()
  17. if input == "1" then
  18. rednet.send(turtleid, "1")
  19. elseif input == "2" then
  20. rednet.send(turtleid, "2")
  21. elseif input == "3" then
  22. rednet.send(turtleid, "3")
  23. elseif input == "4" then
  24. rednet.send(turtleid, "4")
  25. elseif input == "5" then
  26. rednet.send(turtleid, "5")
  27. elseif input == "6" then
  28. rednet.send(turtleid, "6")
  29. elseif input == "7" then
  30. rednet.send(turtleid, "7")
  31. elseif input == "8" then
  32. rednet.send(turtleid, "8")
  33. elseif input == "9" then
  34. rednet.send(turtleid, "9")
  35. elseif input == "10" then
  36. rednet.send(turtleid, "10")
  37. elseif input == "11" then
  38. rednet.send(turtleid, "11")
  39. elseif input == "12" then
  40. rednet.send(turtleid, "12")
  41. elseif input == "13" then
  42. rednet.send(turtleid, "13")
  43. elseif input == "14" then
  44. rednet.send(turtleid, "14")
  45. elseif input == "15" then
  46. rednet.send(turtleid, "15")
  47. elseif input == "16" then
  48. rednet.send(turtleid, "16")
  49. elseif input == "17" then
  50. start2()
  51. end
  52. end
  53.  
  54.  
  55. function o()
  56. os.reboot()
  57. end
  58.  
  59. function start()
  60. term.clear()
  61. term.setTextColor(textcolor)
  62. term.setBackgroundColor(bgcolor)
  63. term.setCursorPos(1,1)
  64. term.setBackgroundColor(bgcolor)
  65. print("Running Mackan90096's Turtle Controlling program version (version)")
  66. term.clear()
  67. term.setCursorPos(5,5)
  68. print("[1] Start")
  69. term.setCursorPos(5,6)
  70. print("[2] Whats new in this version")
  71. term.setCursorPos(5,7)
  72. print("[3] Exit the program")
  73. local input = read()
  74. if input == "1" then
  75. start2()
  76. elseif input == "2" then
  77. whatsnew()
  78. elseif input == "3" then
  79. term.clear()
  80. end
  81. end
  82.  
  83. function whatsnew()
  84. term.clear()
  85. term.setCursorPos(1,1)
  86. print("Whats new:")
  87. term.setCursorPos(1,2)
  88. print("[Version 1.1]")
  89. term.setCursorPos(1,3)
  90. print("Added Whats New function")
  91. term.setCursorPos(1,4)
  92. print("Added block placement and suck functionallity")
  93. term.setCursorPos(1,5)
  94. print("Added refuelng function")
  95. term.setCursorPos(1,6)
  96. print("Added slot selection tool")
  97. term.setCursorPos(1,8)
  98. write("To exit type y and press enter: ")
  99. local input = read()
  100. if input == "y" then
  101. term.clear()
  102. end
  103. end
  104.  
  105. function movement()
  106. term.clear()
  107. sleep(1)
  108. term.setCursorPos(1,1)
  109. print("[1] Make turtle go forward")
  110. term.setCursorPos(1,2)
  111. print("[2] Make turtle go backwards")
  112. term.setCursorPos(1,3)
  113. print("[3] Make turtle turn left")
  114. term.setCursorPos(1,4)
  115. print("[4] Make turtle turn right")
  116. term.setCursorPos(1,5)
  117. print("[5] Make turtle go up")
  118. term.setCursorPos(1,6)
  119. print("[6] Make turtle go down")
  120. term.setCursorPos(1,7)
  121. print("[7] Make turtle dig")
  122. term.setCursorPos(1,8)
  123. print("[8] Place a block")
  124. ter.setCursorPos(1,9)
  125. print("[9] Exit")
  126. write("Input number please: ")
  127. local input = read()
  128. if input == "1" then
  129. rednet.send(turtleid, "forward")
  130. movement()
  131. elseif input == "2" then
  132. rednet.send(turtleid, "backwards")
  133. movement()
  134. elseif input == "3" then
  135. rednet.send(turtleid, "left")
  136. movement()
  137. elseif input == "4" then
  138. rednet.send(turtleid, "right")
  139. movement()
  140. elseif input == "5" then
  141. rednet.send(turtleid, "up")
  142. movement()
  143. elseif input == "6" then
  144. rednet.send(turtleid, "down")
  145. movement()
  146. elseif input == "7" then
  147. rednet.send(turtleid, "dig")
  148. movement()
  149. elseif input == "8" then
  150. rednet.send(turtleid, "place")
  151. movement()
  152. elseif input == "9" then
  153. term.clear()
  154. start2()
  155. end
  156. end
  157.  
  158. function start2()
  159. term.setCursorPos(1,1)
  160. print("[1] Movement")
  161. term.setCursorPos(1,2)
  162. print("[2] Fuel")
  163. term.setCursorPos(1,3)
  164. print("[3] Inventory seletion")
  165. term.setCursorPos(1,4)
  166. write("Input a number: ")
  167. local input = read()
  168. if input == "1" then
  169. term.clear()
  170. movement()
  171. elseif input == "2" then
  172. term.clear()
  173. fuel()
  174. elseif input == "3" then
  175. term.clear()
  176. selecinventory()
  177. end
  178. end
  179.  
  180. function fuel()
  181. term.clear()
  182. term.setCursorPos(1,1)
  183. print("[1] Refuel all")
  184. term.setCursorPos(1,2)
  185. print("[2] Get Fuel Level")
  186. term.setCursorPos(1,3)
  187. print("[3] Exit")
  188. term.setCursorPos(1,4)
  189. write("Please input a number: ")
  190. local input = read()
  191. if input == "1" then
  192. rednet.send(turtleid, "refuel")
  193. elseif input == "2" then
  194. rednet.send(turtleid, "fuellevel")
  195. while true do
  196. event, id, text = os.pullEvent()
  197. sleep(2)
  198. print(text)
  199. sleep(sleep)
  200. fuel()
  201. end
  202. elseif input == "3" then
  203. start2()
  204. end
  205. end
  206.  
  207. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement