Posted 06 October 2014 - 07:13 AM
hello,
Today i was trying to make a registery for my password login program only thing is im totally new at this stuff so im not sure how to make the registery.. i have the login all down good even added effects
but i wanted to take one step forward and make it so when you first run file/startup it will ask you what you want your username to be then your password also when you run the program again i need it to not re-register a new user.
i was thinking of making it part of startup and then have a if true/false statment so that it wont run that part of the program and go straight into logging in. so this makes is unhackable also the registery program on a disk so that i can add people to my computer if i want to also use that to edit my username and password.
knowing this i will have to redo my whole login program which im fine with but i need a bit of understanding on the registering part cause this one doesn't work.
Today i was trying to make a registery for my password login program only thing is im totally new at this stuff so im not sure how to make the registery.. i have the login all down good even added effects
but i wanted to take one step forward and make it so when you first run file/startup it will ask you what you want your username to be then your password also when you run the program again i need it to not re-register a new user.
i was thinking of making it part of startup and then have a if true/false statment so that it wont run that part of the program and go straight into logging in. so this makes is unhackable also the registery program on a disk so that i can add people to my computer if i want to also use that to edit my username and password.
os.pullEvent = os.pullEventRaw
term.setBackgroundColour(colours.white)
term.clear()
term.setTextColour(colours.grey)
local user = ""
local pass = ""
local i = 2
term.setCursorPos(3, 3)
print(" running Applied-TechSecureure Startup 5.5V)
sleep(3)
term.clear()
term.setCursorPos(1, 1)
print(" Applied-TechSecure Startup")
term.setCursorPos(2, 2)
write(" Username: ")
input = read("*")
if input == user then
else
term.setCursorPos(6, 8)
print(" Please Wait...")
sleep(3)
term.setCursorPos(6, 8)
print(" Username is incorrect")
sleep(3)
term.clear()
shell.run("startup")
end
term.setCursorPos(3, 3)
write(" Password: ")
input = read("*")
term.clear()
term.setCursorPos(6, 8)
print(" Please Wait...")
sleep(3)
if input == pass then
else
term.setCursorPos(6, 8)
print(" Password is incorrect")
sleep(3)
term.clear()
term.setCursorPos(6, 8)
print(" Try Again Later")
sleep(4)
shell.run("startup")
end
NOTE: this is my username and login with no registery
local userFile
local passwordFile
local users = {}
local passwords = {}
local passwordEntered
local userEntered
local userNum = 0
local lineRead
local registerUser = ""
local registerPassword = ""
local confirmPassword = ""
local regUser
local regPassword
local curY1
local curY2
function RegisterUser()
readUsersAndPasswords()
textutils.slowPrint("Please enter your desired username: ", 20)
registerUser = read()
RegisterPassword()
end
function RegisterPassword()
textutils.slowPrint("Please enter your desired password: ", 20)
registerPassword = read("*")
textutils.slowPrint("Please confirm your password: ", 20)
confirmPassword = read("*")
if registerPassword == confirmPassword then
textutils.slowPrint("Passwords match.", 20)
fs.makeDir("passwordFolder")
regUser = fs.open("passwordFolder/users","a")
regPassword = fs.open("passwordFolder/passwords","a")
regUser.writeLine(registerUser)
regPassword.writeLine(registerPassword)
regUser.close()
regPassword.close()
readUsersAndPasswords()
textutils.slowPrint("User registered.", 20)
else
textutils.slowPrint("Passwords missmatch. Please try again: ", 20)
regUser.close()
regPassword.close()
RegisterPassword()
end
end
function readUsersAndPasswords()
fs.makeDir("passwordFolder")
regUser = fs.open("passwordFolder/users","a")
regPassword = fs.open("passwordFolder/passwords","a")
regUser.close()
regPassword.close()
users = {}
passwords = {}
userFile = fs.open("passwordFolder/users","r")
passwordFile = fs.open("passwordFolder/passwords","r")
lineRead = userFile.readLine()
repeat
table.insert(users,lineRead)
lineRead = userFile.readLine()
until lineRead == nil
lineRead = passwordFile.readLine()
repeat
table.insert(passwords,lineRead)
lineRead = passwordFile.readLine()
until lineRead == nil
passwordFile.close()
userFile.close()
end
function password()
textutils.slowPrint("Please enter your password "..users[userNum], 20)
passwordEntered = read("*")
if passwordEntered == passwords[userNum] then
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint("Password match.", 20)
textutils.slowPrint("Welcome "..users[userNum], 20)
elseif passwordEntered == "retry" then
username()
else
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint("Password missmatch. Please try again.", 20)
textutils.slowPrint("Type 'retry' to enter a new username.", 20)
password()
end
end
function username()
userNum = 0
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint("Welcome", 20)
sleep(1)
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint("Please enter your username", 20)
userEntered = read()
for i=1, #users do
if userEntered == users[i] then
userNum = i
break
end
end
if userNum == 0 then
textutils.slowPrint("Username could not be recognized. Please try again", 20)
sleep(1)
username()
else
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint("Username recognized.", 20)
sleep(1)
term.clear()
term.setCursorPos(1,1)
password()
end
end
readUsersAndPasswords()
if users[1] == nil then
textutils.slowPrint("Welcome to your new password program!", 20)
textutils.slowPrint("Please register your admin user.", 20)
textutils.slowPrint("This user will be the admin for this system.", 20)
textutils.slowPrint("The admin is the only one with full access", 20)
textutils.slowPrint("to this system.", 20)
RegisterUser()
end
username()
if userNum ~= 1 then
end
NOTE: i did get this from another person but i was going to edit it for it to be compatible with my login programknowing this i will have to redo my whole login program which im fine with but i need a bit of understanding on the registering part cause this one doesn't work.
Edited on 06 October 2014 - 05:18 AM