Jump to content

ComputerCraft Lock Door


iPSY

Recommended Posts

Hi ! So i've just made a simple piston secret door design and place a computer has the opening mechanism, for some reason, it keeps giving me "bios:337: [srting "startup"]:11: syntax error.

I've checked line 11 and found nothing wrong in it. Can you guys help me out, maybe im missing something.

Also, wen it did work the first time, it gave me an Error in line 5 saying couldn't reach nil or something like that.

correctpass = "PortalRoom123"

while true do

term.clear()

term.setCursorPos(1,1)

write("Welcome ! Please, enter Password Now: ")

pass = read("*")

if pass == correctpass then

write("Access Granted !")

redstone.setOutput("back",true)

sleep(10)

redstone.setOutput("back",false)

else

write("Access Denied !")

sleep(2)

end

end

Link to comment
Share on other sites

Im using this in my lan world with my cousin, and he doesn't understand computercraft, so ya, no problem in that.

If i do want to stop the loop, I just need to type this os.pullEvent = os.pullEventRaw at the start of the program, I did my research.

Link to comment
Share on other sites

that actually is useless, just hold ctrl + T, then you can stop the loop. type lua, then use redstone.setOutput("back",true), the door will be opened. lol

That's why you can put this at the top of the code:

os.pullEvent = os.pullEventRaw

That will only make you able to reboot or restart the computer. Also, I always make a maintenance password in my door locks. If I input it, the loop stops and the PC starts normally, for when I want to edit the password or something.

But people can still open your door with a lever or redstone torch. So what you then do is place the door in such a way that when the door is "closed" according to the game, it's actually open. Then make the computer constantly emit a redstone signal so the door closes, and when you input the password, have the redstone signal temporarily turn off, instead of on.

Im using this in my lan world with my cousin, and he doesn't understand computercraft, so ya, no problem in that.

If i do want to stop the loop, I just need to type this os.pullEvent = os.pullEventRaw at the start of the program, I did my research.

That actually does something completely different, as mentioned earlier in this post. If you want to stop the loop, you'll have to actually assign a variable. Such as "loop = true". Example:

loop = true

 

while loop == true do

input = read()

if input == "password" then

loop = false

else

print("incorrect")

end

end

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...