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

Password Help?

Started by tigerman4527, 13 July 2012 - 09:00 PM
tigerman4527 #1
Posted 13 July 2012 - 11:00 PM
So I'm using this code as a Password for my door on a Tekkit server.



local oldPull = os.pullEvent;
os.pullEvent = os.pullEventRaw;

pass = "Pass"

print ("Lock")
write "Password: "
input = read()
if input == pass then
print ("Access Granted")
redstone.setOutput ("left", true )
sleep(5)
os.shutdown()
else
print ("Access Denied"!)
sleep(2)
os.shutdown()
end

os.pullEvent = oldPull;

The code before pass and after end prevent Ctrl + T Termination.

I need an extra code that turns the lock off and then goes back to CraftOS 1.3, like a debug code.

I'm LUA Retarded, so I need some help :/
jay5476 #2
Posted 14 July 2012 - 12:26 AM
Well I use this code.

os.pullEvent = os.pullEventRaw
T = read()
If t == "open" then -- or any password here
rs.setOutput("right",true)
Sleep(3.5)
os.reboot()
elseif t == "access" then -- not sure if its elseif or if
term.clear()
term.setCursorPos(1,1)
Grey_M62 #3
Posted 14 July 2012 - 12:44 AM

local oldPull = os.pullEvent;
os.pullEvent = os.pullEventRaw;

pass = "Pass"
access = "Pass2"

print ("Lock")
write("Password: ")
input = read()
if input == pass then
print ("Access Granted")
redstone.setOutput ("left", true )
sleep(5)
os.shutdown()
elseif pass == access then
term.setCursorPos(1,1)
print("CraftOS 1.3")
else
print ("Access Denied!")
sleep(2)
os.shutdown()
end

os.pullEvent = oldPull;

I modified your code a bit for it to work.

Plus, if you make

input = read()
into

input = read("*")
the password will show as stars rather than the actual letters.
tigerman4527 #4
Posted 14 July 2012 - 12:52 AM
Thanks :P/>/> Works great
Grey_M62 #5
Posted 14 July 2012 - 02:56 AM
Thanks :P/>/> Works great
Your welcome :)/>/>