Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local AllowedSettings = {"os_DesktopLoc","NetworkAccess","ClientAppFolder","AdminKey","Files","reinstall"}
- local options = AllowedSettings
- options[#options + 1] = "exit"
- settings.load(".settings")
- local function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function CUI(m,y) --declare function
- n=1
- local l = #m
- while true do
- term.setCursorPos(1,y)
- for i=1, #m, 1 do --traverse the table of options
- 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
- end
- a, b= os.pullEvent("key") --wait for keypress
- if b==keys.w and n>1 then n=n-1 end
- if b==keys.s and n<l then n=n+1 end
- if b==keys.enter then break end
- end
- return n --return the value
- end
- function SettingMenu(I)
- local Details = settings.getDetails(AllowedSettings[I])
- 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)
- else
- settings.set(AllowedSettings[I],input)
- end
- end
- DrawMenu()
- end
- function DrawMenu()
- term.setBackgroundColor(colors.lightGray)
- Clear()
- print("settings menu")
- local n = CUI(options,2)
- if options[n] == "exit" then
- settings.save(".settings")
- elseif options[n] == "Files" then
- shell.run("os/System/Programs/FileSystemNavigator")
- elseif options[n] == "reinstall" then
- shell.run("pastebin","run","hyuJKatc")
- else
- SettingMenu(n)
- end
- end
- DrawMenu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement