Posted 22 March 2017 - 11:23 PM
Hi, I'm trying to create a login and register system for my upcoming OS. But it seems I made an error somewhere:
When I try to register, it says "program not found" waits 5 seconds and brings me back to the login screen. I haven't even tested the login function yet.
term.setBackgroundColor(colors.gray)
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.white)
shell.run("/lib/back/screen")
term.setCursorPos(17,6)
user = read()
term.setCursorPos(17,8)
pass = read('*')
while true do
event, whichone, x, y = os.pullEvent("mouse_click")
if x == 7 and y == 11 then
if fs.exists("/lib/users/"..user) then
file = fs.open("/lib/users/"..user,"r")
file.readLine()
if pass == file.readLine then
shell.run("/system/menu")
else
shell.run("/system/login")
file.close()
end
else
term.setCursorPos(17,8)
print("Pass incorrect")
term.setCursorPos(17,6)
print("No user or")
sleep(0.5)
shell.run("/system/login")
end
elseif x == 7 and y == 13 then
if fs.exists("/lib/users/"..user) then
term.setCursorPos(17,6)
print("User exists")
sleep(0.5)
shell.run("/system/userval")
else
shell.run("cd /lib/users")
file = fs.open(user, "w")
file.writeLine(pass)
file.close()
term.setCursorPos(17,6)
print("Registered!")
sleep(5)
shell.run("/system/login")
end
end
end
Edited on 23 March 2017 - 09:26 AM