Advertisement
yeeeeeeeeeeeee

eeeeeeeeeeeeeeeeeeee

May 3rd, 2025
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.51 KB | None | 0 0
  1. -- Define all presets
  2. local presets = {
  3. default = {
  4. {colors.white, 0xf0f0f0}, {colors.orange, 0xf2b233}, {colors.magenta, 0xe57fd8},
  5. {colors.lightBlue, 0x99b2f2}, {colors.yellow, 0xdede6c}, {colors.lime, 0x7fcc19},
  6. {colors.pink, 0xf2b2cc}, {colors.gray, 0x4c4c4c}, {colors.lightGray, 0x999999},
  7. {colors.cyan, 0x4c99b2}, {colors.purple, 0xb266e5}, {colors.blue, 0x3366cc},
  8. {colors.brown, 0x7f664c}, {colors.green, 0x57a64e}, {colors.red, 0xcc4c4c},
  9. {colors.black, 0x111111}
  10. },
  11. inverted = {
  12. {colors.white, 0x111111}, {colors.black, 0xf0f0f0}, {colors.gray, 0x999999},
  13. {colors.lightGray, 0x4c4c4c}, {colors.orange, 0xf2b233}, {colors.magenta, 0xe57fd8},
  14. {colors.lightBlue, 0x99b2f2}, {colors.yellow, 0xdede6c}, {colors.lime, 0x7fcc19},
  15. {colors.pink, 0xf2b2cc}, {colors.cyan, 0x4c99b2}, {colors.purple, 0xb266e5},
  16. {colors.blue, 0x3366cc}, {colors.brown, 0x7f664c}, {colors.green, 0x57a64e},
  17. {colors.red, 0xcc4c4c}
  18. },
  19. rgb = {
  20. {colors.white, 0xffffff}, {colors.orange, 0xff7f00}, {colors.magenta, 0xbe00ff},
  21. {colors.lightBlue, 0x7f7fff}, {colors.yellow, 0xffff00}, {colors.lime, 0x00ff00},
  22. {colors.pink, 0xff00ff}, {colors.gray, 0x555555}, {colors.lightGray, 0xbebebe},
  23. {colors.cyan, 0x007fff}, {colors.purple, 0x5500ff}, {colors.blue, 0x0000ff},
  24. {colors.brown, 0x7f4000}, {colors.green, 0x007f00}, {colors.red, 0xff0000},
  25. {colors.black, 0x000000}
  26. },
  27. retro = {
  28. {colors.white, 0xf4f4f4}, {colors.orange, 0xef7d57}, {colors.magenta, 0x566c86},
  29. {colors.lightBlue, 0x41a6f6}, {colors.yellow, 0xffcd75}, {colors.lime, 0xa7f070},
  30. {colors.pink, 0x94b0c2}, {colors.gray, 0x505050}, {colors.lightGray, 0xb0b0b0},
  31. {colors.cyan, 0x3e82e0}, {colors.purple, 0x333c57}, {colors.blue, 0x3b5dc9},
  32. {colors.brown, 0x7f664c}, {colors.green, 0x38b764}, {colors.red, 0xb13e53},
  33. {colors.black, 0x151515}
  34. },
  35. hacker = {
  36. {colors.white, 0x00ff00}, {colors.orange, 0x00ff00}, {colors.magenta, 0x00ec05},
  37. {colors.lightBlue, 0x00da09}, {colors.yellow, 0x00ff00}, {colors.lime, 0x00c70e},
  38. {colors.pink, 0x00b513}, {colors.gray, 0x006000}, {colors.lightGray, 0x00b000},
  39. {colors.cyan, 0x00a217}, {colors.purple, 0x00901c}, {colors.blue, 0x003333},
  40. {colors.brown, 0x007d20}, {colors.green, 0x006b25}, {colors.red, 0x00582a},
  41. {colors.black, 0x001100}
  42. }
  43. }
  44.  
  45. -- Function to generate a random palette
  46. local function generateRandomPalette()
  47. local keys = {
  48. colors.white, colors.orange, colors.magenta, colors.lightBlue,
  49. colors.yellow, colors.lime, colors.pink, colors.gray,
  50. colors.lightGray, colors.cyan, colors.purple, colors.blue,
  51. colors.brown, colors.green, colors.red, colors.black
  52. }
  53. local palette = {}
  54. for _, color in ipairs(keys) do
  55. table.insert(palette, {color, math.random(0, 0xFFFFFF)})
  56. end
  57. return palette
  58. end
  59.  
  60. -- Set palette on term and write to file
  61. local function applyPalette(preset)
  62. local file = fs.open("/startup/paletteSetter.lua", "w")
  63. for _, pair in ipairs(preset) do
  64. local color, hex = table.unpack(pair)
  65. term.setPaletteColor(color, hex)
  66. file.writeLine("term.setPaletteColor("..color..", "..hex..")")
  67. end
  68. file.close()
  69. end
  70.  
  71. -- Flashing colors on monitor loop
  72. local function startFlashing(palette, monitor)
  73. monitor.setTextScale(1)
  74. monitor.clear()
  75. while true do
  76. for _, pair in ipairs(palette) do
  77. monitor.setBackgroundColor(pair[1])
  78. monitor.clear()
  79. sleep(0.4)
  80. end
  81. end
  82. end
  83.  
  84. -- Setup
  85. local monitor = peripheral.wrap("top")
  86. if not monitor then
  87. print("No monitor on top!")
  88. return
  89. end
  90.  
  91. monitor.setTextScale(1)
  92. monitor.setBackgroundColor(colors.black)
  93. monitor.setTextColor(colors.white)
  94. monitor.clear()
  95.  
  96. local options = {"default", "inverted", "rgb", "retro", "hacker", "random"}
  97.  
  98. -- Draw menu
  99. for i, name in ipairs(options) do
  100. monitor.setCursorPos(2, i + 1)
  101. monitor.write("[" .. name .. "]")
  102. end
  103.  
  104. -- Wait for touch
  105. while true do
  106. local event, side, x, y = os.pullEvent("monitor_touch")
  107. local choice = options[y - 1]
  108. if choice then
  109. local selected = choice == "random" and generateRandomPalette() or presets[choice]
  110. applyPalette(selected)
  111. monitor.setTextScale(1)
  112. monitor.clear()
  113. startFlashing(selected, monitor)
  114. end
  115. end
  116.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement