Kasama

TurtlePad

Jun 17th, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.14 KB | None | 0 0
  1. --------------------------------------------------------------------------------------------------
  2. -- ___ ___ __ ____________ __ ___ ___ __ --
  3. -- |:| /:/ /::\ |::::::::::| /::\ |::\ /::| /::\ --
  4. -- |:| /:/ /::::\ |::/¨¨¨¨¨¨¨¨ /::::\ |:::\ /:::| /::::\ --
  5. -- |:| /:/ /::/\::\ |::| /::/\::\ |::::\/::::| /::/\::\ --
  6. -- |:|/:/ /::/__\::\ |::\________ /::/__\::\ |::|\::/|::| /::/__\::\ --
  7. -- |:|\:\ /::/::::\::\ |::::::::::| /::/::::\::\ |::| \/ |::| /::/::::\::\ --
  8. -- |:| \:\ /::/¨¨¨¨¨¨\::\ ¨¨¨¨¨¨¨¨\::| /::/¨¨¨¨¨¨\::\ |::| |::| /::/¨¨¨¨¨¨\::\ --
  9. -- |:| \:\ /::/ \::\ /::| /::/ \::\ |::| |::| /::/ \::\ --
  10. -- |:| \:\ /::/ \::\ |::::::::::| /::/ \::\ |::| |::| /::/ \::\ --
  11. -- ¨¨¨ ¨¨¨ ¨¨¨ ¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨ ¨¨¨ ¨¨¨¨ ¨¨¨¨ ¨¨¨ ¨¨¨ --
  12. ----------------------------------------------------------------------------------------Scripts---
  13. -- joypad turtle
  14. local forward = 200 --/\
  15. local back = 208 -- \/
  16. local left = 203 -- <
  17. local right = 205 -- >
  18. local up = 57 -- Space
  19. local down = 42 -- Left Shift
  20. local dig = 36 -- J
  21. local digUp = 22 -- U
  22. local digDown = 49 -- N
  23. local place = 37 -- K
  24. local placeUp = 23 -- I
  25. local placeDown = 50 -- M
  26. local refuel = 19 -- R
  27. local select = 31 -- S
  28. local swap = 17 -- W
  29. local esc = 1 -- Esc
  30. local current = 1 -- Keep track of the selected slot
  31.  
  32.  
  33. turtle.select(1)
  34. --lots of ifs
  35. while true do
  36.  
  37. event, scancode = os.pullEvent("key")
  38. if scancode == forward then
  39. x = turtle.forward()
  40. if x then
  41. print "Moved Forward"
  42. else
  43. print "Couldn't Move"
  44. if turtle.getFuelLevel() == 0 then
  45. print "Out of Fuel"
  46. end
  47. end
  48. elseif scancode == back then
  49. x = turtle.back()
  50. if x then
  51. print "Moved Backward"
  52. else
  53. print "Couldn't Move"
  54. if turtle.getFuelLevel() == 0 then
  55. print "Out of Fuel"
  56. end
  57. end
  58. elseif scancode == up then
  59. x = turtle.up()
  60. if x then
  61. print "Moved Upward"
  62. else
  63. print "Couldn't Move"
  64. if turtle.getFuelLevel() == 0 then
  65. print "Out of Fuel"
  66. end
  67. end
  68. elseif scancode == down then
  69. x = turtle.down()
  70. if x then
  71. print "Moved Downward"
  72. else
  73. print "Couldn't Move"
  74. if turtle.getFuelLevel() == 0 then
  75. print "Out of Fuel"
  76. end
  77. end
  78. elseif scancode == left then
  79. x = turtle.turnLeft()
  80. if x then
  81. print "Turned Left"
  82. else
  83. print "Couldn't Turn"
  84. if turtle.getFuelLevel() == 0 then
  85. print "Out of Fuel"
  86. end
  87. end
  88. elseif scancode == right then
  89. x = turtle.turnRight()
  90. if x then
  91. print "Turned Right"
  92. else
  93. print "Couldn't Turn"
  94. if turtle.getFuelLevel() == 0 then
  95. print "Out of Fuel"
  96. end
  97. end
  98. elseif scancode == dig then
  99. x = turtle.dig()
  100. if x then
  101. print "Dug"
  102. else
  103. print "Couldn't Dig"
  104. if turtle.getFuelLevel() == 0 then
  105. print "Out of Fuel"
  106. end
  107. end
  108. elseif scancode == digUp then
  109. x = turtle.digUp()
  110. if x then
  111. print "Dug"
  112. else
  113. print "Couldn't Dig"
  114. if turtle.getFuelLevel() == 0 then
  115. print "Out of Fuel"
  116. end
  117. end
  118. elseif scancode == digDown then
  119. x = turtle.digDown()
  120. if x then
  121. print "Dug"
  122. else
  123. print "Couldn't Dig"
  124. if turtle.getFuelLevel() == 0 then
  125. print "Out of Fuel"
  126. end
  127. end
  128. elseif scancode == place then
  129. x = turtle.place()
  130. if x then
  131. print "Placed"
  132. else
  133. print "Couldn't Place"
  134. if turtle.getFuelLevel() == 0 then
  135. print "Out of Fuel"
  136. end
  137. end
  138. elseif scancode == placeDown then
  139. x = turtle.placeDown()
  140. if x then
  141. print "Placed"
  142. else
  143. print "Couldn't Place"
  144. if turtle.getFuelLevel() == 0 then
  145. print "Out of Fuel"
  146. end
  147. end
  148. elseif scancode == placeUp then
  149. x = turtle.placeUp()
  150. if x then
  151. print "Placed"
  152. else
  153. print "Couldn't Place"
  154. if turtle.getFuelLevel() == 0 then
  155. print "Out of Fuel"
  156. end
  157. end
  158. elseif scancode == refuel then
  159. x = turtle.refuel()
  160. if x then
  161. print "Refilled"
  162. else
  163. print "Couldn't Refuel"
  164. end
  165. print ("Current fuel at "..tostring(turtle.getFuelLevel()))
  166. elseif scancode == select then
  167. print "Number of the slot:"
  168. x = read()
  169. x = string.sub(x,2)
  170. x = tonumber(x)
  171. if tonumber(x)>16 then
  172. print "Invalid slot"
  173. else
  174. turtle.select(x)
  175. current = tonumber(x)
  176. current = tonumber(current)
  177. end
  178. elseif scancode == swap then
  179. print "Number of the slot to swap to:"
  180. x = read()
  181. x = string.sub(x,2)
  182. x = tonumber(x)
  183. print "Quantity of the item to swap:"
  184. y = read()
  185. y = string.sub(y,1)
  186. y = tonumber(y)
  187. if tonumber(x)>16 then
  188. print "Invalid Slot"
  189. else
  190. if y>turtle.getItemCount(tonumber(current)) then
  191. y = turtle.getItemCount(tonumber(current))
  192. end
  193. turtle.transferTo(x,y)
  194. end
  195. elseif scancode == esc then
  196. term.clear()
  197. term.setCursorPos(1,1)
  198. print "Thanks, Exiting program"
  199. break
  200. end
  201. end
Advertisement
Add Comment
Please, Sign In to add comment