5 posts
Location
Ktown Az
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
474 posts
Posted 24 June 2012 - 07:29 PM
On it.
(Fixing wiki)
474 posts
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
5 posts
Location
Ktown Az
Posted 24 June 2012 - 07:36 PM
hey thanks for helping
=]
5 posts
Location
Ktown Az
Posted 24 June 2012 - 08:05 PM
actually the password is always incorrect this way
=[
15 posts
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
5 posts
Location
Ktown Az
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
1604 posts
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.
445 posts
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
92 posts
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.
445 posts
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
5 posts
Location
Ktown Az
Posted 25 June 2012 - 05:01 PM
well if it isnt the () around password on line 9, what else would it be?