Posted 07 December 2012 - 07:56 AM
When you initially call something and set it's scope (the level at which the memory allocated to it will remain), you use a declaration, local variable. Usually the declaration is combined with an assignment, to avoid having "got nil" errors, but the assignment is a separate operation from the declaration. You only need to declare a variable once, after that you will change the value using assignments.
If you assign a variable that has not previously been declared, then lua will make the new variable global in scope. It is good practice to avoid this when you don't have a good reason for making it global other than because you forgot to declare it.