Advertisement
Mojokojo69

raresign

Aug 22nd, 2023 (edited)
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.00 KB | None | 0 0
  1. local colorsList = {
  2. colors.white, colors.orange, colors.magenta, colors.lightBlue,
  3. colors.yellow, colors.lime, colors.pink, colors.gray,
  4. colors.lightGray, colors.cyan, colors.purple, colors.blue,
  5. colors.brown, colors.green, colors.red, colors.black,
  6. }
  7.  
  8. local message = [[
  9. __
  10. / / ___ __ _____ ___ ____
  11. / /__/ _ \/ // / _ \/ _ `/ -_)
  12. /____/\___/\_,_/_//_/\_, /\__/
  13. /___/
  14. ]]
  15.  
  16. local monitor = peripheral.find("monitor")
  17. monitor.setTextScale(1)
  18. monitor.setCursorBlink(false)
  19. local currentTextColor = colors.green -- Default text color
  20. local currentBackgroundColor = colors.black -- Default background color
  21. monitor.setTextColor(currentTextColor) -- Default text color
  22. monitor.setBackgroundColor(currentBackgroundColor) -- Default background color
  23.  
  24. local totalWidth, height = monitor.getSize()
  25. local singleMonitorWidth = totalWidth / 6 -- Adapt for 6-wide monitors
  26. local speed = 0.25 -- Default speed
  27. local isPaused = false
  28. local offset = 1
  29. local isRainbowMode = false
  30. local currentColorIndex = 1
  31.  
  32. local messageLines = {}
  33. for line in message:gmatch("[^\r\n]+") do
  34. table.insert(messageLines, line .. string.rep(" ", totalWidth))
  35. end
  36.  
  37. local fullMessageWidth = totalWidth
  38. for _, line in ipairs(messageLines) do
  39. fullMessageWidth = math.max(fullMessageWidth, #line)
  40. end
  41.  
  42. fullMessageWidth = fullMessageWidth + totalWidth
  43.  
  44. local function drawText(offset)
  45. monitor.setBackgroundColor(currentBackgroundColor)
  46. monitor.clear()
  47. if isRainbowMode then
  48. currentColorIndex = (currentColorIndex % #colorsList) + 1
  49. monitor.setTextColor(colorsList[currentColorIndex])
  50. else
  51. monitor.setTextColor(currentTextColor) -- Use variable here
  52. end
  53. for i = 1, #messageLines do
  54. local lineOffset = (offset - 1) % fullMessageWidth + 1
  55. local visibleText = messageLines[i]:sub(lineOffset, lineOffset + totalWidth - 1) ..
  56. messageLines[i]:sub(1, lineOffset - 1)
  57. monitor.setCursorPos(1, i)
  58. monitor.write(visibleText)
  59. end
  60. end
  61.  
  62. local function scrollText()
  63. while true do
  64. if not isPaused then
  65. drawText(offset)
  66. sleep(speed)
  67. offset = offset + 1
  68. if offset > fullMessageWidth then
  69. offset = 1
  70. end
  71. else
  72. sleep(0.1)
  73. end
  74. end
  75. end
  76.  
  77. local function terminalInterface()
  78. local helpMessage = [[
  79. Commands:
  80. speed <value> - Set scrolling speed (0.1 to 1)
  81. pause - Pause scrolling
  82. start - Start scrolling
  83. center - Center and pause scrolling
  84. textcolor <color> - Change text color (e.g., green, red, blue)
  85. backgroundcolor <color> - Change background color
  86. rainbow - Enable rainbow mode
  87. help - Show this help message
  88. ]]
  89.  
  90. print("Welcome to the ASCII Scroller Control Terminal")
  91. print("Waiting for command. Type 'help' for a list of commands.")
  92. print(helpMessage)
  93. while true do
  94. local command = read()
  95. if command == "pause" then
  96. isPaused = true
  97. elseif command == "start" then
  98. isPaused = false
  99. elseif command == "center" then
  100. isPaused = true
  101. offset = math.floor((totalWidth - #message) / 2)
  102. elseif command == "rainbow" then
  103. isRainbowMode = not isRainbowMode
  104. print(isRainbowMode and "Rainbow mode enabled!" or "Rainbow mode disabled!")
  105. elseif command == "help" then
  106. print(helpMessage)
  107. elseif command:match("^speed%s+(%S+)$") then
  108. local newSpeed = tonumber(command:match("^speed%s+(%S+)$"))
  109. if newSpeed and newSpeed >= 0.1 and newSpeed <= 1 then
  110. speed = newSpeed
  111. print("Speed updated!")
  112. else
  113. print("Invalid input. Please enter a number between 0.1 and 1.")
  114. end
  115. elseif command:match("^textcolor%s+%w+$") then
  116. local colorName = command:match("^textcolor%s+(%w+)$")
  117. if colors[colorName] then
  118. currentTextColor = colors[colorName] -- Update variable here
  119. print("Text color updated!")
  120. else
  121. print("Invalid color. Available colors: white, orange, magenta, etc.")
  122. end
  123. elseif command:match("^backgroundcolor%s+%w+$") then
  124. local colorName = command:match("^backgroundcolor%s+(%w+)$")
  125. if colors[colorName] then
  126. currentBackgroundColor = colors[colorName]
  127. print("Background color updated!")
  128. else
  129. print("Invalid color. Available colors: white, orange, magenta, etc.")
  130. end
  131. else
  132. print("Unknown command. Type 'help' for a list of commands.")
  133. end
  134. end
  135. end
  136.  
  137. parallel.waitForAll(scrollText, terminalInterface)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement