Control Structure Statements

What are control structure statements? Let’s remember our “shopping list” metaphor: a list of instructions to your spouse.

These statements are the real intelligence of your code.

I don’t want to put pressure on you … but you have to master this.

Conditional Statements

This is the basic control statement, and the most used: If … Then … Else.

With this amazing “if” statement, you’re able to execute some code only if a certain condition is verified. I always use this example:

If it rains, take an umbrella.

In Lua and in a “game coding” situation, it looks like this:

ifig0018.jpg

This means that if the distance between the ...

Get Create 2D Mobile Games with Corona SDK now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.