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

[error] password script trouble ->[string "startup"]:10: ')' expected

Started by 115billy, 27 July 2012 - 08:25 PM
115billy #1
Posted 27 July 2012 - 10:25 PM
So i'm trying to create a door password script (see below)

function lock()
term.clear()
term.setCursorPos(1,1)
os.PullEvent = os.pullEventRaw
pass = oi.read()
if pass == "test" then
term.clear()
redstone.setOutput("right", true)
sleep(3)
redstone.setOutput("right", false)
lock()
else
lock()
end
end
lock()

it is saved to disk/startup

I get an error saying that in line 10, there's a ')' missing when first putting in the floppy then activating the computer, but based on this video it looks fine to me. [media]http://www.youtube.com/watch?v=dp-adiB2aaY[/media]

I'm very new to this, so if there's an obvious problem, lemme now. Thanks :)/>/>
sjele #2
Posted 27 July 2012 - 10:57 PM
This should work.

function lock()
term.clear()
term.setCursorPos(1,1)
os.PullEvent = os.pullEventRaw
pass = io.read()                                   --Edit happned here, it is supposed to be io.read() not oi.read()
if pass == "test" then
term.clear()
redstone.setOutput("right", true)
sleep(3)
redstone.setOutput("right", false)
lock()
else
lock()
end
end
lock()

This is my pw lock, put this on the right side of the door you want to open

os.pullEvent = os.pullEventRaw
pass = "password" --Change you're pw here
print("Password lock!")
write "Password: "
input = read()
if input == pass then
print("Accsess granted!")
rs.setOutput ("right",true)
sleep(5)
os.shutdown()
else
print ("Wrong password!")
sleep(3)
os.shutdown()
end
115billy #3
Posted 28 July 2012 - 12:35 AM
Thanks! Dumb mistake as I thought!