Advertisement
JustinzocktYT

somthing i need in computer craft just ignore

Jun 26th, 2025
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.39 KB | None | 0 0
  1. -- Konfiguration
  2. local TICKER_MESSAGE = "Sehr geehrte Fahrgäste, auf Grund einer Baustelle fahren aktuell keine Züge. Wir bitten um Ihr Verständnis +++ Aktuell kann es zu Verzögerungen bei Bus und Stadtbahn kommen, Grund dafür ist eine Brücke die saniert wird. Wir bitten um Verständnis"
  3. local TICKER_SPEED = 0.3 -- Geschwindigkeit des Lauftextes (in Sekunden)
  4. local COL_WIDTHS = {4, 15, 5, 8, 8} -- Spaltenbreiten: Linie, Ziel, Gleis, Ankunft, Abfahrt
  5.  
  6. -- Beispieldaten für die Tabelle
  7. local schedule = {
  8.   {"S1", "Stuttgart Hbf", "3", "12:30", "12:32"},
  9.   {"S2", "Schorndorf", "5", "12:35", "12:37"},
  10.   {"U5", "Herrenberg", "1", "12:40", "12:42"},
  11.   {"RE", "Tübingen Hbf", "9", "12:45", "12:47"},
  12.   {"ICE", "München Hbf", "12", "12:50", "12:53"}
  13. }
  14.  
  15. -- Monitor initialisieren
  16. local mon = peripheral.find("monitor")
  17. if mon then
  18.   mon.setTextScale(0.5)
  19.   mon.setBackgroundColor(colors.black)
  20.   mon.setTextColor(colors.white)
  21. else
  22.   print("Kein Monitor gefunden! Verbinde einen Monitor.")
  23.   return
  24. end
  25.  
  26. local w, h = mon.getSize()
  27. local tickerOffset = 0
  28.  
  29. -- Hauptfunktion
  30. while true do
  31.   mon.clear()
  32.  
  33.   -- Uhrzeit und Datum oben rechts
  34.   local time = textutils.formatTime(os.time(), false)
  35.   local date = os.date("%d.%m.%Y")
  36.   local datetime = time .. "   " .. date
  37.   mon.setCursorPos(w - #datetime + 1, 1)
  38.   mon.write(datetime)
  39.  
  40.   -- Tabellen-Überschriften
  41.   local headers = {"Linie", "Ziel", "Gleis", "Ankunft", "Abfahrt"}
  42.   local yPos = 3
  43.   local x = 2
  44.  
  45.   for i, header in ipairs(headers) do
  46.     mon.setCursorPos(x, yPos - 1)
  47.     mon.write(header)
  48.     x = x + COL_WIDTHS[i] + 2
  49.   end
  50.  
  51.   -- Trennlinie unter Überschriften
  52.   mon.setCursorPos(1, yPos)
  53.   mon.write(string.rep("-", w))
  54.  
  55.   -- Fahrplandaten
  56.   for i, entry in ipairs(schedule) do
  57.     if yPos + i <= h - 2 then
  58.       x = 2
  59.       for j, item in ipairs(entry) do
  60.         mon.setCursorPos(x, yPos + i)
  61.         mon.write(item)
  62.         x = x + COL_WIDTHS[j] + 2
  63.       end
  64.     end
  65.   end
  66.  
  67.   -- Lauftext (Ticker)
  68.   local tickerY = h
  69.   local displayText = TICKER_MESSAGE .. " +++ " .. TICKER_MESSAGE
  70.   local tickerText = ""
  71.  
  72.   for i = 1, w do
  73.     local idx = (tickerOffset + i - 1) % #displayText + 1
  74.     tickerText = tickerText .. displayText:sub(idx, idx)
  75.   end
  76.  
  77.   mon.setCursorPos(1, tickerY)
  78.   mon.write(tickerText)
  79.   tickerOffset = (tickerOffset + 1) % #displayText
  80.  
  81.   sleep(TICKER_SPEED)
  82. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement