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

Simple Lock Program bios:206: [string "lock"] :9: '=' expected

Started by roodtooder, 26 June 2012 - 05:08 PM
roodtooder #1
Posted 26 June 2012 - 07:08 PM
Hello
I just started learning to work with computer craft and LUA script today.
I have previous experience with several scripts and stuff but I was working on this simple program to retract some sticky pistons using a password system. When I try to run the program I get an error that says bios:206: [string "lock"] :9: '=' expected and I dont have the slightest clue what this means. The word lock is no where in the script so i thought id change the program name to 'password' and then i got bios:206: [string "password"] :9: '=' expected.

I just need assistance knowing what the problem is.



Pass=cowfence
write "Good Day, Mason!"
write "Please enter the password"
input=read()
if
input==pass
then
term.clear
term.setcursorpos(1,1)
print "Access Granted…!"
rs.setoutput("Back,True")
os.shutdown
else
term.clear
term.setcursorpos(1,1)
Write "PASSWORD INCORRECT"
Sleep(2)
term.clear
term.sercursorpos(1,1)
Write "Shutting down…
Sleep (2)
os.shutdown
end
Exerro #2
Posted 26 June 2012 - 07:15 PM
Pass=cowfence
write "Good Day, Mason!"
write "Please enter the password"
input=read()
if input==pass then
term.clear()
term.setcursorpos(1,1)
print "Access Granted…!"
rs.setoutput("back", true )
os.shutdown()
else
term.clear()
term.setcursorpos(1,1)
write "PASSWORD INCORRECT"
sleep(2)
term.clear()
term.sercursorpos(1,1)
write "Shutting down…"
sleep (2)
os.shutdown()
end

you need to use lower case and put () on the end of term. and os. and it says string lock because the program is called lock
roodtooder #3
Posted 26 June 2012 - 07:38 PM
thanks i didnt know () was a requirement
inventor2514 #4
Posted 26 June 2012 - 07:52 PM
Also, the 9 in the error message indicates the error occurred on line 9 of your program. In this case, term.setcursorpos(1,1) should be written as term.setCursorPos(1,1).
Exerro #5
Posted 26 June 2012 - 09:11 PM
Also, the 9 in the error message indicates the error occurred on line 9 of your program. In this case, term.setcursorpos(1,1) should be written as term.setCursorPos(1,1).
oh yeh can't believe I missed that…
archit #6
Posted 26 June 2012 - 09:14 PM
Besides the above corrections, the following should also be corrected:

Pass=cowfence
should really be:
Pass = "cowfence"
MysticT #7
Posted 26 June 2012 - 09:21 PM
Lua is case sensitive, so things like:

term.setcursorpos(1,1)
rs.setoutput("Back", true)
Are wrong, they should be:

term.setCursorPos(1, 1)
rs.setOutput("back", true)

Fixed code:

local pass = "cowfence" -- needs quotes to be a string
write("Good Day, Mason!")
write("Please enter the password")
local input = read()
if input == pass then
  term.clear()
  term.setCursorPos(1,1)
  print("Access Granted...!")
  rs.setOutput("back", true) -- true shouldn't be a string, no quotes there. And "Back" is not a valid side, "back" is.
  os.shutdown()
else
  term.clear()
  term.setCursorPos(1, 1) -- setcursorpos is wrong, it's setCursorPos
  write("PASSWORD INCORRECT") -- write, not Write
  sleep(2)
  term.clear()
  term.setCursorPos(1, 1)
  write("Shutting down...")
  sleep(2)
  os.shutdown()
end