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

Computers not working correctly and password lock quitting

Started by FoxData, 09 February 2016 - 07:30 PM
FoxData #1
Posted 09 February 2016 - 08:30 PM
Hi everyone. On my data center i have a command computer running a password lock program. But the issue is that when you enter the correct or wrong password it will quit the program. And sometimes it just stops working (It shuts down and does not switch on until i restart minecraft or wait for it). What is going on with my data center?
Lupus590 #2
Posted 09 February 2016 - 10:31 PM
Post your code.

http://pastebin.com
FoxData #3
Posted 10 February 2016 - 04:33 PM
Post your code.

http://pastebin.com
Hi. I followed this tutorial to make the password lock: http://www.computercraft.info/wiki/Making_a_Password_Protected_Door

And what about the computer shutting down and not starting up issue?
Dog #4
Posted 10 February 2016 - 04:42 PM
FoxData, we need to see *your* code, not the tutorial. If we can't see your code, we can only guess as to why it's not working.
FoxData #5
Posted 10 February 2016 - 05:43 PM
Post your code. http://pastebin.com

This is my code: http://pastebin.com/Hm4PPnZ4
Edited on 10 February 2016 - 04:54 PM
FoxData #6
Posted 10 February 2016 - 05:55 PM
Also: Is there anything i can do about the other computer issue?
Edited on 10 February 2016 - 04:59 PM
Lupus590 #7
Posted 10 February 2016 - 06:19 PM
Have you heard of while loops?


while true do
--#stuff to do forever
end

Add a while loop at about line 9.

also, remove the os.reboot at line 28.
Dog #8
Posted 10 February 2016 - 08:17 PM
Lupus590 is on to something. If you take a look at the tutorial again, you will see that it used a while loop and didn't use os.reboot(). That loops allows the program to run indefinitely without having to restart the computer each time.

As your code is written now your program will exit when the correct password is entered but reboot if an incorrect password is entered. Both of these issues can be resolved with the use of a while loop.