oblinger

RCT Terminal/PC v2.1

Mar 28th, 2014
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. --RCT Terminal
  2.  
  3. rednet.open("back")
  4. term.clear()
  5. term.setCursorPos(1,1)
  6. print("RCT v1.6")
  7. print("Turtle ID: ")
  8. select = 1
  9.  
  10. term.setCursorPos(12,2)
  11. id = read()
  12. id = tonumber(id)
  13.  
  14. --Code
  15.  
  16. function findTurtle()
  17. term.setCursorPos(1,2)
  18. term.clearLine()
  19. print("Searching...")
  20. rednet.send(id,"on")
  21. sid,msg,dis = rednet.receive(5)
  22.  
  23. if msg == nill then
  24. term.setCursorPos(1,2)
  25. print("Turtle #"..id.." Is Not Online")
  26. elseif msg == "on" then
  27. term.setCursorPos(1,2)
  28. print("Connected To Turtle #"..id)
  29. elseif msg == "atk" then
  30. a = 1
  31. term.setCursorPos(1,2)
  32. print("Connected To Turtle #"..id)
  33.  
  34. end
  35. end
  36.  
  37. function printGui()
  38. term.setCursorPos(1,5)
  39. print("Controls:")
  40. print("W/Forward")
  41. print("A/Left")
  42. print("D/Right")
  43. print("S/Back")
  44. print()
  45. print("Space/Up")
  46. print("LShift/Down")
  47. if msg == "on" then
  48. print("F/Attack")
  49. print("G/Dig")
  50. print("Q/Dig Direction:")
  51. print()
  52. print("Press X To Reboot Turtle")
  53. print("Press T To Quit And Disconnect")
  54. elseif msg == "atk" then
  55. print("F/Attack")
  56. print("Q/Toggle Attack Direction: Off")
  57. print()
  58. print("Press T To Quit And Disconnect")
  59. end
  60. end
  61.  
  62. function sendKey()
  63. event,key = os.pullEvent("key")
  64. if key == 17 then
  65. rednet.send(id,"w")
  66. elseif key == 30 then
  67. rednet.send(id,"a")
  68. elseif key == 31 then
  69. rednet.send(id,"s")
  70. elseif key == 32 then
  71. rednet.send(id,"d")
  72. elseif key == 42 then
  73. rednet.send(id,"lsft")
  74. elseif key == 57 then
  75. rednet.send(id,"spc")
  76. elseif key == 33 and select == 2 then
  77. rednet.send(id,"au")
  78. elseif key == 33 and select == 3 then
  79. rednet.send(id,"ad")
  80. elseif key == 33 then
  81. rednet.send(id,"f")
  82. elseif key == 34 and select == 2 then
  83. rednet.send(id,"du")
  84. elseif key == 34 and select == 3 then
  85. rednet.send(id,"dd")
  86. elseif key == 34 then
  87. rednet.send(id,"g")
  88. elseif key == 16 then
  89. if select < 3 then
  90. select = select + 1
  91. elseif select == 3 then
  92. select = 1
  93. end
  94. elseif key == 18 then
  95. if select > 1 then
  96. select = select - 1
  97. elseif select == 1 then
  98. select = 3
  99. end
  100. elseif key == 34 then
  101. rednet.send(id,"du")
  102. elseif key == 20 then
  103. rednet.send(id,"dsc")
  104. term.clear()
  105. term.setCursorPos(1,1)
  106. rednet.close("back")
  107. error()
  108. elseif keys.getName(key) == "x" then
  109. rednet.send(id,"sht")
  110. rednet.close("back")
  111. term.clear()
  112. term.setCursorPos(1,1)
  113. error()
  114. end
  115. term.setCursorPos(17,15)
  116. term.write(" ")
  117. term.setCursorPos(17,15)
  118. if select == 1 then
  119. print("Off")
  120. elseif select == 2 then
  121. print("Up")
  122. elseif select == 3 then
  123. print("Down")
  124. end
  125. end
  126.  
  127.  
  128.  
  129.  
  130. findTurtle()
  131. if msg == "on" then
  132. printGui()
  133. while true do
  134. sendKey()
  135. end
  136. end
Advertisement
Add Comment
Please, Sign In to add comment