Advertisement
Marlingaming

CC Tweaked CCSPS Iron - SettingsMenu_2 Touch compatible

Feb 3rd, 2022 (edited)
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. local AllowedSettings = {"os_DesktopLoc","NetworkAccess","ClientAppFolder","AdminKey","reinstall","exit"}
  2.  
  3.  
  4. settings.load(".settings")
  5.  
  6. local function Clear()
  7. term.clear()
  8. term.setCursorPos(1,1)
  9. end
  10.  
  11. local function LoadSettings()
  12. local file = fs.open("os/System/Files/SettingsMenu_Options.txt","r")
  13. AllowedSettings = textutils.unserialize(file.readAll())
  14. file.close()
  15. AllowedSettings[#AllowedSettings + 1] = "exit"
  16. end
  17.  
  18. function CUI(m,y) --declare function
  19. n=0
  20. local l = #m
  21. while true do
  22. a, b, c, d= os.pullEvent("mouse_click") --wait for keypress
  23. for i = 1, #AllowedSettings do
  24. if d == i * 2 then n = i end
  25. end
  26. if n > 0 then break end
  27. end
  28. return n --return the value
  29. end
  30.  
  31. function DrawButtons()
  32. Clear()
  33. for i = 1, #AllowedSettings do
  34. print("==========================")
  35. print("[",AllowedSettings[i],"]")
  36. end
  37. end
  38.  
  39.  
  40. function SettingMenuButton(I)
  41.  
  42. settings.load(".settings")
  43. local Details = settings.getDetails(AllowedSettings[I])
  44. term.setBackgroundColor(colors.lightGray)
  45. Clear()
  46. print("Edit")
  47. print(AllowedSettings[I])
  48. print(settings.get(AllowedSettings[I]))
  49. local n = 1
  50. while true do
  51. term.setCursorPos(1,5)
  52. term.clearLine()
  53. if n == 1 then term.write("[ true ] or false") else term.write("true or [ false ]") end
  54. local event, key = os.pullEvent("key")
  55. if key == keys.a then n = 1 end
  56. if key == keys.d then n = 2 end
  57. if key == keys.enter then break end
  58. end
  59.  
  60. if n == 1 then
  61. settings.set(AllowedSettings[I],true)
  62. elseif n == 2 then
  63. settings.set(AllowedSettings[I],false)
  64. end
  65. settings.save(".settings")
  66. DrawMenu()
  67. end
  68.  
  69. function SettingMenu(I)
  70. settings.load(".settings")
  71. local Details = settings.getDetails(AllowedSettings[I])
  72. term.setBackgroundColor(colors.lightGray)
  73. Clear()
  74. print("Edit")
  75. print(AllowedSettings[I])
  76. print(settings.get(AllowedSettings[I]))
  77. print("press enter to save")
  78. local input
  79. while true do
  80. local event = {os.pullEvent("key")}
  81. if event[2] == keys.enter then break end
  82. input = read()
  83. end
  84.  
  85. if input == "true" then
  86. settings.set(AllowedSettings[I],true)
  87. elseif input == "false" then
  88. settings.set(AllowedSettings[I],false)
  89. else
  90. if settings.get(AllowedSettings[I]) == true then
  91. settings.set(AllowedSettings[I],false)
  92. elseif settings.get(AllowedSettings[I]) == false then
  93. settings.set(AllowedSettings[I],true)
  94. elseif input ~= nil then
  95. settings.set(AllowedSettings[I],input)
  96. end
  97. end
  98. settings.save(".settings")
  99. DrawMenu()
  100. end
  101.  
  102. function DrawMenu()
  103. term.setBackgroundColor(colors.lightGray)
  104. DrawButtons()
  105. local n = CUI(AllowedSettings,2)
  106. if AllowedSettings[n] == "exit" then
  107.  
  108. elseif AllowedSettings[n] == "reinstall" then
  109. Clear()
  110. print("are you sure?")
  111. print("doing so will delete all files except for your user profile")
  112. print("y/n")
  113. local event, key
  114. repeat
  115. event, key = os.pullEvent("key")
  116. until key == keys.y or key == keys.n
  117. if key == keys.y then
  118. shell.run("pastebin","run","BCCRGYMR")
  119. else
  120. DrawMenu()
  121. end
  122. elseif AllowedSettings[n] == "changeVersion" then
  123. shell.run("os/System/Programs/UpdateMenu.lua")
  124. else
  125. if settings.get(AllowedSettings[n]) == true or settings.get(AllowedSettings[n]) == false then
  126. SettingMenuButton(n)
  127. else
  128. SettingMenu(n)
  129. end
  130. end
  131. end
  132.  
  133. LoadSettings()
  134. DrawMenu()
  135.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement