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

Password Lock Code: What's wrong with THIS one?

Started by blueflames7, 30 September 2012 - 12:44 PM
blueflames7 #1
Posted 30 September 2012 - 02:44 PM
Pretty simple. But it won't work, like usual.

print ("Password Lock, By Noah
sleep(3)
print ("Please out your door on the left side of this device")
sleep(5)
print ("Please eneter your password")
if name = "Alienware" then
redstone.setOutput ("left", true)
print ("Welcome!")
sleep(5)
redstone.setOutput ("left", false)
os.reboot()
end
if else
print ("Password Incorrect!")
os.reboot()
end
This is what I get

bios:206: [string "PasswordLockByNoah"]:6: 'then'
expected
Klausar #2
Posted 30 September 2012 - 02:47 PM
Try this:

print ("Password Lock, By Noah")
sleep(3)
print ("Please out your door on the left side of this device")
sleep(5)
print ("Please eneter your password")
name = io.read()
if name == "Alienware" then
redstone.setOutput ("left", true)
print ("Welcome!")
sleep(5)
redstone.setOutput ("left", false)
os.reboot()
elseif
print ("Password Incorrect!")
os.reboot()
end

Your forgot to set the variable "name" and it has to be name ==. Also the print at the beginning wasn't closed. If else is also wrong, it's elseif.
blueflames7 #3
Posted 30 September 2012 - 02:51 PM
Now I'm getting an error about an unexpected symbol.
Klausar #4
Posted 30 September 2012 - 02:52 PM
Please post the errorcode.
blueflames7 #5
Posted 30 September 2012 - 02:54 PM
Ok, here it is

bios:206: [string "PasswordLockByNoah"]:14:
unexpected symbol
Klausar #6
Posted 30 September 2012 - 02:59 PM
oh ofcourse! use "else" only instead of elseif.
jag #7
Posted 30 September 2012 - 02:59 PM
Well you got
elseif
without any parameters at line 13…
blueflames7 #8
Posted 30 September 2012 - 03:02 PM
I fixed that one, now there's a new one…..

bios:206: [string "PasswordLockByNoah"] :14:
'<eof>' expected
jag #9
Posted 30 September 2012 - 03:06 PM
SpoilerI fixed that one, now there's a new one…..

bios:206: [string "PasswordLockByNoah"] :14:
'<eof>' expected
What did you do? Can you show us the "new" code?
blueflames7 #10
Posted 30 September 2012 - 03:10 PM
I'm just doing what you guys are telling me to do :3
Klausar #11
Posted 30 September 2012 - 03:12 PM
os.reboot()
else
print ("Password Incorrect!")
os.reboot()
end

That's how the code should look at the end, does it look like this?
blueflames7 #12
Posted 30 September 2012 - 03:12 PM
Yep!
Klausar #13
Posted 30 September 2012 - 03:14 PM
Post your whole code again, how does it look right now? I cant find any errors.
jag #14
Posted 30 September 2012 - 03:17 PM
SpoilerI'm just doing what you guys are telling me to do :3
Well just add a post with the new code, and we'll take a new look at it.
NIN3 #15
Posted 30 September 2012 - 03:59 PM
Is there a space bettween print and the ("words")? In your orriginal code there is. You cant do that(last time I cheaked). remove the space.
jag #16
Posted 30 September 2012 - 04:01 PM
SpoilerIs there a space bettween print and the ("words")? In your orriginal code there is. You cant do that(last time I cheaked). remove the space.
I actually think you can have spaces, I don't even think that is the problem…
EDIT: I just tried it, and it workes (the spaces between print and the arguments).
jag #17
Posted 30 September 2012 - 04:14 PM
So I just tried your script and it worked!
So you must have messed something up, or (if you are playing on a server) the server is a bit buggy…
Images:
Spoiler



I added it to pastebin, so if someone else want to try then here you go:
5ncnJF0r
blueflames7 #18
Posted 30 September 2012 - 07:59 PM
I'm running CraftOS 1.3, is that the problem?

I KNOW! I didn't put double enter, so I need to press enter another time.
jag #19
Posted 30 September 2012 - 07:59 PM
I'm running CraftOS 1.3, is that the problem?
It might be… I don't know what they added coding wise when they updated to CC 1.4
blueflames7 #20
Posted 30 September 2012 - 08:02 PM
Thanks! You really helped me!

it works!
jag #21
Posted 30 September 2012 - 08:02 PM
Thanks! You really helped me!

it works!
Well I'm glad that I could help you :)/>/>