1 posts
Posted 19 February 2013 - 05:24 AM
Ok so i am trying to make a password door, i have got all the door and password lock setup however i would like to know how i would be able to make it so the first tim they use the computer it asks them to set a password instead of me editing the code.
8543 posts
Posted 19 February 2013 - 06:41 AM
Split into new topic.
7 posts
Posted 19 February 2013 - 08:51 PM
local setpass
print("Please define your desired password:")
setpass = read()
clear()
7508 posts
Location
Australia
Posted 19 February 2013 - 08:55 PM
the best/easiest way to do it is to have a file, if the file doesn't exist, assume that its the programs first run. if the file exists, load the password from it. :)/>
24 posts
Posted 20 February 2013 - 04:23 AM
the best/easiest way to do it is to have a file, if the file doesn't exist, assume that its the programs first run. if the file exists, load the password from it. :)/>
Which, in code, would be something along the lines of:
Spoiler
if fs.exists("pass.wrd") then
local passfile = fs.open("pass.wrd", "r")
password = passfile.readLine()
passfile.close()
else
local passfile = fs.open("pass.wrd", "w")
print("Create your password and press Enter to confirm.")
password = read("*")
passfile.write(tostring(password))
passfile.close()
end
Of course this isn't very secure - but I'll leave you to figure that one out. ;)/>