Posted 09 September 2016 - 04:02 AM
Hey there! So I'm trying to set up a little system where each user is set up with a password, and I'm trying to read out the values just to make sure everything's working out okay. So far I have things set up like so:
This results in a serialised table that looks something like
I've then proceeded to unserialise this file in another program, and have written the following code:
This returns:
How do I break this down into showing the usernames and passwords separately? For instance:
usrtable = {}
usrtable[1]={usr="User1", pass="pass1"},
usrtable[2]={usr="User2", pass="pass2"},
usrtable[3]={usr="User3", pass="pass3"},
--etc etc
file=fs.open("user", "w")
file.write(textutils.serialise(usrtable))
file.close()
This results in a serialised table that looks something like
{
{
usr="User1",
pass="pass1",
},
{
usr="User2",
pass="pass2",
},
{
usr="User3",
pass="pass3",
},
}
I've then proceeded to unserialise this file in another program, and have written the following code:
for _, v in pairs(usertable) do
for _, u in pairs (v) do
print(u)
end
end
This returns:
User1
pass1
User2
pass2
User3
pass3
How do I break this down into showing the usernames and passwords separately? For instance:
"User: "..user.." Pass: "..pass
Edited on 09 September 2016 - 02:03 AM