Advertisement
Guest User

lauftext.lua

a guest
Feb 25th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1.  
  2. local gpu = require("component").gpu
  3. require("term").clear()
  4.  
  5. local function setResolution(columns)
  6.   local mw, mh = gpu.maxResolution()
  7.   for i = 1, mh do
  8.     gpu.setResolution(mw, i)
  9.     local w, h = gpu.getResolution()
  10.     if h >= columns then return end
  11.   end
  12. end
  13.  
  14. local function scrollText(texts, speed, cBack, cFore)
  15.   local positions = {}
  16.  
  17.   gpu.setBackground(cBack)
  18.   gpu.setForeground(cFore)
  19.   setResolution(#texts)
  20.  
  21.   for i = 1, #texts do positions[i] = 0 end
  22.   local width, height = gpu.getResolution()
  23.  
  24.   while true do
  25.     for i = 1, #texts do
  26.       gpu.fill(1, i, width, 1, " ")
  27.       for j = positions[i], width, string.len(texts[i]) do
  28.         gpu.set(j, i, texts[i])
  29.       end
  30.       positions[i] = positions[i] - 1
  31.       if positions[i] <= -string.len(texts[i]) then positions[i] = 0 end
  32.     end
  33.     os.sleep(speed)
  34.   end
  35. end
  36.  
  37. local texts = {
  38.   "Dies ist ein Test"
  39. }
  40.  
  41. scrollText(texts, 0.5, 0x000000, 0xFFFFFF)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement