ModJosh

scrollingtext7

Feb 17th, 2025
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. local monitor = peripheral.wrap("bottom") -- Change "bottom" if your monitor is on a different side
  2.  
  3. monitor.setTextScale(3.0) -- Adjust text size (0.5 - 5.0)
  4. monitor.setTextColor(colors.white) -- Set text color to blue
  5. monitor.setBackgroundColor(colors.blue) -- Set background color to white
  6. monitor.clear()
  7.  
  8. local message = " Hostile Networks "
  9. local width, height = monitor.getSize() -- Get monitor dimensions
  10. local centerY = math.floor(height / 2) -- Center the text vertically
  11.  
  12. -- Create a padded message: pad on both sides with spaces (length = monitor width)
  13. local pad = string.rep(" ", width)
  14. local paddedMessage = pad .. message .. pad
  15. local paddedLength = #paddedMessage
  16.  
  17. while true do
  18. -- Loop from the far right of the padded message back to the start
  19. for offset = paddedLength - width + 1, 1, -1 do
  20. local display = string.sub(paddedMessage, offset, offset + width - 1)
  21. monitor.setCursorPos(1, centerY)
  22. monitor.clearLine() -- Clear only the current line
  23. monitor.write(display)
  24. sleep(0.2) -- Adjust the scrolling speed here
  25. end
  26. end
  27.  
Advertisement
Add Comment
Please, Sign In to add comment