1 posts
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!
445 posts
Posted 28 July 2012 - 05:00 PM
pcall(read,"*") might work
1604 posts
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.
30 posts
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
515 posts
Location
Australia
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
30 posts
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()andinput = read("*")
127 posts
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.