Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- side = "left"
- function save(usr,pass)
- h = fs.open("users/"..usr.."/password","w")
- h.writeLine(pass)
- h.close()
- end
- function check(usr,pass)
- if usr == "changeme" then
- return "admin"
- end
- if not fs.exists("users/"..usr.."/password") then
- return "nousr"
- end
- c = fs.open("users/"..usr.."/password","r")
- if pass == c.readLine() then
- return true
- else
- return false
- end
- end
- while true do
- term.clear()
- term.setCursorPos(1,1)
- term.write("Input Username: ")
- username = read()
- term.setCursorPos(1,2)
- term.write("Input Password: ")
- password = read("*")
- result = check(username,password)
- if result == true then
- redstone.setOutput(side,true)
- sleep(2)
- redstone.setOutput(side,false)
- elseif result == "admin" then
- term.clear()
- term.setCursorPos(1,1)
- term.write("Input new Account username: ")
- newUser = read()
- term.setCursorPos(1,2)
- term.write("Input passowrd for account "..newUser..": ")
- newPass = read("*")
- save(newUser,newPass)
- elseif result == false then
- print("Invalid password")
- sleep(2)
- elseif result == "nousr" then
- print("No such user")
- sleep(2)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment