David_Turtle

Turtle "eZ Connect"

Nov 8th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.60 KB | None | 0 0
  1. local modem = peripheral.wrap("right")
  2. function info()
  3.     term.clear()
  4.     term.setCursorPos(1,1)
  5.     term.write("Computer ID: ")
  6.     print(os.getComputerID())
  7.     print("Alle eZ-Connect Geraete senden auf Kanal 42")
  8.     print("Nachrichten empfangen mit recieve")
  9.     print("Nachrichten senden mit send")
  10.     print("Benoetigt ein Wireless Modem an der rechten Seite")
  11.     print("Beenden mit exit")
  12. end
  13. function recieve()
  14.     print("Warte auf Nachricht...")
  15.     event, modemSite, senderChannel, replyChannel, message = os.pullEvent("modem_message")
  16.     print("")
  17.     print("Nachricht erhalten:")
  18.     print(message)
  19.     term.write("Auf Kanal ")
  20.     term.write(senderChannel)
  21.     term.write(" mit Antwortkanal ")
  22.     print(replyChannel)
  23. end
  24. function exit()
  25.     print("Programm beendet")
  26.     print("Computer wird nun neustarten")
  27.     os.sleep(3)
  28.     os.reboot()
  29. end
  30. function send()
  31.     print("Sende Nachricht...")
  32.     local message = read()
  33.     modem.transmit(42, 42, message)
  34.     print("Nachricht gesendet: ")
  35.     print(message)
  36. end
  37. function clear()
  38.     term.clear()
  39.     term.setCursorPos(1,1)
  40. end
  41. modem.open(42)
  42. local run = 0
  43. term.clear()
  44. term.setCursorPos(1,1)
  45. term.write("eZ-Connect")
  46. print("")
  47. sleep(2)
  48.  
  49. while run ~= 1 do
  50.         print("")
  51.         command = read()
  52.     if command == "info" then
  53.                 info()
  54.     elseif command == "recieve" then
  55.                 recieve()
  56.     elseif command == "send" then
  57.                 send()
  58.     elseif command == "clear" then
  59.                 clear()
  60.     elseif command == "exit" then
  61.         exit()
  62.         else
  63.                 print("Unbekannter Kommando")
  64.                 print("Hilfe mit info")
  65.                 os.sleep(1)
  66.     end
  67. end
Advertisement
Add Comment
Please, Sign In to add comment