Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function changeLock(uname)
- func.clear(uname)
- local lSel = 1
- local i = 0
- local lockz = true
- while lockz do
- local menu = {"Back", "10 Seconds", "20 Seconds", "30 Seconds", "40 Seconds", "50 Seconds", "60 Seconds"}
- tMenu = menu
- func.drawRect(1, 1, w, 1, tbCol)
- func.drawCenteredX("Choose New Lockout Time", 1, tbCol, txCol)
- func.drawTableCentered(menu, tbxCol, txCol, lSel, uname)
- local keyPress = func.getMenuKey()
- if keyPress ~=2 then
- if (keyPress == 1 and lSel > 1) or (keyPress == -1 and lSel < #menu) then
- lSel = lSel - keyPress
- end
- else
- local file = fs.open(usrPath .. uname .. "/settings", "r")
- local data = file.readAll()
- file.close()
- os.loadAPI(usrPath .. uname .. "/settings")
- local curTime = settings.lockout
- os.unloadAPI(usrPath .. uname .. "/settings")
- if lSel == 1 then
- lockz = false
- elseif lSel == 2 then
- newTime = 10
- elseif lSel == 3 then
- newTime = 20
- elseif lSel == 4 then
- newTime = 30
- elseif lSel == 5 then
- newTime = 40
- elseif lSel == 6 then
- newTime = 50
- elseif lSel == 7 then
- newTime = 60
- end
- data = string.gsub(data, "lockout = " .. curTime, "lockout = " .. newTime)
- file = fs.open(usrPath .. uname .. "/settings", "w")
- file.write(data)
- file.close()
- lockz = false
- end
- end
- end
- function users(uname)
- func.clear(uname)
- local lSel = 1
- local i = 0
- local use = true
- os.unloadAPI(regPath .. "usr")
- local file = fs.open(regPath .. "usr", "r")
- local data = file.readAll()
- file.close()
- local menu = {}
- while use do
- --is an admin
- if string.find(data, uname .. " = 2") then
- menu = {"Back", "Change Password", "Lockout Time", "Add User", "Remove User"}
- --is not an admin
- else
- menu = {"Back", "Change Password", "Lockout Time"}
- end
- func.drawRect(1, 1, w, 1, tbCol)
- func.drawCenteredX("User Settings", 1, tbCol, txCol)
- func.drawTableCentered(menu, tbxCol, txCol, lSel, uname)
- local keyPress = func.getMenuKey()
- if keyPress ~=2 then
- if (keyPress == 1 and lSel > 1) or (keyPress == -1 and lSel < #menu) then
- lSel = lSel - keyPress
- end
- else
- if lSel == 1 then
- use = false
- --change password
- elseif lSel == 2 then
- func.clear(uname)
- cred.pChange(uname)
- --change lockout time
- elseif lSel == 3 then
- changeLock(uname)
- func.clear(uname)
- --add user
- elseif lSel == 4 then
- if uname == "Admin" or cred.verify(uname) then
- cred.register()
- end
- func.clear(uname)
- --remove user
- elseif lSel == 5 then
- cred.remove(uname)
- func.clear(uname)
- end
- end
- end
- end
- function colorChoose(uname)
- func.clear(uname)
- local lSel = 1
- local i = 0
- local col = true
- while col do
- menu = {"Back", "White", "Orange", "Magenta", "Light Blue", "Yellow", "Lime", "Pink", "Gray", "Light Gray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black"}
- tMenu = menu
- func.drawRect(1, 1, w, 1, tbCol)
- func.drawCenteredX("Choose a Color", 1, tbCol, txCol)
- func.drawTableCentered(menu, tbxCol, txCol, lSel, uname)
- local keyPress = func.getMenuKey()
- if keyPress ~=2 then
- if (keyPress == 1 and lSel > 1) or (keyPress == -1 and lSel < #menu) then
- lSel = lSel - keyPress
- end
- else
- if lSel == 1 then
- local cols = {func.getCol(uname)}
- func.clear(uname)
- return cols[5]
- --white
- elseif lSel == 2 then
- func.clear(uname)
- return colors.white
- --orange
- elseif lSel == 3 then
- func.clear(uname)
- return colors.orange
- --magenta
- elseif lSel == 4 then
- func.clear(uname)
- return colors.magenta
- --light blue
- elseif lSel == 5 then
- func.clear(uname)
- return colors.lightBlue
- --yellow
- elseif lSel == 6 then
- func.clear(uname)
- return colors.yellow
- --lime
- elseif lSel == 7 then
- func.clear(uname)
- return colors.lime
- --pink
- elseif lSel == 8 then
- func.clear(uname)
- return colors.pink
- --gray
- elseif lSel == 9 then
- func.clear(uname)
- return colors.gray
- --light gray
- elseif lSel == 10 then
- func.clear(uname)
- return colors.lightGray
- --cyan
- elseif lSel == 11 then
- func.clear(uname)
- return colors.cyan
- --purple
- elseif lSel == 12 then
- func.clear(uname)
- return colors.purple
- --blue
- elseif lSel == 13 then
- func.clear(uname)
- return colors.blue
- --brown
- elseif lSel == 14 then
- func.clear(uname)
- return colors.brown
- --green
- elseif lSel == 15 then
- func.clear(uname)
- return colors.green
- --red
- elseif lSel == 16 then
- func.clear(uname)
- return colors.red
- --black
- elseif lSel == 17 then
- func.clear(uname)
- return colors.black
- end
- end
- end
- end
- function colSet(uname, tb, bg, tx, tbx, stx)
- local file = fs.open(usrPath .. uname .. "/settings", "r")
- local data = file.readAll()
- file.close()
- os.loadAPI(usrPath .. uname .. "/settings")
- data = string.gsub(data, "tbCol = " .. settings.tbCol, "tbCol = " .. tb)
- data = string.gsub(data, "bgCol = " .. settings.bgCol, "bgCol = " .. bg)
- data = string.gsub(data, "txCol = " .. settings.txCol, "txCol = " .. tx)
- data = string.gsub(data, "tbxCol = " .. settings.tbxCol, "tbxCol = " .. tbx)
- data = string.gsub(data, "stxCol = " .. settings.stxCol, "stxCol = " .. stx)
- os.unloadAPI(usrPath .. uname .. "/settings")
- file = fs.open(usrPath .. uname .. "/settings", "w")
- file.write(data)
- file.close()
- end
- function color(uname)
- func.clear(uname)
- local lSel = 1
- local i = 0
- local col = true
- while col do
- if params.locale == "US" then
- menu = {"Back", "Taskbar Color", "Text Color", "Background Color", "Menu Color", "Selected Text Color"}
- else
- menu = {"Back", "Taskbar Colour", "Text Colour", "Background Colour", "Menu Colour", "Selected Text Colour"}
- end
- tMenu = menu
- func.drawRect(1, 1, w, 1, tbCol)
- func.drawCenteredX("Color Settings", 1, tbCol, txCol)
- func.drawTableCentered(menu, tbxCol, txCol, lSel, uname)
- local keyPress = func.getMenuKey()
- if keyPress ~=2 then
- if (keyPress == 1 and lSel > 1) or (keyPress == -1 and lSel < #menu) then
- lSel = lSel - keyPress
- end
- else
- if lSel == 1 then
- col = false
- --taskbar color
- elseif lSel == 2 then
- tbCol = colorChoose(uname)
- colSet(uname, tbCol, bgCol, txCol, tbxCol, stxCol)
- func.clear(uname)
- --text color
- elseif lSel == 3 then
- txCol = colorChoose(uname)
- colSet(uname, tbCol, bgCol, txCol, tbxCol, stxCol)
- func.clear(uname)
- --background color
- elseif lSel == 4 then
- bgCol = colorChoose(uname)
- colSet(uname, tbCol, bgCol, txCol, tbxCol, stxCol)
- func.clear(uname)
- --menu color
- elseif lSel == 5 then
- tbxCol = colorChoose(uname)
- colSet(uname, tbCol, bgCol, txCol, tbxCol, stxCol)
- func.clear(uname)
- elseif lSel == 6 then
- stxCol = colorChoose(uname)
- colSet(uname, tbCol, bgCol, txCol, tbxCol, stxCol)
- func.clear(uname)
- end
- end
- end
- end
- function programs(uname)
- func.clear(uname)
- local menu = prg.progs
- func.drawRect(1, 1, w, 1, tbCol)
- func.drawCenteredX("Programs", 1, tbCol, txCol)
- local lSel = 1
- local doit = true
- while doit do
- func.clear(uname)
- func.drawTableCentered(menu, tbxCol, txCol, lSel, uname)
- local keyPress = func.getMenuKey()
- if keyPress ~=2 then
- if (keyPress == 1 and lSel > 1) or (keyPress == -1 and lSel < #menu) then
- lSel = lSel - keyPress
- end
- else
- if lSel == 1 then
- doit = false
- --taskbar color
- elseif lSel == 2 then
- func.clear(uname)
- os.run({prgPath}, prgPath .. 'calcPlus')
- --text color
- elseif lSel == 3 then
- func.clear(uname)
- os.run({}, prgPath .. "ink")
- elseif lSel == 4 then
- func.clear(uname)
- os.run({rootPath}, prgPath .. "luaIDE")
- end
- end
- end
- end
- function recover(uname)
- func.clear(uname)
- local lSel = 1
- local doit = true
- menu = {"Back", "Keep User Data", "Lose User Data"}
- func.drawRect(1, 1, w, 1, tbCol)
- func.drawCenteredX("Recovery Options", 1, tbCol, txCol)
- while doit do
- func.drawTableCentered(menu, tbxCol, txCol, lSel, uname)
- local keyPress = func.getMenuKey()
- if keyPress ~=2 then
- if (keyPress == 1 and lSel > 1) or (keyPress == -1 and lSel < #menu) then
- lSel = lSel - keyPress
- end
- else
- if lSel == 1 then
- doit = false
- --taskbar color
- elseif lSel == 2 then
- recovery.recover(1)
- func.clear(uname)
- --text color
- elseif lSel == 3 then
- recovery.recover(2)
- func.clear(uname)
- end
- end
- end
- end
- function set(uname)
- tbCol, tbxCol, txCol, bgCol, stxCol = func.getCol(uname)
- func.clear(uname)
- local lSel = 1
- local i = 0
- local doit = true
- while doit do
- func.clear(uname)
- local menu = {}
- if params.locale == "US" then
- menu = {"Back", "Users", "Colors", "Recovery"}
- tMenu = menu
- else
- menu = {"Back", "Users", "Colours", "Recovery"}
- tMenu = menu
- end
- func.drawRect(1, 1, w, 1, tbCol)
- func.drawCenteredX("Settings", 1, tbCol, txCol)
- func.drawTableCentered(menu, tbxCol, txCol, lSel, uname)
- local keyPress = func.getMenuKey()
- if keyPress ~=2 then
- if (keyPress == 1 and lSel > 1) or (keyPress == -1 and lSel < #menu) then
- lSel = lSel - keyPress
- end
- else
- if lSel == 1 then
- doit = false
- --users
- elseif lSel == 2 then
- func.clear(uname)
- users(uname)
- --colors
- elseif lSel == 3 then
- func.clear(uname)
- color(uname)
- --recovery
- elseif lSel == 4 then
- func.clear(uname)
- recover(uname)
- end
- end
- end
- end
- function logged(uname)
- os.loadAPI(usrPath .. uname .. "/settings")
- bgCol = settings.bgCol
- tbCol = settings.tbCol
- txCol = settings.txCol
- tbxCol = settings.tbxCol
- stxCol = settings.stxCol
- _G.lockTime = settings.lockout
- os.unloadAPI(usrPath .. uname .. "/settings")
- _G.lockout = os.startTimer(lockTime)
- func.clear(uname)
- local lSel = 1
- local i = 0
- local log = true
- while log do
- local menu = {"Programs", "Settings", "Logout", "Shutdown", "Restart"}
- local tMenu = menu
- func.drawRect(1, 1, w, 1, tbCol)
- func.drawCenteredX("Logged in as " .. uname, 1, tbCol, txCol)
- func.drawTableCentered(menu, tbxCol, txCol, lSel, uname)
- local keyPress = func.getMenuKey()
- if keyPress ~=2 then
- if (keyPress == 1 and lSel > 1) or (keyPress == -1 and lSel < #menu) then
- os.cancelTimer(lockout)
- lockout = os.startTimer(lockTime)
- lSel = lSel - keyPress
- elseif keyPress == 3 then
- os.cancelTimer(lockout)
- lockout = os.startTimer(lockTime)
- tbCol, tbxCol, txCol, bgCol, stxCol = func.resetCol()
- func.clear(uname)
- log = false
- end
- else
- --programs
- if lSel == 1 then
- programs(uname)
- func.clear(uname)
- --settings
- elseif lSel == 2 then
- set(uname)
- tbCol, tbxCol, txCol, bgCol, stxCol = func.getCol(uname)
- func.clear(uname)
- os.cancelTimer(lockout)
- lockout = os.startTimer(lockTime)
- --logout
- elseif lSel == 3 then
- tbCol, tbxCol, txCol, bgCol, stxCol = func.resetCol()
- func.clear(uname)
- log = false
- --shutdown
- elseif lSel == 4 then
- func.shutdown()
- --restart
- elseif lSel == 5 then
- func.restart()
- end
- end
- end
- end
- function main()
- local mainSel = 1
- local i = 0
- local doit = true
- while doit do
- local menu = {"Login", "Shutdown"}
- local tMenu = menu
- func.drawRect(1, 1, w, 1, tbCol)
- func.drawCenteredX("Welcome to TestOS", 1, tbCol, txCol)
- func.drawTableCentered(menu, tbxCol, txCol, mainSel)
- local keyPress = func.getMenuKey()
- if keyPress ~= 2 then
- if (keyPress == 1 and mainSel > 1) or (keyPress == -1 and mainSel < #menu) then
- mainSel = mainSel - keyPress
- end
- else
- --login
- if mainSel == 1 then
- local log, uname = cred.login()
- if log then
- logged(uname)
- end
- --register
- elseif mainSel == 2 then
- cred.register()
- --shutdown
- elseif mainSel == 3 then
- func.shutdown()
- end
- end
- tbCol, tbxCol, txCol, bgCol, stxCol = func.resetCol()
- func.clear()
- end
- end
Add Comment
Please, Sign In to add comment