Jump to content




[SOLVED]'then expected'


  • You cannot reply to this topic
5 replies to this topic

#1 dw28394

  • Members
  • 84 posts

Posted 08 September 2012 - 01: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:
Posted Image

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?

#2 nolongerexistant

  • Validating
  • 201 posts
  • LocationNetherlands

Posted 08 September 2012 - 01:51 PM

It says you are missing 'then' on line 7.
if rs.getInput("bottom")

should be:
if rs.getInput("bottom") then


#3 Lettuce

  • Members
  • 210 posts
  • LocationIn your fridge.

Posted 08 September 2012 - 01: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.

#4 dw28394

  • Members
  • 84 posts

Posted 08 September 2012 - 01:55 PM

View PostSnakybo, on 08 September 2012 - 01:51 PM, said:

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?

#5 Lettuce

  • Members
  • 210 posts
  • LocationIn your fridge.

Posted 08 September 2012 - 01: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.

#6 nolongerexistant

  • Validating
  • 201 posts
  • LocationNetherlands

Posted 08 September 2012 - 02:50 PM

redpulse top 1 1

Needs to be

redpulse("top", 1, 1)






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users