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

[LUA][password lock] Help please :D

Started by predatorxil, 22 October 2012 - 03:10 AM
predatorxil #1
Posted 22 October 2012 - 05:10 AM
Hello, im trying to add to my login program. What im trying to do is make it so i can change passwords for users without having to do "edit startup". i just need help getting started in makeing it. here's waht i got.


local sPath = ":/rom/programs"
term.clear()
term.setCursorPos(1,1)
print("==========================================================")
term.setCursorPos(1,2)
textutils.slowPrint("		   Welcome to R.S. Incorporated		   ")
term.setCursorPos(1,3)
print("=========================================================")
term.setCursorPos(1,5)
print("Users: ")
term.setCursorPos(1,6)
textutils.slowPrint("- predatorxil  - nexoigi")
term.setCursorPos(1,7)
textutils.slowPrint("- axel1298	 - ztrevetty88")
term.setCursorPos(1,8)
textutils.slowPrint("- coolwater97")
term.setCursorPos(1,9)
print("==========================================================")
term.setCursorPos(1,4)
textutils.slowPrint("Os Version 3.1")
term.setCursorPos(1,10)
textutils.slowPrint("Message: Enter UserName")
term.setCursorPos(1,11)
os.pullEvent = os.pullEventRaw
local tries = 0
local tUsers = {}
tUsers["predatorxil"] = "13034"
tUsers["nexoigi"] = "999"
tUsers["coolwater97"] = "sarah1157"
tUsers["axel1298"] = "999"
while true do
    write("Username: ")
    name = read()
    if tUsers[name] then
   term.setCursorPos(10,10)
   textutils.slowPrint("Enter Password")
		    term.setCursorPos(1,12)
		    write("Password: ")
		    pass = read("*")
		    if tUsers[name] == pass then
	 term.setCursorPos(10,10)
	 textutils.slowPrint("Access Approved")
	 sleep(.5)
	 rs.setOutput("back", true)
	 sleep(5)
	 rs.setOutput("back", false)
	 sleep(1)
	 os.reboot()
				 else
				    if tries < 3 then
					    term.setCursorPos(10,10)
					    textutils.slowPrint("Access Denied ")
					    sleep(2)
					    tries = tries +1
				    else
					    print("Tries Exceeded 3")
					    print("Entering cooldown cycle")
					    sleep(30)
					    os.reboot()
					 end
				  end
		    end
end	 
					
			
























PixelToast #2
Posted 22 October 2012 - 06:26 AM
sooo…. any errors?
remiX #3
Posted 22 October 2012 - 08:52 AM
Make a thing when they are logged in with an option to change passwords. I'm not quite sure what you want to do.
bloodless2010 #4
Posted 22 October 2012 - 07:57 PM
Have a directory(folder) called users, and in that have files with the username for players, and in that file have the text (their password) and with this system you can add users add you will manually of use the fs function, you could make it so you can change the password ect, I wouldn't know how to do it myself but I know its possible using the fs function (I'm terrible at file opening and writing XD)