Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to clear the monitor screen
- local function clearMonitor(monitor)
- monitor.setBackgroundColor(colors.black) -- Set monitor background color to black
- monitor.clear()
- end
- -- Function to continuously cycle through RGB colors on a monitor
- local function cycleRGBColors(monitor)
- clearMonitor(monitor)
- local colors = {colors.red, colors.green, colors.blue}
- local colorIndex = 1
- -- Continuously cycle through RGB colors
- while true do
- monitor.setTextColor(colors[colorIndex])
- -- Display a placeholder text (optional)
- monitor.setCursorPos(1, 1)
- monitor.write("RGB Color Cycle")
- -- Increment color index for next cycle
- colorIndex = colorIndex % #colors + 1
- -- Sleep to control the speed of color change
- os.sleep(0.5)
- end
- end
- -- Example usage:
- local monitor = peripheral.wrap("top") -- Wrap the monitor peripheral on the "top" side
- -- Call the function to continuously cycle through RGB colors
- cycleRGBColors(monitor)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement