Posted 09 April 2018 - 06:06 PM
Hey there, I'm having trouble with reading a file and making it a variable so I can display the username.
So to give you more info I have a password system I'm trying to create with an ability to ask for one's name and pass. which then are put on the table like so.
The trouble I'm having is actually making the serialized table become variable I can use in print or a statement.
I took out what I thought I could use help or some advice on. I'm honestly just trying to get the name, copy it into a table named USERS.txt then go open it with it only asking for a password, and displays the name.
any help would be appreciated :)/>
{
{
name = "Vyse",
pass = "test",
},
}
how the table is inside the file.So to give you more info I have a password system I'm trying to create with an ability to ask for one's name and pass. which then are put on the table like so.
The trouble I'm having is actually making the serialized table become variable I can use in print or a statement.
local function SecureV()
term.setCursorPos(2, 19)
write("username"..Tbe.user)
end
local function reg( user )
local tbl = {}
table.insert(tbl, user)
local f = fs.open("saves/USERS.txt", "w")
f.write(textutils.serialize(tbl))
f.close()
end
local function Regist()
if fs.exists("saves/USERS.txt") == false then
local user = {}
user.name = read()
user.pass = read("*")
reg( user )
else
print('starting..")
end
end
local function login()
local s = fs.open("saves/USER.txt", "r")
Tbe = textutils.unserialize(s.readAll())
s.close()
local Tbe = {}
local user1 = Tbe.user
local pass1 = Tbe.pass
local password = read("*")
if password == pass1 then
redstone.setOutput("right", true)
sleep(2)
redstone.setOutput("right", false)
else
print("incorrect")
end
end
Regist()
login()
I took out what I thought I could use help or some advice on. I'm honestly just trying to get the name, copy it into a table named USERS.txt then go open it with it only asking for a password, and displays the name.
any help would be appreciated :)/>
Edited on 09 April 2018 - 04:16 PM