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

[Error] Trying to make a valve door

Started by sidebelow, 21 September 2012 - 05:17 PM
sidebelow #1
Posted 21 September 2012 - 07:17 PM
Hey!

Im trying to make a valve door that first will answer if I want to open or not.
Then there is a password required. After that the door should open.
But I only gets the error message:

bios:206: [string "startup"]:39: 'end' expected
(to close 'if' at line 13)

and here is the code i have done:
term.setCursorPos(1,1)
write("Security Guard Valve")
term.setCursorPos(3,1)
write("Do you wish to enter?")
term.setCursorPos(5,1)
write("YES")
term.setCursorPos(6,1)
write("NO")
print " "
correctpass = "yes"
pass = read("*")

if pass == (correctpass) then
term.clear()
term.setCursorPos(1,1)
write("Please enter password: ")

else
print " "
write("Bye!")
os.shutdown()

correctpass = "defcomp"
pass = read("*")

if pass == (correctpass) then
term.clear()
term.setCursorPos(1,1)
write("Please enter!")
redstone.setOutput("back", true)

else
term.setCursorPos(1,1)
write("Denied!")
term.setCursorPos(3,1)
write("System shutdown")
sleep(300)
os.shutdown()
end

Hope someone can help me.

//Sidebelow
sjele #2
Posted 21 September 2012 - 07:20 PM

term.setCursorPos(1,1)
write("Security Guard Valve")
term.setCursorPos(3,1)
write("Do you wish to enter?")
term.setCursorPos(5,1)
write("YES")
term.setCursorPos(6,1)
write("NO")
print " "
correctpass = "yes"
pass = read("*")
if pass == (correctpass) then
term.clear()
term.setCursorPos(1,1)
write("Please enter password: ")
else
print " "
write("Bye!")
os.shutdown()
end
correctpass = "defcomp"
pass = read("*")
if pass == (correctpass) then
term.clear()
term.setCursorPos(1,1)
write("Please enter!")
redstone.setOutput("back", true)
else
term.setCursorPos(1,1)
write("Denied!")
term.setCursorPos(3,1)
write("System shutdown")
sleep(300)
os.shutdown()
end

Should work
sidebelow #3
Posted 21 September 2012 - 07:26 PM
Well, it kind of worked but the text that comes up now is not the one i wanted.

it says:
Security Guard Valvestartup:3: bad argument: int
expected, got nil

The text i want to have is:
Security Guard Valve

Do you wish to enter?

YES
NO
sjele #4
Posted 21 September 2012 - 07:39 PM
It does work for me, in CC emulator. Copy paste the latest code i gave you. that was the one i tested
sidebelow #5
Posted 21 September 2012 - 07:55 PM
i dont understand how you can paste it in the emulator o.o


Edit: i fixed it, Thanks very much! +1