Advertisement
loccode

ipad

Feb 10th, 2021
1,088
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.62 KB | None | 0 0
  1. function init()
  2.  
  3. rednet.open("back")
  4.  
  5. if (rednet.isOpen(modemSide)) then
  6.  
  7. print("[OK] Wi-fi activated")
  8.  
  9. showCommands()
  10.  
  11. else
  12.  
  13. print("Wi-fi activation error. Maybe wrong side?")
  14.  
  15. return false
  16. end
  17.  
  18. end
  19.  
  20.  
  21. function showCommands()
  22.  
  23. print("\n~~~~\nVvedite komandu dlya cherepaxi:\n1. Online\n2. GPS\n~~~~\n")
  24. local command = read()
  25.  
  26. if (command == "Online") then
  27.  
  28. checkTurtleOnline()
  29.  
  30. elseif( command == "GPS" ) then
  31.  
  32. sendGPStoTurtle()
  33.  
  34. else
  35.  
  36. end
  37.  
  38. end
  39.  
  40.  
  41. function checkTurtleOnline()
  42.  
  43. rednet.broadcast("Who is online?", "loader-1")
  44.  
  45. local senderId, message, protocol = rednet.receive()
  46. print(tostring(senderId), " is online.")
  47.  
  48. showCommands()
  49.  
  50. end
  51.  
  52. function sendGPSCommand(message)
  53.  
  54. print(message)
  55.  
  56. local command = read()
  57.  
  58. rednet.broadcast(command, "loader-1")
  59.  
  60.  
  61. end
  62.  
  63.  
  64. function sendGPStoTurtle()
  65.  
  66. rednet.broadcast("Move to the point by XYZ", "loader-1")
  67.  
  68. local senderId, message, protocol = rednet.receive()
  69.  
  70.  
  71. if (message == "Vvedite X") then
  72.  
  73. sendGPSCommand(message)
  74.  
  75. end
  76.  
  77. senderId, message, protocol = rednet.receive()
  78.  
  79.  
  80. if (message == "Vvedite Y") then
  81.  
  82. sendGPSCommand(message)
  83.  
  84. end
  85.  
  86. senderId, message, protocol = rednet.receive()
  87.  
  88.  
  89. if (message == "Vvedite Z") then
  90.  
  91. sendGPSCommand(message)
  92.  
  93. end
  94.  
  95.  
  96. senderId, message, protocol = rednet.receive()
  97.  
  98. if (message == "Ne rabotaet GPS. Proverte vashi GPS vishki.") then
  99.  
  100. print("Izvinite, cherepaxa naxoditsa vne radiusa vishek ili vishki viklucheni.")
  101. showCommands()
  102.  
  103. end
  104.  
  105. if (message == "Ya na meste naznacheniya") then
  106. sendGPSCommand(message)
  107. showCommands()
  108. end
  109.  
  110.  
  111.  
  112.  
  113. end
  114.  
  115.  
  116. return { init = init }
  117.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement