I don't understand the syntax

Hi people :smiley:

I’m not entirely new to programming and scripting (some experience with VBS, C++, Python 3, AutoIt), but I have a hard time understanding the syntax of this here.

Most likely I’m just skipping something that would explain a lot, but right now I just see snippets of code that are run in a completely random order without much dependency on other snippets.

Does anybody have some resources that explain it easily? Thanks! :smiley:

Can you post an example of what’s confusing?

If you know other languages, then this page should help you out:  https://coronalabs.com/learn-lua/

I wrote it assuming the person knows some C/Java/JavaScript/Actionship/PHP syntax.

One other thing. Lua is a single pass interpreter/compiler. In C and most C like languages, the compiler makes a pass to generate addresses for all variables/functions that are defined and then a second pass to plug those addresses in to where it’s going to be used. This lets you in C for instance, write your main() function at the top and functions that main() calls below it. Since Lua is a single pass any variable or function has to exist so it can be given an address before it’s used.  You have to code in reverse. Of course in C languages you could put main() as the last function and code in this reverse style, which many people do.

Rob

Can you post an example of what’s confusing?

If you know other languages, then this page should help you out:  https://coronalabs.com/learn-lua/

I wrote it assuming the person knows some C/Java/JavaScript/Actionship/PHP syntax.

One other thing. Lua is a single pass interpreter/compiler. In C and most C like languages, the compiler makes a pass to generate addresses for all variables/functions that are defined and then a second pass to plug those addresses in to where it’s going to be used. This lets you in C for instance, write your main() function at the top and functions that main() calls below it. Since Lua is a single pass any variable or function has to exist so it can be given an address before it’s used.  You have to code in reverse. Of course in C languages you could put main() as the last function and code in this reverse style, which many people do.

Rob