Advertisement
Skillkiller

Dashboard

Jul 19th, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.33 KB | None | 0 0
  1. --Dashboard
  2. wModul = "top" --Angabe für die Position des Wirless Modems
  3. monitor = "right" --Angabe für die Position des Monitors
  4. TextScale = 1 --Anagbe für die Größe der Schrift
  5. PInfo = "1900Info" --Angabe für das Sende Protokoll Info --Müssen im Code gewechselt werden
  6. PWarn = "1900Warn" --Angabe für das Sende Protokoll Warn --Müssen im Code gewechselt werden
  7. PCrit = "1900Crit" --Angabe für das Sende Protokoll Crit --Müssen im Code gewechselt werden
  8. url = "http://thecoin.de/time.php" --Woher soll der Computer die Uhrzeit nehmen
  9.  
  10. --Code
  11. rednet.open(wModul)
  12. local monitor = peripheral.wrap(monitor)
  13. monitor.setTextScale(TextScale)
  14. monitor.setCursorPos(0,0)
  15. monitor.clear()
  16. maxX, maxY = monitor.getSize()
  17. lastRoundLocked = false
  18.  
  19. print("Lade Daten...")
  20.  
  21. rednet.broadcast("status?", "1900Player")
  22. senderId, message, protocol = rednet.receive("1900Player",10)
  23.  
  24. if message == "Online" then
  25.  POnline = true
  26. elseif message == "Offline" then
  27.  POnline = false
  28. else
  29.  print("Es scheint etwas nicht zu stimmen ?!")
  30.  sleep(5)
  31.  os.reboot()
  32. end
  33.  
  34. shell.run("clear")
  35. print("Privates Dashboard")
  36. print("Max X: " .. maxX)
  37. print("Max Y: " .. maxY)
  38.  
  39. function info()
  40. senderId, message, protocol = rednet.receive("1900Info")
  41. show("Info", message)
  42. end
  43.  
  44. function warn()
  45. senderId, message, protocol = rednet.receive("1900Warn")
  46. show("Warn", message)
  47. end
  48.  
  49. function crit()
  50. senderId, message, protocol = rednet.receive("1900Crit")
  51. show("Crit", message)
  52. end
  53.  
  54. function show(status, Message)
  55.  
  56. x, y = monitor.getCursorPos()
  57.  
  58. if message == "Benutzer ging Offline" then
  59.  POnline = false;
  60. elseif message == "Benutzer ging Online" then
  61.  POnline = true;
  62. end
  63.  
  64. if POnline == true then
  65.   curX, curY = monitor.getCursorPos()
  66.  
  67.   if (curY == math.floor((maxY/2) + 0,5)  and lastRoundLocked == true) then
  68.     monitor.clear()
  69.     y = 0 --Fix für die Ansicht
  70.     lastRoundLocked = false
  71.   end
  72.  
  73.   if y == maxY then
  74.     monitor.scroll(1)
  75.     monitor.setCursorPos(1, maxY)
  76.   else
  77.     monitor.setCursorPos(1, y + 1)
  78.   end
  79.  
  80.   monitor.write(http.get(url).readAll() .. ": " .. status .. ": " .. Message)
  81.  
  82. else
  83.   monitor.clear()
  84.   monitor.setCursorPos(1, math.floor((maxY/2) + 0,5))
  85.   monitor.write("Dashboard nicht aktiv!")
  86.   lastRoundLocked = true
  87.  
  88. end
  89. end
  90.  
  91. while true do --Endlosschleife
  92. parallel.waitForAny(info, warn, crit)
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement