Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. -- The monitor on which to display the text.
  2. local monitor = peripheral.wrap("bottom")
  3. -- The delay between marquee updates.
  4. local delay = 0.5
  5. -- String that separtes the text when it repeats.
  6. local sepStr = " "
  7.  
  8. -- Initial monitor configuration.
  9. monitor.setTextScale(5)
  10. monitor.setCursorBlink(false)
  11.  
  12. -- Get text to display.
  13. local text = "Stockage"
  14.  
  15. -- Create the repeating text unit.
  16. local monitorCharLength, _ = monitor.getSize()
  17.  
  18. -- Repeating text unit must be at least twice the size of text
  19. -- so there are no gaps when it scrolls.
  20. local repeatingText = text .. sepStr .. text
  21.  
  22. -- Expand the repeating text unit so that it is longer than
  23. -- the length of the monitor by at least a text unit's length.
  24. -- This will give an smooth, unbroken marquee effect.
  25. while string.len(repeatingText) <= monitorCharLength + string.len(text) do
  26. repeatingText = repeatingText .. sepStr .. text
  27. end
  28.  
  29. -- Write the repeating text unit at a negative offset on each tick
  30. -- to give the marquee effect.
  31. while true do
  32. for i = 1, -string.len(text) - string.len(sepStr) + 2, -1 do
  33. monitor.clear()
  34. monitor.setCursorPos(i, 1)
  35. monitor.write(repeatingText)
  36. sleep(delay)
  37. end
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement