Advertisement
Marlingaming

CC Tweaked CCSPS Iron - Settings Menu

Jan 25th, 2022 (edited)
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. local AllowedSettings = {"os_DesktopLoc","NetworkAccess","ClientAppFolder","AdminKey","Files","reinstall"}
  2.  
  3. local options = AllowedSettings
  4. options[#options + 1] = "exit"
  5.  
  6. settings.load(".settings")
  7.  
  8. local function Clear()
  9. term.clear()
  10. term.setCursorPos(1,1)
  11. end
  12.  
  13. function CUI(m,y) --declare function
  14. n=1
  15. local l = #m
  16. while true do
  17. term.setCursorPos(1,y)
  18. for i=1, #m, 1 do --traverse the table of options
  19. if i==n and m[n] == "exit" then term.clearLine() print(i, ">exit") elseif i==n then term.clearLine() print(i, ">",m[i]," = ",settings.get(m[i])) elseif m[i] == "exit" then term.clearLine() print(i,"-exit") else term.clearLine() print(i, "-", m[i]," = ",settings.get(m[i])) end --print them
  20. end
  21. a, b= os.pullEvent("key") --wait for keypress
  22. if b==keys.w and n>1 then n=n-1 end
  23. if b==keys.s and n<l then n=n+1 end
  24. if b==keys.enter then break end
  25. end
  26. return n --return the value
  27. end
  28.  
  29. function SettingMenu(I)
  30. local Details = settings.getDetails(AllowedSettings[I])
  31. Clear()
  32. print("Edit")
  33. print(AllowedSettings[I])
  34. print(settings.get(AllowedSettings[I]))
  35. print("press enter to save")
  36. local input
  37. while true do
  38. local event = {os.pullEvent("key")}
  39. if event[2] == keys.enter then break end
  40. input = read()
  41. end
  42.  
  43. if input == "true" then
  44. settings.set(AllowedSettings[I],true)
  45. elseif input == "false" then
  46. settings.set(AllowedSettings[I],false)
  47. else
  48. if settings.get(AllowedSettings[I]) == true then
  49. settings.set(AllowedSettings[I],false)
  50. elseif settings.get(AllowedSettings[I]) == false then
  51. settings.set(AllowedSettings[I],true)
  52. else
  53. settings.set(AllowedSettings[I],input)
  54. end
  55. end
  56. DrawMenu()
  57. end
  58.  
  59. function DrawMenu()
  60. term.setBackgroundColor(colors.lightGray)
  61. Clear()
  62. print("settings menu")
  63. local n = CUI(options,2)
  64. if options[n] == "exit" then
  65. settings.save(".settings")
  66. elseif options[n] == "Files" then
  67. shell.run("os/System/Programs/FileSystemNavigator")
  68. elseif options[n] == "reinstall" then
  69. shell.run("pastebin","run","hyuJKatc")
  70. else
  71. SettingMenu(n)
  72. end
  73. end
  74.  
  75. DrawMenu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement