Advertisement
Corbinhol

Communicator Debugger

Feb 4th, 2023 (edited)
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. --Debug Communicator
  2. rednet.open("back");
  3.  
  4. while true do
  5. shell.run("clear");
  6. print("==========================");
  7. io.write("Protocol: ");
  8. local protocol = io.read();
  9. local lookup;
  10. local address;
  11. if protocol ~= "" then
  12. io.write("Lookup Name: ");
  13. lookup = io.read();
  14. if lookup ~= "" then
  15. address = rednet.lookup(protocol, lookup);
  16. if address == nil then
  17. print("Error Finding Address through Lookup. Input it Manually, or skip to broadcast.")
  18. end
  19. end
  20. end
  21. if address == nil then
  22. io.write("Computer Address: ");
  23. address = io.read();
  24. end
  25. io.write("Message: ");
  26. local message = io.read();
  27. print("==========================")
  28. if message ~= "" then
  29. if protocol == "" then
  30. if address == "" then
  31. rednet.broadcast(message);
  32. else
  33. rednet.send(address, message);
  34. end
  35. else
  36. if address == "" then
  37. rednet.broadcast(message, protocol);
  38. else
  39. rednet.send(address, message, protocol);
  40. end
  41. end
  42. local returnMessage, from;
  43. if protocol == "" then
  44. from, returnMessage = rednet.receive(5);
  45. else
  46. from, returnMessage = rednet.receive(protocol, 5);
  47. end
  48. if from ~= nil then
  49. print("From: " .. from);
  50. print("=========================")
  51. print(returnMessage);
  52. print("=========================")
  53. else
  54. print("Recieved Nothing.")
  55. end
  56. io.read();
  57. end
  58. sleep(0);
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement