Aphex124

Untitled

Dec 29th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. function scrollText(tStrings, nRate)
  2. nRate = nRate or 5
  3. if nRate < 0 then
  4. error("rate must be positive")
  5. end
  6. local nSleep = 1 / nRate
  7.  
  8. width, height = mon.getSize()
  9. x, y = mon.getCursorPos()
  10. sText = ""
  11. for n = 1, #tStrings do
  12. sText = sText .. tostring(tStrings[n])
  13. sText = sText .. " | "
  14. end
  15. sString = "| "
  16. if width / string.len(sText) < 1 then
  17. nStringRepeat = 3
  18. else
  19. nStringRepeat = math.ceil(width / string.len(sText) * 3)
  20. end
  21. for n = 1, nStringRepeat do
  22. sString = sString .. sText
  23. end
  24. while true do
  25. for n = 1, string.len(sText) do
  26. sDisplay = string.sub(sString, n, n + width - 1)
  27. mon.clearLine()
  28. mon.setCursorPos(1, y)
  29. mon.write(sDisplay)
  30. sleep(nSleep)
  31. end
  32. end
  33. end
Add Comment
Please, Sign In to add comment