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

[SOLVED]'then expected'

Started by Rangicus, 08 September 2012 - 12:43 PM
Rangicus #1
Posted 08 September 2012 - 02:43 PM
So I am making a program to record how many times my door has tried to be opened with a wrong password,
but I get this error:


This is my code:

os.pullEvent = os.pullEventRaw
function PrintDoors()
x = x + 1
print("Failed Opening Attempts:(..x..)")
end
if rs.getInput("bottom") then
PrintDoors()
end
Help?
nolongerexistant #2
Posted 08 September 2012 - 02:51 PM
It says you are missing 'then' on line 7.
if rs.getInput("bottom")

should be:
if rs.getInput("bottom") then
Lettuce #3
Posted 08 September 2012 - 02:52 PM
if statements must have a "then" at the end, telling Lua you are done entering parameters. It should be

if rs.getInput("bottom") then
PrintDoors()
end

A simple mistake.
Rangicus #4
Posted 08 September 2012 - 02:55 PM
It says you are missing 'then' on line 7.
if rs.getInput("bottom")

should be:
if rs.getInput("bottom") then
Thank you that did work,
but now my other code doesn't work:

os.pullEvent = os.pullEventRaw
print("X-Cor:DoorLock")
print("Passcode Required For Entry")
x = io.read()
if x == "xcor" then
print("Passcode Correct!")
redstone.setOutput("left", true)
sleep(2.5)
redstone.setOutput("left", false)
os.reboot()
else
print("Passcode Incorrect!")
redpulse top 1 1
sleep(1)
os.reboot()
end 
Here is the error:

Line 13 '=' expected
(It doesnt say this exactly i just broke it down)
and in the redpulse help function it doesnt say that you need ()'s or ""'s
Help Again?
Lettuce #5
Posted 08 September 2012 - 02:58 PM
It's redpulse("top", 1, 1) you need to add the parenthesis, signalling a function call. I may have gotten the syntax wrong, but you NEED parenthesis.
nolongerexistant #6
Posted 08 September 2012 - 03:50 PM
redpulse top 1 1

Needs to be

redpulse("top", 1, 1)