Advertisement
Skillkiller

Meldezentrale

Feb 9th, 2016
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.16 KB | None | 0 0
  1. -- Variablen
  2. protokoll = "1594"
  3. light = "bottom"
  4. modul = "back"
  5.  
  6. -- Start
  7. rednet.open(modul)
  8. redstone.setOutput(light, true)
  9. mon = peripheral.wrap("right")
  10. print("Keine Nachricht empfangen")
  11. print("Warte auf erste Nachricht")
  12.  
  13. -- Funktionen
  14. function blink()
  15. for i = 1, 5 do
  16.  redstone.setOutput(light, false)
  17.  sleep(0.2)
  18.  redstone.setOutput(light, true)
  19.  sleep(0.2)
  20. end
  21. end
  22.  
  23. function newLine()
  24. local cX,cY= mon.getCursorPos()
  25. mon.setCursorPos(1,cY+1)
  26. end
  27.  
  28. function dashboard(memo)
  29. mon.clear()
  30. mon.setCursorPos(1,1)
  31. mon.write("Neuste Nachricht: ")
  32. local cX = mon.getCursorPos()
  33. zeilen = math.ceil(string.len(memo)/cX)
  34. for i = 1, zeilen do
  35.  newLine()
  36.  mon.write(string.sub(memo, (i-1)*cX+1, i*cX))
  37. end
  38. end
  39.  
  40. -- Loader
  41. while true do
  42. local senderId, message = rednet.receive()
  43. shell.run("clear")
  44. if string.sub(message, 0, string.len(protokoll)) == protokoll then
  45.  blink()
  46.  print("Blink abgeschlossen")
  47.  dashboard(string.sub(message, string.len(protokoll) +1))
  48.  print("Dashboard abgeschlossen")
  49. else
  50.  print("Falsches Protokoll")
  51.  print("Protokoll: " .. string.sub(message, 0, string.len(protokoll)))
  52. end
  53. print("Warte auf neue Nachricht")
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement