For Loop Optimization
Access to external locals (that is, variables that are local to an enclosing function) is not as fast as access to local variables, but it is still faster than access to globals.
The following code:
for i = 1, 1000000 do
x = x + math.sqrt(i)
end
Can be optimized to:
local math.sqrt = math.sqrt
for i = 1, 1000000 do
x = x + math.sqrt(i)
end
Object Behavior from OOP
You can use object behavior from Object Oriented Programming inside LUA too using tables.
Consider using this:
AnObject = {};
AnObject.AFunction = function ()
print"I am an object yeppie!"
end
AnObject.AFunction();
--Which call the AFunction inside AnObject class.
WTF? This isn't class, this is just a function inside a table! You cant do AnObject:AFunction(...) can you? That is what OOP is!
Sorry but this tutorial is innacurate