Advertisement
Skillkiller

Externes Gebäude Screen

Sep 30th, 2016
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. --Variablen
  2. wModul = "top"
  3. monitor = "left"
  4.  
  5. -- Code
  6. rednet.open(wModul)
  7. local monitor = peripheral.wrap(monitor)
  8. monitor.setTextScale(1)
  9.  
  10. function saubermachen()
  11. monitor.setCursorPos(1,1)
  12. monitor.setBackgroundColor(colors.black)
  13. monitor.clear()
  14. end
  15.  
  16.  
  17. function externesBild()
  18. maxX, maxY = monitor.getSize()
  19. saubermachen()
  20. local text = "Externes Geb\195\164ude"
  21. monitor.setCursorPos(math.floor((maxX - string.len(text)) / 2 + 1), 1) --Berechnung vom Mittelpunkt der ersten Zeile
  22. monitor.setTextColor(colors.red)
  23. monitor.write(text)
  24.  
  25. local text = "von Minni1704"
  26. monitor.setCursorPos(math.floor((maxX - string.len(text)) / 2 + 1), 2) --Berechnung vom Mittelpunkt der zweiten Zeile
  27. monitor.setTextColor(colors.lime)
  28. monitor.write(text)
  29.  
  30. monitor.setTextColor(colors.white)
  31. monitor.setCursorPos(1, 5)
  32. monitor.write("Besitzer: ")
  33. local besitzer = BesitzerCheck()
  34. if besitzer == "Online" then
  35.     monitor.setTextColor(colors.green)
  36.     monitor.write(besitzer)
  37. else
  38.     monitor.setTextColor(colors.red)
  39.     monitor.write(besitzer)
  40. end
  41. print("User ist " .. besitzer)
  42. monitor.setCursorPos(1, 6)
  43. monitor.write(os.time())
  44. end
  45.  
  46. function BesitzerCheck()
  47. rednet.broadcast("status?", "1900Player")
  48. local senderId, message, protocol = rednet.receive("1900Player",10)
  49.  
  50. if (message == "Online" or message == "Offline") then
  51. return message
  52. end
  53. end
  54.  
  55. externesBild()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement