Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Add Accounts File
- Written by TheShadow989
- ]]--
- os.pullEvent = os.pullEventRaw
- os.loadAPI("xos/api/sha256")
- local verNumber = "Alpha 1.24"
- local x = term.getSize()
- rRead = fs.open("xos/.usertable", "r")
- users = textutils.unserialize(rRead.readAll())
- rRead.close()
- cu = tonumber(users[1])
- cs = tonumber(users[cu+1])
- cp = tonumber(users[cu+2])
- local function cPrint(string)
- x, _ = term.getSize()
- _, y = term.getCursorPos()
- term.setCursorPos((x-#string)/2,y)
- textutils.slowPrint(string)
- end
- local function kPrint(string)
- x, _ = term.getSize()
- _, y = term.getCursorPos()
- term.setCursorPos((x-#string)/2,y)
- print(string)
- end
- local function errormsg()
- term.clear()
- term.setCursorPos(1,19)
- term.write("xOS "..verNumber.." by TheShadow989")
- term.setCursorPos(1,3)
- kPrint("Create Account")
- term.setCursorPos(11,8)
- end
- term.clear()
- term.setCursorPos(1,19)
- term.write("xOS "..verNumber.." by TheShadow989")
- term.setCursorPos(1,3)
- cPrint("Create Account")
- sleep(2)
- while true do
- term.setCursorPos(17,8)
- write("Username: ")
- newuser = read()
- userlenght = string.len(newuser)
- if userlenght >= 10 then
- errormsg()
- term.setTextColor( colors.red )
- kPrint("Username must be between 1-9 characters!")
- term.setTextColor( colors.white )
- sleep(3)
- errormsg()
- else
- break
- end
- end
- while true do
- term.setCursorPos(17,8)
- write("Username: "..newuser)
- term.setCursorPos(17,10)
- write("Password: ")
- newpass = read('*')
- term.setCursorPos(17,12)
- write("Re-enter Password: ")
- newpass2 = read('*')
- if newpass ~= newpass2 then
- errormsg()
- term.setTextColor( colors.red )
- kPrint("Passwords entered do not match!")
- term.setTextColor( colors.white )
- sleep(3)
- errormsg()
- else
- break
- end
- end
- newseclvl = "1"
- if users[5] == nil then
- users[5] = newuser
- users[6] = newseclvl
- users[7] = sha256.sha256(newpass)
- elseif users[8] == nil then
- users[8] = newuser
- users[9] = newseclvl
- users[10] = sha256.sha256(newpass)
- elseif users[11] == nil then
- users[11] = newuser
- users[12] = newseclvl
- users[13] = sha256.sha256(newpass)
- end
- rWrite = fs.open("xos/.usertable", "w")
- rWrite.write(textutils.serialize(users))
- rWrite.close()
- term.clear()
- term.setTextColor(colors.green)
- term.setCursorPos(11,8)
- kPrint("Account Created, Rebooting!")
- sleep(3)
- os.reboot()
Add Comment
Please, Sign In to add comment