Posted 15 July 2012 - 12:30 PM
Well i started with computercraft yesterday when i decided to make a lock for my house. Everythign went great, i found some tutorials and read them. But the problem is why doesnt my lock security work?
Everything work great but i got to terminate it and start it up again for it to work properly. Ok i will tell you what happens.
When i start it up everything goes as it should. It says it version and asks for the password. When i enter the wrong password it says "Incorrect Password" like it should. But when i type the right password it also says that. But when i type the right password again for the second time it then says "Password Correct", And the door opens. But then if i write the wrong password it just makes a new line and ask for the password again. It doesnt say "Password Incorrect" and it neither clears the screen. I have tried to fix it for a while but it doesnt want to work But here is the code so you can se for yourself whats wrong:
Everything work great but i got to terminate it and start it up again for it to work properly. Ok i will tell you what happens.
When i start it up everything goes as it should. It says it version and asks for the password. When i enter the wrong password it says "Incorrect Password" like it should. But when i type the right password it also says that. But when i type the right password again for the second time it then says "Password Correct", And the door opens. But then if i write the wrong password it just makes a new line and ask for the password again. It doesnt say "Password Incorrect" and it neither clears the screen. I have tried to fix it for a while but it doesnt want to work But here is the code so you can se for yourself whats wrong:
while password ~= "Fish" do
print ("TheWoakus Lock Security V0.1")
write ("Enter Password: -")
password = io.read()
print ("Password Incorrect")
sleep (3)
term.clear()
term.setCursorPos(1,1)
end
while true do
print ("TheWoakus Lock Security V0.1")
write ("Enter Password: -")
password = io.read()
if password == "Fish" then
print ("Password Correct")
redstone.setOutput("back", true)
sleep (5)
redstone.setOutput("back", false)
term.clear()
term.setCursorPos(1,1)
end
end