19 posts
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
818 posts
Posted 29 September 2012 - 01:29 PM
redstone.setOutput ('right, false) is wrong.
redstone.setOutput ('right', false) is correct
19 posts
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!
19 posts
Posted 29 September 2012 - 01:35 PM
Now I'm getting a new error :/
bios:206: [string "lock"] :5: unfinished string
19 posts
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.
19 posts
Posted 29 September 2012 - 01:38 PM
Now I'm back to the original error, any more ideas?
818 posts
Posted 29 September 2012 - 01:53 PM
put your code up to pastebin and I can take a look.
19 posts
Posted 29 September 2012 - 01:54 PM
818 posts
Posted 29 September 2012 - 01:54 PM
anotehr bug:
if name == ('Aperture') then WRONG
if name == 'Aperture' then CORRECT
19 posts
Posted 29 September 2012 - 01:59 PM
I'm getting the same error…….. WHY COMPUTERCRAFT WHY!!!!!!!!
bios:206: [ string "lock" :5: ')' expected
818 posts
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
818 posts
Posted 29 September 2012 - 02:07 PM
oh and also
there is spaces between your functions and your parameters. that is messing stuff up.
55 posts
Location
Everywhere.
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'?
818 posts
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 ""
19 posts
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.
818 posts
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
19 posts
Posted 29 September 2012 - 03:10 PM
k
14 posts
Location
Poland (in Europe)
Posted 29 September 2012 - 03:21 PM
This should work.
local password = "Aperture"while true doprint("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()
endendWell, 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".
818 posts
Posted 29 September 2012 - 03:54 PM
ehrm…. why os.shutdown in a while true loop? really? that's just unnesssesary.
60 posts
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 :)/>/>
60 posts
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.