Jump to content




[LUA][Error] 'end' expected


8 replies to this topic

#1 Mackan90096

  • Signature Abuser
  • 518 posts
  • LocationIn my basement.

Posted 22 March 2013 - 06:56 AM

Hi!
I am trying to make a ordering script that will send the orders to my email which i have setup.

But i keep getting errors! :(

Please help me.

Script:
Spoiler


#2 OmegaVest

  • Members
  • 436 posts

Posted 22 March 2013 - 07:09 AM

I think the biggest problem you have is incorrect if-block grammar.

It should go as such:

if [condition] then
  -- Body
elseif [condition] then
  -- Body
else
  -- Body
end

Also, it may help to format your code so that every time you open a conditional statement, you indent, and then when you close one (like an end or the next case), you de-indent. ie
function func(dark)
  while [cond] do
    if dark then
      --something
    else
      --somethingelse
    end
  end
end


It helps to find missing or extra ends.

#3 faubiguy

  • Members
  • 213 posts

Posted 22 March 2013 - 07:09 AM

I fixed some errors I found and commented what they were (Including the end expected). I can't test this right now, but It looks right.

Spoiler

EDIT: There was indentation, but the forum software removed it.
EDIT 2: Went back and added indentation again.

#4 Mackan90096

  • Signature Abuser
  • 518 posts
  • LocationIn my basement.

Posted 22 March 2013 - 07:22 AM

Ah, thanks!

#5 Mackan90096

  • Signature Abuser
  • 518 posts
  • LocationIn my basement.

Posted 22 March 2013 - 07:26 AM

View Postfaubiguy, on 22 March 2013 - 07:09 AM, said:

I fixed some errors I found and commented what they were (Including the end expected). I can't test this right now, but It looks right.

Spoiler

EDIT: There was indentation, but the forum software removed it.

You might also be

I tried that but i get 'end' expected to close if at line 14

#6 OmegaVest

  • Members
  • 436 posts

Posted 22 March 2013 - 07:35 AM

Okay, so I reformatted faubiguy's code, and here is what I got, let's see if you catch the problem.
Spoiler



EDIT: I changed some of my own errors in formatting, make sure you are commenting on the corrected version. Also, the forum code tags do some weird things with spacing, I'll grant that.

#7 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 22 March 2013 - 07:36 AM

Faubiguy, when pasting code, click "Editing mode" before (I think it's that - it's the top left icon in the new post section).
Doing that will keep the indentation.

I have to do this for Chrome, but not firefox. Not sure about other browsers

#8 Mackan90096

  • Signature Abuser
  • 518 posts
  • LocationIn my basement.

Posted 22 March 2013 - 07:42 AM

View PostOmegaVest, on 22 March 2013 - 07:35 AM, said:

Okay, so I reformatted faubiguy's code, and here is what I got, let's see if you catch the problem.
Spoiler



EDIT: I changed some of my own errors in formatting, make sure you are commenting on the corrected version. Also, the forum code tags do some weird things with spacing, I'll grant that.

This worked! THANKS!

#9 Mackan90096

  • Signature Abuser
  • 518 posts
  • LocationIn my basement.

Posted 22 March 2013 - 08:00 AM

Can i make this send the input and the orderid?

Edit: Nvm





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users