Advertisement
MigasRocha

RGB Storage Room

Apr 27th, 2024 (edited)
832
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. -- Function to clear the monitor screen
  2. local function clearMonitor(monitor)
  3.     monitor.setBackgroundColor(colors.black)  -- Set monitor background color to black
  4.     monitor.clear()
  5. end
  6.  
  7. -- Function to continuously cycle through RGB colors on a monitor
  8. local function cycleRGBColors(monitor)
  9.     clearMonitor(monitor)
  10.  
  11.     local colors = {colors.red, colors.green, colors.blue}
  12.     local colorIndex = 1
  13.  
  14.     -- Continuously cycle through RGB colors
  15.     while true do
  16.         monitor.setTextColor(colors[colorIndex])
  17.  
  18.         -- Display a placeholder text (optional)
  19.         monitor.setCursorPos(1, 1)
  20.         monitor.write("RGB Color Cycle")
  21.  
  22.         -- Increment color index for next cycle
  23.         colorIndex = colorIndex % #colors + 1
  24.  
  25.         -- Sleep to control the speed of color change
  26.         os.sleep(0.5)
  27.     end
  28. end
  29.  
  30. -- Example usage:
  31. local monitor = peripheral.wrap("top")  -- Wrap the monitor peripheral on the "top" side
  32.  
  33. -- Call the function to continuously cycle through RGB colors
  34. cycleRGBColors(monitor)
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement