Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
XFactHD

Compile error "end expected"

Question

When trying to execute this code (http://pastebin.com/Kujgx5sx), the computer gives me the following error:

"control.lua:73: 'end' expected (to close 'if' at line 47) near <eof>"

If I comment out the erroring "if" block with the method to execute and the "end" statement or put an "end" statement at the expected position, it gives me the same error for another of the three "if" blocks. If I comment out all three if blocks, it expects me to put an "end" at <eof> to close the method. I don't get why, because all the "end" statements the computer expects are in the code. If I put all four "end" statements the computer expects, the program runs the way it should.

Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Luas if statements are ended just with a "then" not with a "then do".

 

EDIT:

Also in Lua you don't need an end after every elseif so it should look like this:

if test == 1 then
  print("Hello World!!!")
elseif test == 0 then
  print("Bye World!!!")
end

not like this:

if test == 1 then
  print("Hello World!!!")
end
elseif test == 0 then
  print("Bye World!!!")
end
end
Edited by tim4242
Link to post
Share on other sites
  • 0

That function still contained the same error, it should look like this:

local function getClick(_, x, y, _, _)
  if x > 1 and x < 3 and y > 1 and y < 3 and active == false then
    setStatus(true)
  elseif x > 1 and x < 3 and y > 1 and y < 3 and active == true then
    setStatus(false)
  elseif x > 72 and x < 74 and y > 0 and y < 2 then
    shutdown()
  end
end
Link to post
Share on other sites
  • 0

I didn't change the pastebin link when writing the EDIT.

Now I have another problem, if event.listen("touch", getClick) receives a touch signal, the defined callback function doesn't get triggered.

If I try this in a small test program that prints the results to screen, the coordinates are exactly as expected.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.