Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function again()
- term.clear()
- term.setCursorPos(1,1)
- term.setCursorPos(14,7)
- print" Log in/create new user"
- term.setTextColor(colors.red)
- term.setBackgroundColor(colors.black)
- term.setCursorPos(12,9)
- print" New "
- term.setCursorPos(12,10)
- print" User "
- term.setCursorPos(33,9)
- print" Log "
- term.setCursorPos(33,10)
- print" In "
- term.setBackgroundColor(colors.white)
- local running=true
- while running==true do
- event,button,x,y = os.pullEvent("mouse_click")
- if (x>=33) and (x<=42) and (y>=9) and (y<=10) then
- shell.run"login"
- running=false
- elseif (x>=12) and (x<=18) and (y>=9) and (y<=10) then
- shell.run"NewUser"
- end
- end
- end
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setCursorPos(17,10)
- term.setTextColor(colors.red)
- print"Username:"
- term.setCursorPos(17,11)
- print"Password:"
- term.setCursorPos(26,10)
- term.setTextColor(colors.black)
- username=read()
- term.setCursorPos(26,11)
- password=read("*")
- if fs.exists("users/"..username) then
- file=fs.open("users/"..username,"r")
- local pass=file.readLine()
- if password==pass then
- print(" Loged in as " ..username)
- file.close()
- if fs.exists"loged-user" then
- fs.delete"loged-user"
- end
- local file=fs.open("loged-user","a")
- file.writeLine(username)
- file.close()
- sleep(3)
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- else
- print" Incorrect password"
- sleep(3)
- again()
- end
- else
- print" Unknown username"
- sleep(3)
- again()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement