- Introduction to lua
- Basic Setup
- Estrela for Luxinia
- Scenegraphs
- Scene Setup
- Models/Meshes
- Input handling
- Basic physics
- Physics surface properties
- Vehicle physics
- Using models
- Picking
- A Simple UDP Server
- GUI for the UDP Server
- Tetris attack clone prototype
- Stencil Shadows
- Sprite animation with matobject
- Project archives
- Estrela for Cg
- Specular mapping shader
- Material and Matobject
Local vs. Global variables
Knowing the scope of variables is an important issue. When designing your code, you need to know what values are needed for which pieces of code.
Writing functions
Functions are usually receiving arguments, do something with them and returns maybe a number of return values. All this is involving variables, which is in most cases a mix of global and local values.
function dosomething (arg1,arg2) local a = "Arg 1: "..tostring(arg1) local b = "Arg 2: "..tostring(arg2) print(a,b) return a,b end
This function has 4 local variables and is accessing 3 different global variables.
The local variables are:
arg1arg2ab
dosomethingtostringprint
local function dosomething (arg1,arg2)
The local keyword will forbid any access on a variable outside of the scope of the variable.
