This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Kekkonen's profile picture

Password protection question

Started by Kekkonen, 20 March 2012 - 10:45 AM
Kekkonen #1
Posted 20 March 2012 - 11:45 AM
Is there a way to make a password protection system that has a "superpassword" which allows you to change the access password or exit the program? I only managed to make a program as far as being able to change the password or closing the program after entering a superpassword but after the program reboots, the changed password is switched to the default one in the code.
Espen #2
Posted 20 March 2012 - 11:52 AM
Runtime variables which aren't stored to disk will be lost after a reboot.
That's not only the case with CC computers, but with actually every real computer as well.
Just open a notepad (one without autosave) in a real computer and type some text. Then force a reboot. Oh where has your text gone to? :D/>/>

You have to make the program be able to store the information, i.e. make use of either fs.open() or io.open() to write data to files, which your program can then read from if a reboot occurred.
Better yet, someone made a very easy to use serialize API that you can make use of for this purpose: http://www.computercraft.info/forums2/index.php?/topic/302-api-proper-serialization

Hope it helps, cheers :)/>/>