Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. local component = require("component")
  2. local event = require("event")
  3. local port = 512
  4. local modem
  5.  
  6. local commands ={
  7. [17] = {messageToRobot = "forward",
  8. text = "Forward"},
  9. [31] = {messageToRobot = "back",
  10. text = "Forward"},
  11. [30] = {messageToRobot = "turnLeft",
  12. text = "Forward"},
  13. [32] = {messageToRobot = "tureRight",
  14. text = "Forward"},
  15. [57] = {messageToRobot = "up",
  16. text = "Forward"},
  17. [42] = {messageToRobot = "down",
  18. text = "Forward"},
  19. [18] = {messageToRobot = "use",
  20. text = "Forward"},
  21. [19] = {messageToRobot = "redstone",
  22. text = "Forward"}
  23. }
  24.  
  25. function init()
  26. if component.isAvailable("modem") then
  27. modem = component.modem
  28. modem.open(port)
  29. else
  30. print("wtf")
  31. return false
  32. end
  33. end
  34.  
  35. function lets()
  36. while true do
  37. if modem.broadcast(port,commands[event.pull()].messageToRobot) then
  38. print(commands[event.pull()].text)
  39. else
  40. print("error")
  41. end
  42. end
  43. end
  44.  
  45. if init() then
  46. print("WASD, E: use, R: redstone, SHIFT: down, SPACE: up")
  47. lets()
  48. else
  49. print("bb")
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement