How do I do that?
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
How To Read A Password From A Different File?
Started by SNWLeader, 11 November 2013 - 04:04 PMPosted 11 November 2013 - 05:04 PM
I am trying to get a passcode from a different file.
How do I do that?
How do I do that?
Posted 11 November 2013 - 05:54 PM
Use the FS API.
local handle = fs.open(filePath, "r")
local passcode = handle.readAll()
handle.close()
Posted 11 November 2013 - 06:22 PM
Use the FS API.local handle = fs.open(filePath, "r") local passcode = handle.readAll() handle.close()
great now how do I use this.
Posted 11 November 2013 - 08:12 PM
Did you read the wiki article? What are you using this for specifically?
Posted 12 November 2013 - 12:27 AM
Use what Yevano said for making the pass a variable
To use it in a program:
Sorry if it's a little messy or wrong, I'm on my iPad.
Use the FS API.local handle = fs.open(filePath, "r") local passcode = handle.readAll() handle.close()
To use it in a program:
local handle = fs.open(filePath, "r") --loads the pass with read permissions
local passcode = handle.readAll() --takes the pass file above and reads it
handle.close() --closes the file
write("Password: ") --asks for the pass
iPass = read() --reads the input
if iPass == passcode then --checks if the input pass matches the file
print("Correct") --if it did
else --if the user input was anything else
print("Denied") --if it didn't
end --closes the if
Sorry if it's a little messy or wrong, I'm on my iPad.
Posted 19 November 2013 - 09:27 PM
That is alright, and it works just perfectly. :D/>
Thanks guys.
Thanks guys.
Posted 20 November 2013 - 03:25 AM
Just what I needed too. Always glad for the invention of the forum and the ability to solve problems by looking at what other people did.