Well, it's pretty simple but for a first program I'll never did better ^^
If you want to make a V2, take a look at these pages:
http://www.computerc...56-in-pure-lua/ to hash the password and make it harder to hack (maybe a bit too hard to understand for somebody is new in lua / computercraft, but maybe…)
http://www.computerc...nfo/wiki/Tables could be useful for making several accounts
And hilburn gave me these functions for one of my programs, it's very cool, you can save a table in a file, and load it later.
--All credits to hilburn for these two functions
function saveFile(data, filename)
if fs.exists(filename) then
fs.delete(filename)
end
file = fs.open(filename, "w")
file.write(textutils.serialize(data))
file.close()
end
function loadFile(filename)
if fs.exists(filename) then
file = fs.open(filename, "r")
data = textutils.unserialize(file.readAll())
file.close()
else
print("Could not load data file, exiting...")
sleep(1.4)
os.shutdown()
end
return data
end
A little explication of these functions:
You have a file called "passwords" and contain the following code :
{
"password1";
"password2";
"Nuttela";
"Sugar";
}
This is a table structure.
You want to load it in the program called "DoorLock", as the table "list", you juste have to did that :
local list = loadFile("passwords")
Notice if, for example, your file "passwords" is in the folder Door, it will be this :
local list = loadFile("/Door/passwords")
Next, if you want to save the file (For example, somebody modified his password in the program):
saveFile(list, "passwords") where list is the name of your table and passwords the name of your file.
I hope I've tell you something useful, and you've understand it (if not, just tell me it, I'll do some… better explications)
And if you want the hilburn's functions adapted for a simple string and not a table, tell me it too :P/>
Edit: After reflexion I think I've said a lot of things that you will not understand X_X