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

Password with installer

Started by GeneraalKudos, 17 May 2014 - 08:07 PM
GeneraalKudos #1
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.


--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
Konlab #2
Posted 18 May 2014 - 12:10 PM
Its nice, but it is an API or Utility?
GeneraalKudos #3
Posted 18 May 2014 - 04:10 PM
Its nice, but it is an API or Utility?
It's an utility. The installer just copies the password code to startup, but it isn't needed for the password code to work.
Agoldfish #4
Posted 20 May 2014 - 09:15 PM
Just use pastebin for the installer(s). o.O