Posted 24 May 2014 - 04:04 PM
So, I'm trying to make a log-in system for a program, and I would like to be able to have a separate file, containing the users' usernames and passwords, in a lua-array style, kind of like this:
This file would be called "users", and it would reside under "/misc"
As you could guess, the password for the "firstuser" account is "foo".
I would like to be able to load this array into a separate file, to be able to achieve this:
This file would be my startup file
Any help is really appreciated :)/>
This file would be called "users", and it would reside under "/misc"
users = { }
user.firstuser = "foo"
user.seconduser = "bar"
user.thirduser = "baz"
As you could guess, the password for the "firstuser" account is "foo".
I would like to be able to load this array into a separate file, to be able to achieve this:
This file would be my startup file
users = <whatever should go here in order to load the "users" array from "/misc/users">
io.write("Username: ")
local username = io.read():lower()
io.write("Password: ")
local password = io.read("*")
if users[username] == nil then
print("Could not find said account")
return false
elseif users[username] == password then
print("Welcome, " .. username. . "!")
return true
else
print("Your password is incorrect...")
return false
end
Any help is really appreciated :)/>