Lua Programming/How to Lua/scope
From Wikibooks, open books for an open world
There are two levels of variable scope in lua
The lua programming language offers two levels of variable scope:
- global - Global variables exist always and are visible everywhere from within the program.
- local - Local variables exist only within the block in which they are created
Variables are global by default
Local variables have lexical scope
The outer scope (other than the global scope) of a nested function may not be accessed.