Advertisement
Le_JuiceBOX

[OS] Options.lua

Jan 22nd, 2025 (edited)
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.08 KB | None | 0 0
  1. -- pRJuAk7m
  2. local Terminal = require("/terminal").new()
  3.  
  4.  
  5. function main()
  6.     list = {}
  7.     settings.load()
  8.     for i,settingName in pairs(settings.getNames()) do
  9.         local val = settings.get(settingName)
  10.         if type(val) == "table" then
  11.             table.insert(list,settingName.." = {")
  12.             Terminal:print(settingName.." = {")
  13.             for k,p in pairs(val) do
  14.                 if type(p) == "table" then
  15.                     table.insert(list," {")
  16.                     for k1,p1 in pairs(p) do
  17.                         table.insert(list,"   "..tostring(k1).." = &c"..tostring(p1))
  18.                     end
  19.                     table.insert(list," }")
  20.                 else
  21.                     table.insert(list,"   "..tostring(k).." = &c"..tostring(p))
  22.                 end
  23.             end
  24.             table.insert(list,"}")
  25.         else
  26.             table.insert(list,settingName.." = &c"..tostring(val))
  27.         end
  28.     end
  29.     local yStart = 5
  30.     local yPos = yStart
  31.     repeat
  32.         -- generate the list at yPos, which is incremented and decremented to choose the starting pos of list, header and info is written above that
  33.         Terminal:reset()
  34.         Terminal.output.setCursorPos(1,yPos)
  35.         for i, data in pairs(list) do
  36.             Terminal:print(data)
  37.         end
  38.         Terminal:display(0,
  39.             "&c"..Terminal:makeSeperator("="),
  40.             " &dOptions ~",
  41.             "&c"..Terminal:makeSeperator("="),
  42.             ""
  43.         )
  44.         Terminal:writeLine(Terminal.size.y,"&1[ArrowKeys] - scroll.  [Backspace] - exit.")
  45.         Terminal:writeLine(Terminal.size.y-1,"yPos: "..tostring(yPos))
  46.         local key = Terminal:waitForKey()
  47.         if key == 265 then -- up
  48.             yPos = yPos + 1
  49.             if yPos > yStart then
  50.                 yPos = yStart
  51.             end
  52.         elseif key == 264 then -- down
  53.             yPos = yPos - 1
  54.             if yPos < yStart-#list+8 then
  55.                 yPos = yStart-#list+8
  56.             end
  57.         end
  58.        
  59.     until key == 259 -- backspace
  60.     Terminal:reset()
  61. end
  62.  
  63.  
  64.  
  65. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement