How To Incorporate "or" Into An If/then Statement?

Can someone please help me incorporate “or” into an if/then statement? This is what I tried and I think it is working well but I feel more comfortable if someone more experienced says this if this is correct or not. Also is the placement of “and” and “or” identical in an if/then statement? 

<lua>

        if (value = 1 ) or (value = 100 )then

           function ()

        end </lua>

Thanks for the help!

Also it seems I don’t know how to incorporate lua code. I thought it was <lua> code here </lua>

Hi Nate,

You’re pretty close!  The only change would be like this:

[lua]

if value == 1 or value == 100 then

function()

end

[/lua]

In conditional statements, you need to use two equal signs, ==, instead of just one, or you’ll get a syntax error when you try to run the code.

Also, in this example I dropped the parentheses, since they’re not strictly necessary.  But you’re welcome to keep them for clarity.  (Parentheses would be necessary for more complex logical constructions though.)

Also, the tags for lua code is actually [] (with lua inside) and [/] (with lua inside).  I can’t write it directly or it’ll think I mean the actual code tags!

Hope this helps!

  • Andrew

Thanks for the reply and explanation! Definitely helpful. 

With the new forums its square brackets around the language type instead of angle brackets (greater than/less than signs)

Hi Nate,

You’re pretty close!  The only change would be like this:

[lua]

if value == 1 or value == 100 then

function()

end

[/lua]

In conditional statements, you need to use two equal signs, ==, instead of just one, or you’ll get a syntax error when you try to run the code.

Also, in this example I dropped the parentheses, since they’re not strictly necessary.  But you’re welcome to keep them for clarity.  (Parentheses would be necessary for more complex logical constructions though.)

Also, the tags for lua code is actually [] (with lua inside) and [/] (with lua inside).  I can’t write it directly or it’ll think I mean the actual code tags!

Hope this helps!

  • Andrew

Thanks for the reply and explanation! Definitely helpful. 

With the new forums its square brackets around the language type instead of angle brackets (greater than/less than signs)