This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Feolthanos's profile picture

Login system not working

Started by Feolthanos, 22 March 2017 - 10:23 PM
Feolthanos #1
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:


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
  
  

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.
Edited on 23 March 2017 - 09:26 AM
Bomb Bloke #2
Posted 23 March 2017 - 02:40 AM
The "program not found" message is generated by one of your shell.run() calls. Basically it means you need to double check that the scripts you're trying to execute exist at the paths you've specified.
Feolthanos #3
Posted 23 March 2017 - 10:27 AM
Thanks for your response! The problem is now that the login function can't read the password file. And when I type something, the pixels around the letters become black, and the background is grey, how can I fix this ?
Bomb Bloke #4
Posted 23 March 2017 - 10:54 PM
term.clear() wipes the entire display, setting it to the current background colour.

The code you've provided here never sets the background to black. You'll need to review the other scripts this script calls.