Jump to content




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


  • You cannot reply to this topic
20 replies to this topic

#1 blueflames7

  • New Members
  • 19 posts

Posted 30 September 2012 - 01: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


#2 Klausar

  • Members
  • 110 posts

Posted 30 September 2012 - 01: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.

#3 blueflames7

  • New Members
  • 19 posts

Posted 30 September 2012 - 01:51 PM

Now I'm getting an error about an unexpected symbol.

#4 Klausar

  • Members
  • 110 posts

Posted 30 September 2012 - 01:52 PM

Please post the errorcode.

#5 blueflames7

  • New Members
  • 19 posts

Posted 30 September 2012 - 01:54 PM

Ok, here it is
bios:206: [string "PasswordLockByNoah"]:14:
unexpected symbol


#6 Klausar

  • Members
  • 110 posts

Posted 30 September 2012 - 01:59 PM

oh ofcourse! use "else" only instead of elseif.

#7 jag

  • Members
  • 533 posts
  • LocationStockholm, Sweden

Posted 30 September 2012 - 01:59 PM

Well you got
elseif
without any parameters at line 13...

#8 blueflames7

  • New Members
  • 19 posts

Posted 30 September 2012 - 02:02 PM

I fixed that one, now there's a new one.....
bios:206: [string "PasswordLockByNoah"] :14:
'<eof>' expected


#9 jag

  • Members
  • 533 posts
  • LocationStockholm, Sweden

Posted 30 September 2012 - 02:06 PM

View Postblueflames7, on 30 September 2012 - 02:02 PM, said:

Spoiler
What did you do? Can you show us the "new" code?

#10 blueflames7

  • New Members
  • 19 posts

Posted 30 September 2012 - 02:10 PM

I'm just doing what you guys are telling me to do :3

#11 Klausar

  • Members
  • 110 posts

Posted 30 September 2012 - 02: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?

#12 blueflames7

  • New Members
  • 19 posts

Posted 30 September 2012 - 02:12 PM

Yep!

#13 Klausar

  • Members
  • 110 posts

Posted 30 September 2012 - 02:14 PM

Post your whole code again, how does it look right now? I cant find any errors.

#14 jag

  • Members
  • 533 posts
  • LocationStockholm, Sweden

Posted 30 September 2012 - 02:17 PM

View Postblueflames7, on 30 September 2012 - 02:10 PM, said:

Spoiler
Well just add a post with the new code, and we'll take a new look at it.

#15 NIN3

  • New Members
  • 57 posts
  • LocationEverywhere.

Posted 30 September 2012 - 02: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.

#16 jag

  • Members
  • 533 posts
  • LocationStockholm, Sweden

Posted 30 September 2012 - 03:01 PM

View PostNIN3, on 30 September 2012 - 02:59 PM, said:

Spoiler
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).

#17 jag

  • Members
  • 533 posts
  • LocationStockholm, Sweden

Posted 30 September 2012 - 03: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

#18 blueflames7

  • New Members
  • 19 posts

Posted 30 September 2012 - 06: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.

#19 jag

  • Members
  • 533 posts
  • LocationStockholm, Sweden

Posted 30 September 2012 - 06:59 PM

View Postblueflames7, on 30 September 2012 - 06:58 PM, said:

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

#20 blueflames7

  • New Members
  • 19 posts

Posted 30 September 2012 - 07:02 PM

Thanks! You really helped me!

it works!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users