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

[Error][Lua] I don't know what iv'e done wrong

Started by Flawededge, 27 April 2012 - 08:03 PM
Flawededge #1
Posted 27 April 2012 - 10:03 PM
I have tried everything to resolve this problem
nothing has worked
here is my whole code
can you tell me what ive done wrong


pass = allblacks
print ("welcome user.")
sleep (1)
print ("please enter password.")
write ("password: ")
password = read()
if password == pass then
print ("processing.")
sleep (0.5)
print ("processing..")
sleep (0.5)
print ("processing...")
sleep (1)
print ("Access GRANTED")
sleep (1)
print ("Door open for 15 seconds")
setOutput ("back", true)
sleep (15)
os.shutdown
end
else
print ("processing.")
sleep (0.5)
print ("processing..")
sleep (0.5)
print ("processing...")
sleep (1)
print ("Access Denied")
SLEEP (2)
os.Shutdown
end

this is my first code, and it opens a piston door
could you please advise on why I keep getting this error:
bios:206: [string "startup"] :21: '=' expected
and anything else i might of got wrong
Luanub #2
Posted 27 April 2012 - 10:15 PM
See comments in corrected code below:


pass = "allblacks" -- added " 's
print ("welcome user.")
sleep (1)
print ("please enter password.")
write ("password: ")
password = read()
if password == pass then
print ("processing.")
sleep (0.5)
print ("processing..")
sleep (0.5)
print ("processing...")
sleep (1)
print ("Access GRANTED")
sleep (1)
print ("Door open for 15 seconds")
rs.setOutput ("back", true) -- added rs. so it knows which API to use
sleep (15)
os.shutdown() -- added ()'s
--end this is not needed yet will cause the else to not work
else
print ("processing.")
sleep (0.5)
print ("processing..")
sleep (0.5)
print ("processing...")
sleep (1)
print ("Access Denied")
sleep (2) -- changed to lowercase
os.shutdown() -- changed from os.Shutdown to os.shutdown() Lua is case sensitive and need the ()'s
end
Flawededge #3
Posted 28 April 2012 - 01:59 AM
THANK YOU SO MUCH!!!
It is now working perfectly now
I will definitely be using Computercraft alot more from now on