Posted 18 October 2012 - 07:39 PM
so i'm trying to make a advanced password lock and i almost have it but there is somekind of problem that i can't understand
ok, there are 2 computers
1st is where the password is entered and the door activated here's the code :
2nd is where the password is stored and it can be changed here's the code:
i think there is a problem with the 1st computer's code becouse when i enter the code it skips everything and again prints enter password or just freezes like it would be waiting for password…
please help
ok, there are 2 computers
1st is where the password is entered and the door activated here's the code :
rednet.open("back")
passex=false
function getpass()
passex=false
rednet.send(20,"pass")
id,txt=rednet.receive()
if id=="20" then
pass=txt
passex=true
end
end
while true do
term.clear()
term.setCursorPos(1,1)
print("Enter Password: ")
input = read("*")
getpass()
if passex==true then
if input==pass then
rs.setOutput("bottom",false)
os.sleep(5)
rs.setOutput("bottom",true)
else
print("Wrong password")
os.sleep(1)
end
else
print("unable to get password")
end
end
2nd is where the password is stored and it can be changed here's the code:
pass="sss"
rednet.open("top")
while true do
term.clear()
term.setCursorPos(1,1)
event,p1,p2= os.pullEvent()
if event=="rednet_message" then
if p2=="pass" then
os.sleep(0.1)
rednet.send(19,pass,true)
print("password was told")
os.sleep(5)
else
print(p2)
os.sleep(1)
end
elseif event=="char" then
if p1=="P" then
print("So you want to change the passowrd?")
print("Enter old password")
input=read("*")
if input==pass then
print("enter new password")
pass=read()
else
print("wrong password")
os.sleep(1)
end
else
print(p1)
end
end
end
i think there is a problem with the 1st computer's code becouse when i enter the code it skips everything and again prints enter password or just freezes like it would be waiting for password…
please help