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

password protect with while true do

Started by ti07shadow, 13 January 2013 - 08:21 AM
ti07shadow #1
Posted 13 January 2013 - 09:21 AM
I have a question here. Say if I have a

while true do
shell.run("program")
sleep(.425)
end

etc etc

how would I also include a password setup to so if I wanted to update some code or a config id be able to without breaking the computer and putting the code back in.

Also not having to put a disk drive (itll be on a SMP server so no acces to protect disk drive)
remiX #2
Posted 13 January 2013 - 10:41 AM
password setup to only run the program if the password is correct?

while true do
  term.setCursorPos(1,1) term.clear()
  pass = read()
  if pass = "passw()rd"
    shell.run("program")
  end
end
ti07shadow #3
Posted 13 January 2013 - 10:47 AM
actually I meant to have the program running and in order to override it to say edit the script or w/e u have to do, you would have to enter a password. but I found a interesting way, unfortunatly it requires a ctrl+r in order to update it so any ideas how to not require a restart?


os.pullEvent = os.pullEventRaw
if rs.getInput("right", 1) then
  term.clear()
  term.setCursorPos(1, 1)
  print("Please Enter Password:")
  input = read("*")
  if input == "yourpasswordhere" then
	print("Override Accepted, change redstone input then reboot to restart program.")
  else
	print("Incorrect Password")
	sleep(1)
	os.reboot()
  end
else
  shell.run("programhere")
end

i tried enclosing with

while true do

end

but after correct password is given well it goes back to the begininng of the program and doesnt give time for anything inside the correct password area.