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

Hide what i am typing into my passord protected door?

Started by samster1990, 28 July 2012 - 02:41 PM
samster1990 #1
Posted 28 July 2012 - 04:41 PM
On my SMP tekkit server, i have written a password door program for everyone to use. I made it so it cannot be terminated with CTRL + T, but anyone can see me typing my password, is there a way to stop that?
It would be cool if the password could be covered with ***** or something. Here is my code:

pass = "password"
print("Sam&Co Locks")
write("Password: ")
local status, input = pcall(read)
if input == pass then
redstone.setOutput("left", true)
print("Access Granted")
sleep(3)
os.shutdown()
else
print("Access Denied")
sleep(3)
os.shutdown()
end
Any help is appreciated, thanks!
Pinkishu #2
Posted 28 July 2012 - 05:00 PM
pcall(read,"*") might work
MysticT #3
Posted 28 July 2012 - 08:49 PM
Enter anything (or just press enter), hold Ctrl-T after the "Access denied" message, program terminated access granted.
The problem: sleep. It calls os.pullEvent, wich handles the "terminate" event and stops the program.
A better way to prevent termination is:

os.pullEvent = os.pullEventRaw
-- your code here
And you don't need pcall.
Lasere123456 #4
Posted 29 July 2012 - 03:16 AM

os.pullEvent = os.pullEventRaw - anti control + t
pass = "password" -- make it short
print("Sam&Co Locks")
write("Password: ")
input = read()
if input == pass then
   redstone.setOutput("left", true)
   term.clear() -- clears the terminal
   term.setCursorPos(1,1) -- makes the new text go to the top of the terminal
   print("Access Granted")
   sleep(3)
   os.shutdown()
else
   print("Access Denied")
   sleep(3)
   os.shutdown()
end
1lann #5
Posted 29 July 2012 - 03:21 AM

os.pullEvent = os.pullEventRaw - anti control + t
pass = "password" -- make it short
print("Sam&Co Locks")
write("Password: ")
input = read()
if input == pass then
   redstone.setOutput("left", true)
   term.clear() -- clears the terminal
   term.setCursorPos(1,1) -- makes the new text go to the top of the terminal
   print("Access Granted")
   sleep(3)
   os.shutdown()
else
   print("Access Denied")
   sleep(3)
   os.shutdown()
end

Actually its


os.pullEvent = os.pullEventRaw -- anti control + t
pass = "password" -- make it short
print("Sam&Co Locks")
write("Password: ")
input = read("*")
if input == pass then
   redstone.setOutput("left", true)
   term.clear() -- clears the terminal
   term.setCursorPos(1,1) -- makes the new text go to the top of the terminal
   print("Access Granted")
   sleep(3)
   os.shutdown()
else
   print("Access Denied")
   sleep(3)
   os.shutdown()
end
Lasere123456 #6
Posted 29 July 2012 - 12:23 PM

os.pullEvent = os.pullEventRaw - anti control + t
pass = "password" -- make it short
print("Sam&Co Locks")
write("Password: ")
input = read()
if input == pass then
   redstone.setOutput("left", true)
   term.clear() -- clears the terminal
   term.setCursorPos(1,1) -- makes the new text go to the top of the terminal
   print("Access Granted")
   sleep(3)
   os.shutdown()
else
   print("Access Denied")
   sleep(3)
   os.shutdown()
end

Actually its


os.pullEvent = os.pullEventRaw -- anti control + t
pass = "password" -- make it short
print("Sam&Co Locks")
write("Password: ")
input = read("*")
if input == pass then
   redstone.setOutput("left", true)
   term.clear() -- clears the terminal
   term.setCursorPos(1,1) -- makes the new text go to the top of the terminal
   print("Access Granted")
   sleep(3)
   os.shutdown()
else
   print("Access Denied")
   sleep(3)
   os.shutdown()
end

what is the difference between:
input = read()
and
input = read("*")
ChiknNuggets #7
Posted 29 July 2012 - 12:37 PM
input = read() just types the actual letters that you press

input = read("*") replaces the letters with a * but will still let u use input as a string.