Another Question relating to if/then statements

So I have a timer that counts every 1 second. I also have a separate function that is put as

[lua]if (timer == 10) then

statement = true

end[/lua]
How should I word it if I want a function to go through on the times: 10, 17, 40? (there is no pattern for which numbers come up) How can I play the word “or” into my if/then statement in order to make it work?

Also how could I word it to lets say make statement = true on every multiple of 10. So at every 10, 100, 1000, etc.

Thanks ahead of time for any answers given. [import]uid: 35535 topic_id: 10344 reply_id: 310344[/import]

Well, you can do this:

if (timer == 10) or (timer == 17) or (timer == 40) then  

…and if those were the only 3 numbers you needed, you’re good to go.

But it sounds like those numbers could/will change so you’ll have to come up with a different solution.

If the numbers change but there will always be just 3 of them, you can define three variables and then test against those (timer == firstNum, timer == secondNum, etc.)

For running the statement on every multiple of 10, you could use the modulo operator %, something like this:

if ((timer % 10) == 0) then  

That will execute the code when timer = 10, 20, 30, 40, etc.

To give you a more precise answer will require more details about what you’re trying to do.

But maybe this is enough to get you going on the right track.

Also, someone else may have a better way to handle this and pipe up. :slight_smile:

Jay

[import]uid: 9440 topic_id: 10344 reply_id: 37848[/import]

Hey thanks so much for that! That is what I was looking for [import]uid: 35535 topic_id: 10344 reply_id: 37867[/import]