YAY you used spoilers! Thanks a bunch! Now the problems:
- You have two load functions (not a problem, but makes no sense)
- users is never declared, so it's treated as a global
- You never actually call load
- The unserialization is messed up
And the solutions:
- Remove the second load function
- Rename the load function to loadUsers (load in itself could mean anything)
- Insert local users before the first line
- Insert users = loadUsers() after declaring loadUsers
And about the unserialization - the
users file isn't unserializable, because it's an actual program. You have two options:
- Have some properly serialized table in the users file
That would require you to throw together the
users file like this:
{
users = {user1 = "admin", user2 = "2nd"},
pass1 = {pass1 = "pass", pass2 = "2nd"}
}
And you would access that in the program like this:
if user == users.users[i] and pass == users.pass1[i] then
- Or load users with some function environment magic:
That would require you to get rid of the
locals in the
users file, and the
loadUsers function would look like this:
local function loadUsers()
local env = {}
setfenv(loadfile("users"), env)()
return env
end
Of course, you'd have to access the data the same way you would do with the properly serialized table.