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

Wiki turtorial mistake?

Started by Mr Sabazio, 24 June 2012 - 05:22 PM
Mr Sabazio #1
Posted 24 June 2012 - 07:22 PM
Well i tried to use the Advanced password protected door code from the wiki, and I get this error, which I'm having trouble fixing. If someone can help It would be greatly appreciated. also I'm using version 1.3
ERROR
Spoiler

bios:206: [string "startup"]:9: ')' expected
PROGRAM
Spoiler
WIKI CODE
Spoiler

os.pullEvent = os.pullEventRaw
local side = "left"
local password = "bacon"
local opentime = 5
term.clear()
term.setCursorPos(1,1)
write("Password: ")
local input = read("*")
if input == (password) then
term.clear()
term.setCursorPos(1,1)
print("Password correct!")
rs.setOutput(side,true)
sleep(opentime)
rs.setOutput(side,false)
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
print("Password incorrect!")
sleep(2)
os.reboot()
end
cant_delete_account #2
Posted 24 June 2012 - 07:29 PM
On it.
(Fixing wiki)
cant_delete_account #3
Posted 24 June 2012 - 07:31 PM
Ok, try remove the brackets from the if, so like this:

if input == (password) then
to this:

if input == password then
Mr Sabazio #4
Posted 24 June 2012 - 07:36 PM
hey thanks for helping
=]
Mr Sabazio #5
Posted 24 June 2012 - 08:05 PM
actually the password is always incorrect this way
=[
Aerik #6
Posted 24 June 2012 - 08:42 PM
Try writing

if input == ("password") then
Not sure if this'll help, but the first thing that occurred to me
Mr Sabazio #7
Posted 24 June 2012 - 08:46 PM
Try writing

if input == ("password") then
Not sure if this'll help, but the first thing that occurred to me
Winning!
thanks you very much
MysticT #8
Posted 24 June 2012 - 08:48 PM
The code is fine and it should work, with or without the brackets.
Maybe it was a typo when copying it.

Try writing

if input == ("password") then
Not sure if this'll help, but the first thing that occurred to me
Winning!
thanks you very much
It works, but the password will always be "password", if you change it at the top (where it says local password = "password") it will have no effect.
Pinkishu #9
Posted 24 June 2012 - 08:49 PM
Uhm, using a variable doesn't make much sense then
input == password
should work fine, if it doesn't theres something else wrong
Bossman201 #10
Posted 24 June 2012 - 11:17 PM
Uhm, using a variable doesn't make much sense then
input == password
should work fine, if it doesn't theres something else wrong

if input == "password" then
No reason to use a variable in such a short program other than to add overhead. Just do a string check and take out variable declaration. Not sure why variable was enclosed with parentheses either, just increases program size.
Pinkishu #11
Posted 24 June 2012 - 11:42 PM
Uhm, using a variable doesn't make much sense then
input == password
should work fine, if it doesn't theres something else wrong

if input == "password" then
No reason to use a variable in such a short program other than to add overhead. Just do a string check and take out variable declaration. Not sure why variable was enclosed with parentheses either, just increases program size.

Well it had one at top though :P/>/>
And programs can always grow bigger - plan ahead
Mr Sabazio #12
Posted 25 June 2012 - 05:01 PM
well if it isnt the () around password on line 9, what else would it be?