Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --APIs
- os.pullEvent = os.pullEventRaw
- os.loadAPI("/DZSystem/API/Color")
- --Variables
- local quit, user, registered = false
- local name, pass, passCnfrm = nil
- local usersDir = "/DZSystem/users/"
- local regStr = "Registration"
- local authStr = "Authorization"
- local program = "V 1.0"
- --Functions
- local function clr(color,str)
- term.setBackgroundColor(color)
- term.setCursorPos(1,1)
- term.clear()
- print(str)
- for i=1,50 do
- if i == 50 then
- print("-")
- else
- write("-")
- end
- end
- end
- repeat
- clr(Color.Lime,program)
- print("Do you have account?")
- print("Y\N")
- local event, key = os.pullEvent()
- until (key == keys.y) or (key == keys.n)
- if key == keys.y then
- --Begin Registration
- repeat --begin
- clr(Color.Lime,regStr)
- write("Enter your name: ")
- name = read()
- user = fs.exists(usersDir..name)
- if user == true then
- clr(Color.Lime,regStr)
- print("User already registered!")
- print("Try another name.")
- sleep(1)
- else
- quit = true
- end
- until quit == true --end
- quit = false
- print("Ok!")
- sleep(1)
- quit = true
- repeat --begin
- clr(Color.Lime,regStr)
- write("Enter your password: ")
- pass = read("*")
- write("Confirm your password: ")
- passCnfrm = read("*")
- if pass == passCnfrm then
- print("Ok!")
- sleep(1)
- quit = true
- else
- quit = false
- clr(Color.Lime,regStr)
- print("Incorrect password!")
- sleep(1)
- end
- until quit == true --end
- file = fs.open(usersDir..name,"a")
- --file.writeLine(name)
- file.writeLine(pass)
- file.close()
- sleep(2)
- --End Registration
- else
- --Begin Authorization
- quit = false
- repeat --begin
- clr(Color.Lime,authStr)
- write("Enter your name: ")
- name = read()
- user = fs.exists(usersDir..name)
- if user == true then
- print("Ok!")
- file = fs.open(usersDir..name,"r")
- passCnfrm = file.readLine()
- file.close()
- sleep(1)
- quit = true
- else
- clr(Color.Lime,authStr)
- print("User is not exists! Try again.")
- sleep(1)
- end
- until quit == true --end
- quit = false
- repeat
- clr(Color.Lime,authStr)
- write("Enter your password: ")
- pass = read()
- if pass == passCnfrm then
- print("Ok!")
- sleep(3)
- quit = true
- else
- clr(Color.Lime,authStr)
- print("Incorrect password!")
- sleep(1)
- end
- until quit == true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement