Advertisement
rickydaan

[LUA]Turtle sender

Feb 26th, 2012
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.99 KB | None | 0 0
  1. local modemside = "right" -- Side the modem is
  2. local send = 1 -- Sending to ID
  3. rednet.open(modemside)
  4. function forward()
  5. term.setCursorPos(12,10)
  6. print("^")
  7. end
  8. function back()
  9. term.setCursorPos(12,10)
  10. print("V")
  11. end
  12. function left()
  13. term.setCursorPos(12,10)
  14. print("<")
  15. end
  16. function right()
  17. term.setCursorPos(12,10)
  18. print(">")
  19. end
  20. function error(code)
  21. term.setCursorPos(8,11)
  22. print(code)
  23. end
  24. term.clear()
  25. term.setCursorPos(1,1)
  26. print("LINUX TURTLE API")
  27. print("Arrow keys to move this")
  28. print("[ = Break block up, ] build block up")
  29. print("t = build block down")
  30. print("W, A, S, D = Move")
  31. print("O = turn right, P = turn left")
  32. print("L = place block, K = break block")
  33. print("1 - 9 (Numpad too) Select block")
  34. print("Q = dig down")
  35. print("E = Dig down + move donw")
  36. print("+ / - = up / down")
  37. print("BACKSPACE = Drop items")
  38. print("~ = Change status to mining status*")
  39. print("TAB to stop, Lshift to restart the turtle")
  40. print("* = Cant be undone! Need reset by player")
  41. print("")
  42. print("Direction: ")
  43. print("Error:")
  44. stop = false
  45. while not stop do
  46. event, char = os.pullEvent()
  47. if turtle then
  48. if event == "key" and char == 200 then
  49. turtle.forward()
  50. end
  51. if event == "key" and char == 203 then
  52. turtle.turnLeft()
  53. turtle.forward()
  54. turtle.turnRight()
  55. end
  56. if event == "key" and char == 208 then
  57. turtle.back()
  58. end
  59. if event == "key" and char == 205 then
  60. turtle.turnRight()
  61. turtle.forward()
  62. turtle.turnLeft()
  63. end
  64. if event == "key" and char == 201 then
  65. turtle.up()
  66. end
  67. if event == "key" and char == 209 then
  68. turtle.down()
  69. end
  70. end
  71. if event == "key" and char == 14 then
  72. rednet.send(send, "drop")
  73. end
  74. if event == "key" and char == 41 then
  75. rednet.send(send, "mine")
  76. end
  77. if event == "key" and char == 42 then
  78. rednet.send(send, "restart")
  79. end
  80. if event == "key" and char == 27 then
  81. rednet.send(send, "buildup")
  82. end
  83. if event == "key" and char == 20 then
  84. rednet.send(send, "builddown")
  85. end
  86. if event == "key" and char == 26 then
  87. rednet.send(send, "breakblockup")
  88. end
  89. if event == "key" and char == 37 then
  90. rednet.send(send, "dig")
  91. end
  92. if event == "key" and char == 25 then
  93. rednet.send(send, "turnleft")
  94. end
  95. if event == "key" and char == 24 then
  96. rednet.send(send, "turnright")
  97. end
  98. if event == "key" and char == 38 then
  99. rednet.send(send, "place")
  100. end
  101. if event == "key" and char == 2 or event == "key" and char == 199 then
  102. rednet.send(send, "1")
  103. end
  104. if event == "key" and char == 3 or event == "key" and char == 200 then
  105. rednet.send(send, "2")
  106. end
  107. if event == "key" and char == 4 or event == "key" and char == 201 then
  108. rednet.send(send, "3")
  109. end
  110. if event == "key" and char == 5 or event == "key" and char == 203 then
  111. rednet.send(send, "4")
  112. end
  113. if event == "key" and char == 6 or event == "key" and char == 0 then
  114. rednet.send(send, "5")
  115. end
  116. if event == "key" and char == 7 or event == "key" and char == 205 then
  117. rednet.send(send, "6")
  118. end
  119. if event == "key" and char == 8 or event == "key" and char == 207 then
  120. rednet.send(send, "7")
  121. end
  122. if event == "key" and char == 9 or event == "key" and char == 208 then
  123. rednet.send(send, "8")
  124. end
  125. if event == "key" and char == 10 or event == "key" and char == 209 then
  126. rednet.send(send, "9")
  127. end
  128.  
  129. if event == "key" and char == 18 then
  130. rednet.send(send, "digdowndown")
  131. end
  132.  
  133. if event == "key" and char == 16 then
  134. rednet.send(send, "digdown")
  135. end
  136.  
  137. if event == "key" and char == 54 and char == 13 or event == "key" and char == 13 then
  138. rednet.send(send, "up")
  139. end
  140.  
  141. if event == "key" and char == 54 and char == 12 or event == "key" and char == 12 then
  142. rednet.send(send, "down")
  143. end
  144.  
  145. if event == "key" and char == 17 then
  146. rednet.send(send, "forward")
  147. end
  148.  
  149. if event == "key" and char == 30 then
  150. rednet.send(send, "left")
  151. end
  152.  
  153. if event == "key" and char == 31 then
  154. rednet.send(send, "back")
  155. end
  156.  
  157. if event == "key" and char == 32 then
  158. rednet.send(send, "right")
  159. end
  160.  
  161. if event == "key" and char == 15 then
  162. term.clear()
  163. term.setCursorPos(1,1)
  164. print("Thanks for using Linux Wireless Moving API")
  165. stop = true
  166. end
  167. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement