
Lower camelCase for locals/parameters

Upper CamelCase for everything else

No semicolons

Always use verbose operators, e.g: not, and, or

Spaces after commas and delimiters unless no arguments/keyvalues are passed, e.g:
[lua]
func1( a, b, c )
func2()
local tbl1 = { a, b, c }
local tbl2 = {}
[/lua]
 Document everything
Example:
[lua]
— All functions are available also as methods of the complex number class.
– Operators work with both numbers and complex numbers.
– @author Pac
– @classmod complex
local complex = {}
complex.__index = complex
complex.__newindex = function() error( “attempt to index complex value” ) end
— Constructors
– @section Constructors
— Creates a new complex number
– @tparam[opt=0] number real
– @tparam[opt=0] number imag
– @treturn complex
– @usage local c = complex.New( 1, 1 )
function complex.New( real, imag )
local obj = {}
obj.Real = real or 0
obj.Imag = imag or 0
setmetatable( obj, complex )
return obj
end
— Fields
– @section Fields
— Real part
complex.Real = 0
— Imaginary part
complex.Imag = 0
— Functions
– @section Functions
— Returns whether the given complex numbers are equal
– @tparam complex c1
– @tparam complex c2
– @treturn bool
function complex.Equal( c1, c2 )
return c1.Real == c2.Real and c1.Imag == c2.Imag
end
— Returns the sum of the given complex numbers
– @tparam complex c1
– @tparam complex c2
– @treturn complex
function complex.Add( c1, c2 )
local real = c1.Real + c2.Real
local imag = c1.Imag + c2.Imag
return complex.New( real, imag )
end
— Returns the difference of the given complex numbers
– @tparam complex c1
– @tparam complex c2
– @treturn complex
function complex.Sub( c1, c2 )
local real = c1.Real  c2.Real
local imag = c1.Imag  c2.Imag
return complex.New( real, imag )
end
[/lua]