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

Password door help!

Started by blueflames7, 29 September 2012 - 11:23 AM
blueflames7 #1
Posted 29 September 2012 - 01:23 PM
I'm getting this message when I try to use my code for password locked doors.

bios:206: [ string "lock" :5: ')' expected
Here is the code I am using

print ('PASSWORD REQUIRED')
name = read()
if name == ('Aperture') then
redstone.setOutput ('right', true)
print ('ACCESS GRANTED')
sleep(5)
redstone.setOutput ('right', false)
else
print ('ACCESS DENIED')
end

Please help!
[EDIT: I'm using the tekkit modpack.]
Edited on 29 September 2012 - 11:39 AM
Doyle3694 #2
Posted 29 September 2012 - 01:29 PM
redstone.setOutput ('right, false) is wrong.
redstone.setOutput ('right', false) is correct
blueflames7 #3
Posted 29 September 2012 - 01:32 PM
redstone.setOutput ('right, false) is wrong.
redstone.setOutput ('right', false) is correct
I'm a complete noob, but I don't see a difference.

Wait, I see it. Thanks!
blueflames7 #4
Posted 29 September 2012 - 01:35 PM
Now I'm getting a new error :/

bios:206: [string "lock"] :5: unfinished string
blueflames7 #5
Posted 29 September 2012 - 01:37 PM
Wait, I went backwords. I'll fix it now.

Actually that mistake you said was a typo on the forums, not in the code.
blueflames7 #6
Posted 29 September 2012 - 01:38 PM
Now I'm back to the original error, any more ideas?
Doyle3694 #7
Posted 29 September 2012 - 01:53 PM
put your code up to pastebin and I can take a look.
blueflames7 #8
Posted 29 September 2012 - 01:54 PM
http://pastebin.com/MGKNkJx3
Doyle3694 #9
Posted 29 September 2012 - 01:54 PM
anotehr bug:
if name == ('Aperture') then WRONG
if name == 'Aperture' then CORRECT
blueflames7 #10
Posted 29 September 2012 - 01:59 PM
I'm getting the same error…….. WHY COMPUTERCRAFT WHY!!!!!!!!

bios:206: [ string "lock" :5: ')' expected
Doyle3694 #11
Posted 29 September 2012 - 02:05 PM
test this code:
local password = "hellu"

while true do
textutils.slowPrint("Password required to enter")
textutils.slowPrint("Please enter password below")
passwordRead = read("*")
if passwordRead == password then
   textutils.slowPrint("Access Granted")
   redstone.setOutput("right", true)
   sleep(5)
   redstone.setOutput("right", false)
else
   textutils.slowPrint("Access Denied")
end
end
Doyle3694 #12
Posted 29 September 2012 - 02:07 PM
oh and also
there is spaces between your functions and your parameters. that is messing stuff up.
NIN3 #13
Posted 29 September 2012 - 02:08 PM
Well, As far as I know, there can be no space bettween print and the ()
print ('PASSWORD REQUIRED') is wrong
print('PASSWORD REQUIRED') is right

Also, doesnt it have to be "lol" instead of 'lol'?
Doyle3694 #14
Posted 29 September 2012 - 02:10 PM
'' and "" can be used however you want. but if you try to use like a quote in your print, then you use ''. and if you're trying to type don't in a print then use ""
blueflames7 #15
Posted 29 September 2012 - 02:39 PM
test this code:
local password = "hellu"

while true do
textutils.slowPrint("Password required to enter")
textutils.slowPrint("Please enter password below")
passwordRead = read("*")
if passwordRead == password then
   textutils.slowPrint("Access Granted")
   redstone.setOutput("right", true)
   sleep(5)
   redstone.setOutput("right", false)
else
   textutils.slowPrint("Access Denied")
end
end

startup:4: attempt to index ? (a nil value)
Thats the error I get.

test this code:
local password = "hellu"

while true do
textutils.slowPrint("Password required to enter")
textutils.slowPrint("Please enter password below")
passwordRead = read("*")
if passwordRead == password then
   textutils.slowPrint("Access Granted")
   redstone.setOutput("right", true)
   sleep(5)
   redstone.setOutput("right", false)
else
   textutils.slowPrint("Access Denied")
end
end

startup:4: attempt to index ? (a nil value)
Thats the error I get.
All I changed was the local password to Aperture.
Doyle3694 #16
Posted 29 September 2012 - 03:01 PM
test changing all textutils.slowPrint's to print. Don't know if textutils work in 1.33

local password = "hellu"

while true do
print("Password required to enter")
print("Please enter password below")
passwordRead = read("*")
if passwordRead == password then
   print("Access Granted")
   rs.setOutput("right", true)
   sleep(5)
   rs.setOutput("right", false)
else
   print("Access Denied")
end
end
blueflames7 #17
Posted 29 September 2012 - 03:10 PM
k
filipkwro #18
Posted 29 September 2012 - 03:21 PM
This should work.

local password = "Aperture"

while true do
print("Password required to enter")
print("Please enter password below")
local passwordRead = read("*")
if passwordRead == password then
print("Access Granted")
rs.setOutput("right", true)
sleep(5)
rs.setOutput("right", false)
else
print("Access Denied")
sleep(2)
os.shutdown()
end
end
Well, As far as I know, there can be no space bettween print and the ()
There can be a space. One time i did:

print							    ("lol")
and it was no error, it just printed lol.

Anyway, wrong section. The thread should be in "Ask a Pro".
Doyle3694 #19
Posted 29 September 2012 - 03:54 PM
ehrm…. why os.shutdown in a while true loop? really? that's just unnesssesary.
DSlink2010 #20
Posted 30 September 2012 - 11:52 PM
Anyway, wrong section. The thread should be in "Ask a Pro".
Yeah, I just reported it to be moved :)/>/>
DSlink2010 #21
Posted 30 September 2012 - 11:57 PM
Oh, and here's WORKING code!

while true do
password = "aperture"
term.clear()
term.setCursorPos(1, 1)
print("Please Enter Password:")
input = read("*")
if input == password then
  redstone.setOutput("back", true)
  print("Access Granted")
  sleep(2)
  redstone.setOutput("back", false)
end
end
It should work.