Advertisement
Guest User

temp

a guest
Oct 22nd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | None | 0 0
  1. local Args = {...}
  2.  
  3. local VText = {
  4. "S",
  5. "A",
  6. "L",
  7. "L",
  8. "E",
  9. " ",
  10. "D",
  11. "E",
  12. "S",
  13. " ",
  14. "M",
  15. "A",
  16. "C",
  17. "H",
  18. "I",
  19. "N",
  20. "E",
  21. "S"
  22. }
  23.  
  24. local HText = {
  25. "",
  26. "SALLE DES MACHINES"
  27. }
  28.  
  29. local MonitorSide = "left"
  30. local TextScale = 1.9
  31.  
  32. local function printScrollHorizontal(p, t)
  33.     local w, h = p.getSize()
  34.     local scroll = 1
  35.     local maxLen
  36.     ModSet = 0
  37.     for i, line in ipairs(t) do
  38.         if not maxLen or #line > maxLen then
  39.             maxLen = #line
  40.         end
  41.     end
  42.     while true do
  43.         p.clear()
  44.         for i, line in ipairs(t) do
  45.             p.setCursorPos(w - scroll, i)
  46.             p.write(line)
  47.         end
  48.         scroll = scroll + 1
  49.         if scroll >= w + maxLen then
  50.             scroll = 1
  51.         end
  52.         sleep(0.15)
  53.     end
  54. end
  55.  
  56. local function printScrollVertical(p, t)
  57.     local w, h = p.getSize()
  58.     while true do
  59.         p.clear()
  60.         for k,v in ipairs(t) do
  61.             p.setCursorPos(1,h)
  62.             p.write(v)
  63.             os.sleep(0.35)
  64.             p.scroll(1)
  65.         end
  66.        
  67.         for i=1,tablelength(t) do
  68.             p.scroll(1)
  69.             os.sleep(0.35)
  70.         end
  71.     end
  72. end
  73.  
  74. function tablelength(a)
  75.     local b = 0
  76.     for _ in pairs(a) do b = b + 1 end
  77.     return b-2
  78. end
  79.  
  80. local p = peripheral.wrap(MonitorSide)
  81. p.setTextScale(TextScale)
  82.  
  83. term.clear()
  84. term.setCursorPos(1, 1)
  85.  
  86.  
  87. if Args[1] ~= "V" then
  88.     print("Scroll Text Horizontal")
  89.     printScrollHorizontal(p, HText, sx)
  90. else
  91.     print("Scroll TextVertical")
  92.     printScrollVertical(p, VText)
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement