Advertisement
Le_JuiceBOX

[OS] colors.lua

Jan 22nd, 2025 (edited)
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.45 KB | None | 0 0
  1. -- 009Zm3kF
  2. local Terminal = require("/terminal").new()
  3.  
  4. local TEXT = {
  5.     "0 - &0White",
  6.     "1 - &1Orange",
  7.     "2 - &2Magenta",
  8.     "3 - &3Li.Blue",
  9.     "4 - &4Yellow",
  10.     "5 - &5Lime",
  11.     "6 - &6Pink",
  12.     "7 - &7Grey",
  13.     "8 - &8Li.Gray",
  14.     "9 - &8Cyan",
  15.     "a - &aPurple",
  16.     "b - &bBlue",
  17.     "c - &cBrown",
  18.     "d - &dGreen",
  19.     "e - &eRed",
  20.     "f - &7Black",
  21. }
  22.  
  23. function main()
  24.     Terminal:reset()
  25.     yStart = 4
  26.     local yPos = yStart
  27.     repeat
  28.         -- generate the list at yPos, which is incremented and decremented to choose the starting pos of list, header and info is written above that
  29.         Terminal:reset()
  30.         Terminal:displayFromList(yPos,TEXT)
  31.         Terminal:display(0,
  32.             "&c"..Terminal:makeSeperator("="),
  33.             " &dColors ~",
  34.             "&c"..Terminal:makeSeperator("="),
  35.             ""
  36.         )
  37.         Terminal:writeLine(Terminal.size.y,"&1[ArrowKeys] - scroll.  [Backspace] - exit.")
  38.         Terminal:writeLine(Terminal.size.y-1,"yPos: "..tostring(yPos))
  39.         local key = Terminal:waitForKey()
  40.         if key == 265 then -- up
  41.             yPos = yPos + 1
  42.             if yPos > yStart then
  43.                 yPos = yStart
  44.             end
  45.         elseif key == 264 then -- down
  46.             yPos = yPos - 1
  47.             if yPos < yStart-#TEXT+8 then
  48.                 yPos = yStart-#TEXT+8
  49.             end
  50.         end
  51.        
  52.     until key == 259 -- backspace
  53. end
  54.  
  55. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement