15 replies to this topic
#1
Posted 26 October 2012 - 02:50 PM
Hello guys can someone help me ??
I have a program voor my Reactor to open de locked door, but I gain every time this error:
'end' expected (to close 'if' at line 12)
PROGRAM:
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# Hello Mr/Mrs, #")
print("# Type in your ID please: #")
print("# #")
print("# #")
print("##############################################")
write("")
ID = io.read()
if ID == "Mr. Reactor" then
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# Type now your password in please: #")
print("# #")
print("# #")
print("# #")
print("##############################################")
write("")
password = io.read()
if password == "1997" then
term.clear()
term.setCursorPos(5, 4)
print("##############################################")
print("# #")
print("# #")
print("# Welcome and be careful! #")
print("# #")
print("# #")
print("##############################################")
rs.setOutput("left", true)
sleep(3)
rs.setOutput("left", false)
os.shutdown()
end
else
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# Sorry, wrong input, #")
print("# Please try again! #")
print("# #")
print("# #")
print("# #")
print("##############################################")
write("")
ID = io.read()
if ID == "Mr. Reactor" then
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# Type now your password in please: #")
print("# #")
print("# #")
print("# #")
print("##############################################")
write("")
password = io.read()
if password == "1997" then
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# #")
print("# Welcome and be careful! #")
print("# #")
print("# #")
print("##############################################")
rs.setOutput("left", true)
sleep(3)
rs.setOutput("left", false)
os.shutdown()
end
else
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# Sorry, I need to #")
print("# shutdown! #")
print("# #")
print("# #")
print("##############################################")
sleep(1)
os.shutdown()
end
else
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# Sorry, wrong input, #")
print("# Please try again! #")
print("# #")
print("# #")
print("# #")
print("##############################################")
write("")
password = io.read()
if password == "1997" then
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# #")
print("# Welcome and be careful! #")
print("# #")
print("# #")
print("##############################################")
rs.setOutput("left", true)
sleep(3)
rs.setOutput("left", false)
os.shutdown()
end
else
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# Sorry, I need to #")
print("# shutdown! #")
print("# #")
print("# #")
print("##############################################")
sleep(1)
os.shutdown()
end
end
Please respond as soon as possible
do not look on the failed SHIFT + 3
I have a program voor my Reactor to open de locked door, but I gain every time this error:
'end' expected (to close 'if' at line 12)
PROGRAM:
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# Hello Mr/Mrs, #")
print("# Type in your ID please: #")
print("# #")
print("# #")
print("##############################################")
write("")
ID = io.read()
if ID == "Mr. Reactor" then
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# Type now your password in please: #")
print("# #")
print("# #")
print("# #")
print("##############################################")
write("")
password = io.read()
if password == "1997" then
term.clear()
term.setCursorPos(5, 4)
print("##############################################")
print("# #")
print("# #")
print("# Welcome and be careful! #")
print("# #")
print("# #")
print("##############################################")
rs.setOutput("left", true)
sleep(3)
rs.setOutput("left", false)
os.shutdown()
end
else
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# Sorry, wrong input, #")
print("# Please try again! #")
print("# #")
print("# #")
print("# #")
print("##############################################")
write("")
ID = io.read()
if ID == "Mr. Reactor" then
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# Type now your password in please: #")
print("# #")
print("# #")
print("# #")
print("##############################################")
write("")
password = io.read()
if password == "1997" then
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# #")
print("# Welcome and be careful! #")
print("# #")
print("# #")
print("##############################################")
rs.setOutput("left", true)
sleep(3)
rs.setOutput("left", false)
os.shutdown()
end
else
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# Sorry, I need to #")
print("# shutdown! #")
print("# #")
print("# #")
print("##############################################")
sleep(1)
os.shutdown()
end
else
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# Sorry, wrong input, #")
print("# Please try again! #")
print("# #")
print("# #")
print("# #")
print("##############################################")
write("")
password = io.read()
if password == "1997" then
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# #")
print("# Welcome and be careful! #")
print("# #")
print("# #")
print("##############################################")
rs.setOutput("left", true)
sleep(3)
rs.setOutput("left", false)
os.shutdown()
end
else
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# Sorry, I need to #")
print("# shutdown! #")
print("# #")
print("# #")
print("##############################################")
sleep(1)
os.shutdown()
end
end
Please respond as soon as possible
do not look on the failed SHIFT + 3
#2
Posted 26 October 2012 - 02:52 PM
oooh and that 'end' expected is on line 92
#3
Posted 26 October 2012 - 02:53 PM
You could use a loop instead of repeating the code 4 times
#4
Posted 26 October 2012 - 02:58 PM
I am not so pro in Computercraft and what you are saying with WindOS
xD
xD
#5
Posted 26 October 2012 - 02:58 PM
Just a couple tips for the future.
Use code tags to make your code easier for people to read. [ code] [ /code]
If you post questions like this in the "Ask a Pro" board, there are usually a ton of programmers just waiting to help.
Use code tags to make your code easier for people to read. [ code] [ /code]
If you post questions like this in the "Ask a Pro" board, there are usually a ton of programmers just waiting to help.
#7
Posted 26 October 2012 - 03:03 PM
use this code:
term.clear()
term.setCursorPos(5, 5)
while true do
print("##############################################")
print("# #")
print("# Hello Mr/Mrs, #")
print("# Type in your ID please: #")
print("# #")
print("# #")
print("##############################################")
write("")
ID = io.read()
if ID == "Mr. Reactor" then
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# Type now your password in please: #")
print("# #")
print("# #")
print("# #")
print("##############################################")
write("")
password = io.read()
if password == "1997" then
term.clear()
term.setCursorPos(5, 4)
print("##############################################")
print("# #")
print("# #")
print("# Welcome and be careful! #")
print("# #")
print("# #")
print("##############################################")
rs.setOutput("left", true)
sleep(3)
rs.setOutput("left", false)
end
else
term.clear()
term.setCursorPos(5, 5)
print("##############################################")
print("# #")
print("# Sorry, wrong input, #")
print("# Please try again! #")
print("# #")
print("# #")
print("# #")
print("##############################################")
end
end
end
#8
Posted 26 October 2012 - 03:15 PM
Why:
font=helvetica, arial, sans-serif] by print.....
?????
font=helvetica, arial, sans-serif] by print.....
?????
#9
Posted 26 October 2012 - 03:21 PM
my error, already fixed
#10
Posted 26 October 2012 - 03:40 PM
Ok
I am trying using loops but i need to see a tutorial first.
I don't know how it works xD
I am trying using loops but i need to see a tutorial first.
I don't know how it works xD
#11
Posted 26 October 2012 - 03:42 PM
the loops are easy, use the loop and when you said end, it will repeat, accordingly to the loop, and you can break it or finish it, according to the loop
#12
Posted 26 October 2012 - 04:04 PM
Well, a loop is simple to use. You just set conditions for your loops, in this case you need to make a loop when you input a wrong password, something like:
Here you're telling the computer: If the password is correct, open the door. If it is not correct say Wrong Password and ask for the password again
function password()
if pass == "Password" then
print("Welcome USER")
rs.setOutput("side", true)
sleep(3)
rs.setOutput("side", false)
password()
else
print("Wrong Password!")
sleep(3)
password()
end
end
Here you're telling the computer: If the password is correct, open the door. If it is not correct say Wrong Password and ask for the password again
#13
Posted 08 November 2012 - 03:55 PM
EDIT: what I said was stupid
#14
Posted 09 November 2012 - 07:12 AM
io.read() I belive does not read from the input that you type in.. Someone correct me if I'm wrong though.
A better way would be to do is input=read(FORMATSTYLE)
A better way would be to do is input=read(FORMATSTYLE)
#16
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












