3 posts
Posted 16 April 2012 - 03:10 AM
Hi, i just started using lua and ComputerCraft today, so i do not know what the bios mean, so could anyone help me with this?
bios:206: [string "access"]:8: '=' expected
Here's the program:
term.clear()
term.setCursorPos(1.1)
write("Enter your passcode:")
x = io.read()
if x == "4086-597" then
print ("Access Granted")
print ("Have a nice day Glindir!")
redpulse back 1 10
else
print ("Access Denied")
end
it is a program to send a redstone signal to open an iron door if the correct passcode is entered (i originally wanted a floppy disk that has it, and i put it in a disk drive to gain access, but it is beyond me)
Can anyone figure this out?
Thanks!
474 posts
Posted 16 April 2012 - 03:46 AM
Instead of redpulse back 1 10 do:
rs.setOutput("back",true)
sleep(10 / 2)
rs.setOutput("back",false)
474 posts
Posted 16 April 2012 - 03:49 AM
Also, instead of io.read(), I would recommend this:
x = read("*")
It will bleep out the password.
166 posts
Location
Don't look behind you..
Posted 16 April 2012 - 08:31 PM
or do shell.run("redpulse back 1 10") if you want it that way..
1111 posts
Location
Portland OR
Posted 16 April 2012 - 09:51 PM
or do shell.run("redpulse back 1 10") if you want it that way..
Should be
shell.run("redpulse", "back", "1", "10")
2447 posts
Posted 16 April 2012 - 09:53 PM
or do shell.run("redpulse back 1 10") if you want it that way..
Should be
shell.run("redpulse", "back", "1", "10")
Not aimed at you luanub - but I'd just like to say that you should never rely on the behaviour of other programs in your program (as they could be changed) - it is much better to do the code route, as suggested by thesbros.
1111 posts
Location
Portland OR
Posted 16 April 2012 - 10:03 PM
or do shell.run("redpulse back 1 10") if you want it that way..
Should be
shell.run("redpulse", "back", "1", "10")
Not aimed at you luanub - but I'd just like to say that you should never rely on the behaviour of other programs in your program (as they could be changed) - it is much better to do the code route, as suggested by thesbros.
I have to say I agree, in fact I hardly ever use the shell API in any of my programs. The only exception being to set gps coords in the startup files of my gps host.
3 posts
Posted 16 April 2012 - 10:53 PM
Thanks for all of your help!
But there is still a problem: access:2: bad argument: int expected, got nil
was i supposed to put in
x = read(*)
or was i supposed to replace the asterisk? (And in my code I added quotes so I didn't get an unexpected symbol error)
term.clear()
term.setCursorPos(1.1)
write("Enter your passcode:")
x = read("*")
if x == "4086-597" then
print ("Access Granted")
print ("Have a nice day Glindir!")
redset.setOutput("back",true)
sleep(10/2)
redset.setOutput("back",false)
else
print ("Access Denied")
end
1111 posts
Location
Portland OR
Posted 16 April 2012 - 10:57 PM
it should be
x = read("*")
The error is saying it received an empty value on line 2. Is this the code you used?
Edited on 16 April 2012 - 09:02 PM
1604 posts
Posted 16 April 2012 - 11:03 PM
Change:
term.setCursorPos(1.1)
to:
term.setCursorPos(1, 1)
Arguments have to be separated by commas.
3 posts
Posted 17 April 2012 - 12:06 AM
Thanks to all of you amazing people, my mistakes were corrected!
I hope that someday, I will be able to help others, and be able to remember you guys and this problem.
Thanks a bundle!
Glindir