Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local colorsList = {
- colors.white, colors.orange, colors.magenta, colors.lightBlue,
- colors.yellow, colors.lime, colors.pink, colors.gray,
- colors.lightGray, colors.cyan, colors.purple, colors.blue,
- colors.brown, colors.green, colors.red, colors.black,
- }
- local message = [[
- __
- / / ___ __ _____ ___ ____
- / /__/ _ \/ // / _ \/ _ `/ -_)
- /____/\___/\_,_/_//_/\_, /\__/
- /___/
- ]]
- local monitor = peripheral.find("monitor")
- monitor.setTextScale(1)
- monitor.setCursorBlink(false)
- local currentTextColor = colors.green -- Default text color
- local currentBackgroundColor = colors.black -- Default background color
- monitor.setTextColor(currentTextColor) -- Default text color
- monitor.setBackgroundColor(currentBackgroundColor) -- Default background color
- local totalWidth, height = monitor.getSize()
- local singleMonitorWidth = totalWidth / 6 -- Adapt for 6-wide monitors
- local speed = 0.25 -- Default speed
- local isPaused = false
- local offset = 1
- local isRainbowMode = false
- local currentColorIndex = 1
- local messageLines = {}
- for line in message:gmatch("[^\r\n]+") do
- table.insert(messageLines, line .. string.rep(" ", totalWidth))
- end
- local fullMessageWidth = totalWidth
- for _, line in ipairs(messageLines) do
- fullMessageWidth = math.max(fullMessageWidth, #line)
- end
- fullMessageWidth = fullMessageWidth + totalWidth
- local function drawText(offset)
- monitor.setBackgroundColor(currentBackgroundColor)
- monitor.clear()
- if isRainbowMode then
- currentColorIndex = (currentColorIndex % #colorsList) + 1
- monitor.setTextColor(colorsList[currentColorIndex])
- else
- monitor.setTextColor(currentTextColor) -- Use variable here
- end
- for i = 1, #messageLines do
- local lineOffset = (offset - 1) % fullMessageWidth + 1
- local visibleText = messageLines[i]:sub(lineOffset, lineOffset + totalWidth - 1) ..
- messageLines[i]:sub(1, lineOffset - 1)
- monitor.setCursorPos(1, i)
- monitor.write(visibleText)
- end
- end
- local function scrollText()
- while true do
- if not isPaused then
- drawText(offset)
- sleep(speed)
- offset = offset + 1
- if offset > fullMessageWidth then
- offset = 1
- end
- else
- sleep(0.1)
- end
- end
- end
- local function terminalInterface()
- local helpMessage = [[
- Commands:
- speed <value> - Set scrolling speed (0.1 to 1)
- pause - Pause scrolling
- start - Start scrolling
- center - Center and pause scrolling
- textcolor <color> - Change text color (e.g., green, red, blue)
- backgroundcolor <color> - Change background color
- rainbow - Enable rainbow mode
- help - Show this help message
- ]]
- print("Welcome to the ASCII Scroller Control Terminal")
- print("Waiting for command. Type 'help' for a list of commands.")
- print(helpMessage)
- while true do
- local command = read()
- if command == "pause" then
- isPaused = true
- elseif command == "start" then
- isPaused = false
- elseif command == "center" then
- isPaused = true
- offset = math.floor((totalWidth - #message) / 2)
- elseif command == "rainbow" then
- isRainbowMode = not isRainbowMode
- print(isRainbowMode and "Rainbow mode enabled!" or "Rainbow mode disabled!")
- elseif command == "help" then
- print(helpMessage)
- elseif command:match("^speed%s+(%S+)$") then
- local newSpeed = tonumber(command:match("^speed%s+(%S+)$"))
- if newSpeed and newSpeed >= 0.1 and newSpeed <= 1 then
- speed = newSpeed
- print("Speed updated!")
- else
- print("Invalid input. Please enter a number between 0.1 and 1.")
- end
- elseif command:match("^textcolor%s+%w+$") then
- local colorName = command:match("^textcolor%s+(%w+)$")
- if colors[colorName] then
- currentTextColor = colors[colorName] -- Update variable here
- print("Text color updated!")
- else
- print("Invalid color. Available colors: white, orange, magenta, etc.")
- end
- elseif command:match("^backgroundcolor%s+%w+$") then
- local colorName = command:match("^backgroundcolor%s+(%w+)$")
- if colors[colorName] then
- currentBackgroundColor = colors[colorName]
- print("Background color updated!")
- else
- print("Invalid color. Available colors: white, orange, magenta, etc.")
- end
- else
- print("Unknown command. Type 'help' for a list of commands.")
- end
- end
- end
- parallel.waitForAll(scrollText, terminalInterface)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement