6 posts
Posted 04 November 2012 - 04:05 AM
This is my start up code for a password door.I need help it won't work.Sorry if under wrong section I'm new.
pass = 1337
print("Awesome Pwning Guy protected")
sleep(1)
print ("Enter password")
write "Password: "
input = read()
if input == pass then
print("Correct password")
sleep(1)
print("Access granted")
sleep(2)
redstone.setOutput("right", true)
sleep(4)
redstone.setOutout("right", false)
else
print("Password Incorrect")
redstone.setOutput("back, true)
sleep(4)
redstone.setOutput("back, true)
Error
bios:338: [string "startup"]:20: 'end' expected (to
close 'if' at line 8
318 posts
Location
Somewhere on the planet called earth
Posted 04 November 2012 - 04:23 AM
if statements require an end. Your if on line 8 has no end.
Fixed code
pass = 1337
print("Awesome Pwning Guy protected")
sleep(1)
print ("Enter password")
write "Password: "
input = read()
if input == pass then
print("Correct password")
sleep(1)
print("Access granted")
sleep(2)
redstone.setOutput("right", true)
sleep(4)
redstone.setOutout("right", false)
else
print("Password Incorrect")
redstone.setOutput("back", true) --You forgot to close brackets here
sleep(4)
redstone.setOutput("back", true) --and here
end -- You need this
6 posts
Posted 04 November 2012 - 04:40 AM
Sorry for my fail thanks sjele. Lol that is why you don't trust me to coding.
6 posts
Posted 04 November 2012 - 04:52 AM
New error
startup:20: attempt to call nil
839 posts
Location
England
Posted 04 November 2012 - 05:01 AM
New error
startup:20: attempt to call nil
do you have a copy of the new code?
6 posts
Posted 04 November 2012 - 05:03 AM
Same code as sjele fix version.
pass = 1337
print("Awesome Pwning Guy protected")
sleep(1)
print ("Enter password")
write "Password: "
input = read()
if input == pass then
print("Correct password")
sleep(1)
print("Access granted")
sleep(2)
redstone.setOutput("right", true)
sleep(4)
redstone.setOutout("right", false)
else
print("Password Incorrect")
redstone.setOutput("left", true)
sleep(4)
redstone.setOutput("left", true)
end
note redstone torch is on left side.
839 posts
Location
England
Posted 04 November 2012 - 05:12 AM
After looking in depth, I found a few errors, this should fix them all:
pass = "1337"
print("Awesome Pwning Guy protected")
sleep(1)
print("Enter password")
write("Password: ")
input = read()
if input == pass then
print("Correct password")
sleep(1)
print("Access granted")
sleep(2)
redstone.setOutput("right", true)
sleep(4)
redstone.setOutput("right", false)
else
print("Password Incorrect")
redstone.setOutput("left", true)
sleep(4)
redstone.setOutput("left", true)
end
Your problems were:
1- using
write "Password: "
(bad way to call a function)
instead of
write("Password: ")
(good way to call a function)
2- using
pass = 1337
(stores 1337 as a number)
instead of
pass = "1337"
(stores 1377 as test)
3-using
redstone.setOutout("right", false)
(typo)
instead of
redstone.setOutput("right", false)
(correct spelling of Output)
6 posts
Posted 04 November 2012 - 05:16 AM
Thanks I looked through and found the output error but the rest i didn't thanks. :D/>/> :)/>/> :)/>/> :)/>/> :)/>/> :)/>/>