Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local AllowedSettings = {"os_DesktopLoc","NetworkAccess","ClientAppFolder","AdminKey","reinstall","exit"}
- settings.load(".settings")
- local function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- local function LoadSettings()
- local file = fs.open("os/System/Files/SettingsMenu_Options.txt","r")
- AllowedSettings = textutils.unserialize(file.readAll())
- file.close()
- AllowedSettings[#AllowedSettings + 1] = "exit"
- end
- function CUI(m,y) --declare function
- n=0
- local l = #m
- while true do
- a, b, c, d= os.pullEvent("mouse_click") --wait for keypress
- for i = 1, #AllowedSettings do
- if d == i * 2 then n = i end
- end
- if n > 0 then break end
- end
- return n --return the value
- end
- function DrawButtons()
- Clear()
- for i = 1, #AllowedSettings do
- print("==========================")
- print("[",AllowedSettings[i],"]")
- end
- end
- function SettingMenuButton(I)
- settings.load(".settings")
- local Details = settings.getDetails(AllowedSettings[I])
- term.setBackgroundColor(colors.lightGray)
- Clear()
- print("Edit")
- print(AllowedSettings[I])
- print(settings.get(AllowedSettings[I]))
- local n = 1
- while true do
- term.setCursorPos(1,5)
- term.clearLine()
- if n == 1 then term.write("[ true ] or false") else term.write("true or [ false ]") end
- local event, key = os.pullEvent("key")
- if key == keys.a then n = 1 end
- if key == keys.d then n = 2 end
- if key == keys.enter then break end
- end
- if n == 1 then
- settings.set(AllowedSettings[I],true)
- elseif n == 2 then
- settings.set(AllowedSettings[I],false)
- end
- settings.save(".settings")
- DrawMenu()
- end
- function SettingMenu(I)
- settings.load(".settings")
- local Details = settings.getDetails(AllowedSettings[I])
- term.setBackgroundColor(colors.lightGray)
- Clear()
- print("Edit")
- print(AllowedSettings[I])
- print(settings.get(AllowedSettings[I]))
- print("press enter to save")
- local input
- while true do
- local event = {os.pullEvent("key")}
- if event[2] == keys.enter then break end
- input = read()
- end
- if input == "true" then
- settings.set(AllowedSettings[I],true)
- elseif input == "false" then
- settings.set(AllowedSettings[I],false)
- else
- if settings.get(AllowedSettings[I]) == true then
- settings.set(AllowedSettings[I],false)
- elseif settings.get(AllowedSettings[I]) == false then
- settings.set(AllowedSettings[I],true)
- elseif input ~= nil then
- settings.set(AllowedSettings[I],input)
- end
- end
- settings.save(".settings")
- DrawMenu()
- end
- function DrawMenu()
- term.setBackgroundColor(colors.lightGray)
- DrawButtons()
- local n = CUI(AllowedSettings,2)
- if AllowedSettings[n] == "exit" then
- elseif AllowedSettings[n] == "reinstall" then
- Clear()
- print("are you sure?")
- print("doing so will delete all files except for your user profile")
- print("y/n")
- local event, key
- repeat
- event, key = os.pullEvent("key")
- until key == keys.y or key == keys.n
- if key == keys.y then
- shell.run("pastebin","run","BCCRGYMR")
- else
- DrawMenu()
- end
- elseif AllowedSettings[n] == "changeVersion" then
- shell.run("os/System/Programs/UpdateMenu.lua")
- else
- if settings.get(AllowedSettings[n]) == true or settings.get(AllowedSettings[n]) == false then
- SettingMenuButton(n)
- else
- SettingMenu(n)
- end
- end
- end
- LoadSettings()
- DrawMenu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement