guamie

asdasd

May 16th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  1. -- The text to show on the monitor
  2. local tText = {
  3. "First Line",
  4. "Second Line",
  5. "All the lines you want",
  6. "If they fit on the monitor"
  7. }
  8. -- The side the monitor is on
  9. local sSide = "back"
  10. -- The text scale
  11. local nTextScale = 3
  12.  
  13. local function printScroll(mon, t)
  14.     local w, h = mon.getSize()
  15.     local scroll = 1
  16.     local maxLen
  17.     for i, line in ipairs(t) do
  18.         if not maxLen or #line > maxLen then
  19.             maxLen = #line
  20.         end
  21.     end
  22.     while true do
  23.         mon.clear()
  24.         for i, line in ipairs(t) do
  25.             mon.setCursorPos(w - scroll, i)
  26.             mon.write(line)
  27.         end
  28.         scroll = scroll + 1
  29.         if scroll >= w + maxLen then
  30.             scroll = 1
  31.         end
  32.         sleep(0.15)
  33.     end
  34. end
  35.  
  36. term.clear()
  37. term.setCursorPos(1, 1)
  38. print("Scrolling text on the monitor...")
  39.  
  40. local mon = peripheral.wrap(sSide)
  41. mon.setTextScale(nTextScale)
  42. printScroll(mon, tText, sx)
Add Comment
Please, Sign In to add comment