Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. tid = 379
  2. thing = "none"
  3. rednet.open("right")
  4. other = true
  5. function s()
  6. sleep(.4)
  7. end
  8. while true do
  9. if other == true then
  10. term.clear()
  11. term.setCursorPos(1,1)
  12. print("Blood-Corp Turtle Systems")
  13. print("Please enter control type (command or key) : ")
  14. local test = read()
  15. if test == "command" then
  16. thing = "command"
  17. elseif test == "key" then
  18. thing = "key"
  19. end
  20. end
  21. if thing == "command" then
  22. command = true
  23. while command == true do
  24. term.clear()
  25. term.setCursorPos(1,1)
  26. print("Blood-Corp Turtle Systems")
  27. print("Commands : up,down,left,right,forward,back,exit.")
  28. term.setCursorPos(1,3)
  29. write("Enter Command : ")
  30. local command = read()
  31. if command == "forward" then
  32. rednet.send(tid, "forward")
  33. print("Sent Forward")
  34. s()
  35. elseif command == "left" then
  36. rednet.send(tid, "right")
  37. print("Sent Left")
  38. s()
  39. elseif command == "right" then
  40. rednet.send(tid, "left")
  41. print("Sent Right")
  42. s()
  43. elseif command == "back" then
  44. rednet.send(tid, "back")
  45. print("Sent Back")
  46. s()
  47. elseif command == "up" then
  48. rednet.send(tid, "up")
  49. print("Sent Up")
  50. s()
  51. elseif command == "down" then
  52. rednet.send(tid, "down")
  53. print("Sent Down")
  54. s()
  55. elseif command == "exit" then
  56. command = false
  57. other = true
  58. s()
  59. else
  60. print("Unknown Command.")
  61. print("Usage: up,down,left,right,forward,back,exit.")
  62. sleep(1)
  63. end
  64. end
  65. elseif thing == "key" then
  66. term.clear()
  67. term.setCursorPos(1,1)
  68. print("Blood-Corp Turtle Systems")
  69. print("Keys : ](up), [(down), a(right), d(left).\nKeys : w(forward), s(back), z(exit).")
  70. key = true
  71. while key == true do
  72. local evt, c = os.pullEvent("char")
  73. c = string.lower(c)
  74. if c == "w" then
  75. rednet.send(tid, "forward")
  76. print("Sent Forward")
  77. elseif c == "d" then
  78. rednet.send(tid, "right")
  79. print("Sent Left")
  80. elseif c == "a" then
  81. rednet.send(tid, "left")
  82. print("Sent Right")
  83. elseif c == "s" then
  84. rednet.send(tid, "back")
  85. print("Sent Back")
  86. elseif c == "]" then
  87. rednet.send(tid, "up")
  88. print("Sent Up")
  89. elseif c == "[" then
  90. rednet.send(tid, "down")
  91. print("Sent Down")
  92. elseif c == "z" then
  93. key = false
  94. other = true
  95. s()
  96. else
  97. print("Unknown Key.")
  98. print("Usage : ](up), [(down), a(right), d(left).\nUsage : w(forward), s(back), z(exit).")
  99. sleep(1)
  100. end
  101. end
  102. end
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement