magge019

scroll

Jul 23rd, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. -- The text to show on the monitor
  2. local tText = {
  3. "==========================",
  4. "Creeper Head Industry Shop",
  5. "=======Comming Soon=======",
  6. "==========================",}
  7. -- The side the monitor is on
  8. local sSide = "top"
  9. -- The text scale
  10. local nTextScale = 3
  11.  
  12. local function printScroll(mon, t)
  13. local w, h = mon.getSize()
  14. local scroll = 1
  15. local maxLen
  16. for i, line in ipairs(t) do
  17. if not maxLen or #line > maxLen then
  18. maxLen = #line
  19. end
  20. end
  21. while true do
  22. mon.clear()
  23. for i, line in ipairs(t) do
  24. mon.setCursorPos(w - scroll, i)
  25. mon.write(line)
  26. end
  27. scroll = scroll + 1
  28. if scroll >= w + maxLen then
  29. scroll = 1
  30. end
  31. sleep(0.15)
  32. end
  33. end
  34.  
  35. term.clear()
  36. term.setCursorPos(12, 10)
  37. print("Scrolling text on the monitor...")
  38.  
  39. local mon = peripheral.wrap(sSide)
  40. mon.setTextColor(16)
  41. mon.setBackgroundColor(32768)
  42. mon.setTextScale(nTextScale)
  43. printScroll(mon, tText, sx)
Advertisement
Add Comment
Please, Sign In to add comment