Posted 17 May 2014 - 10:07 PM
Hello, I've created a simple password program. I'll post it in 2 parts; 1 for the actual password, and 1 for the installer.
1. Password program
If you don't want to use the installer, just put this code in "startup". Then edit the startup to your desires. It should be clear enough.
2. Installer
If you want an installer, get a floppy disk and put the password code in "Pass". Then put the following code in "disk/startup".
1. Password program
If you don't want to use the installer, just put this code in "startup". Then edit the startup to your desires. It should be clear enough.
--Remove the 2 lines in front of the next sentence to prevent people from terminating the program.
--os.pullEvent = os.pullEventRaw
--Change the word "admin" into the desired password.
password="admin"
--Change the word "right" into the side you want to get the redstone signal at. Choose between "left", "right", "front", "back", "bottom" and "top".
side="right"
function clear()
term.clear()
term.setCursorPos(1,1)
end
clear()
write("Enter password: ")
input=read("*")
--This let's the computer read it like it was normal text, but shows 1 * for each character.
if input==password then
clear()
print("Password correct!")
redstone.setOutput(side, true)
sleep(5)
redstone.setOutput(side, false)
os.reboot()
else
clear()
print("Password incorrect!")
sleep(3)
os.reboot()
end
2. Installer
If you want an installer, get a floppy disk and put the password code in "Pass". Then put the following code in "disk/startup".
function clear()
term.clear()
term.setCursorPos(1,1)
end
clear()
print("Would you like to install the a password? Y/N")
print("WARNING: THIS FILE WILL DELETE YOUR CURRENT STARTUP FILE")
input=read()
if input=="Y" then
clear()
fs.delete("startup")
fs.copy("disk/Pass", "startup")
print("Installation complete.")
print("Don't forget to take your Floppy Disk out!")
sleep(7)
os.shutdown()
elseif input=="y" then
clear()
fs.delete("startup")
fs.copy("disk/Pass", "startup")
print("Installation complete.")
print("Don't forget to take your Floppy Disk out!")
sleep(7)
os.shutdown()
else
clear()
print("Installation cancelled")
sleep(3)
os.shutdown()
end