Variables should be camel case, starting with a lower case letter.
Object.variable
Object.variableTwoAll names of self functions, values and APIs must use British spelling. (i.e. colour not color, centre not center)
Methods should follow the same pattern, and use colon syntax.
Object:method()
Object:methodTwo()Enums should be capitalised and words should be separated using underscores.
Enum.VARIABLE
Enum.VARIABLE_TWO'Classes should be camel case and start with a capital letter.
class "Class"
class "ClassTwo"All function calls and definitions must have spaces on either side of the arguments.
function Class:hello( name, age )
log( "Hello, " .. name .. "! You're " .. age .. " years old." )
endStatic methods should be defined with dot syntax, and use camel case starting with a lower case letter.
function Class.static()
function Class.staticFunction()All public functions (and private if you feel like it or it's not obvious) must have comments above them in the structure below. If no return value or arguments are specificed simply ommit the line.
--[[
@desc A reasonable description of what the function does
@param [number] arg1 -- a description of what the variable is
@param [View] arg2 -- a description of what the variable is
@param [class] arg3 -- a description of what the variable is
@return [type] returnedValue -- a description of what the variable is
]]
function Class:functionName( arg1 )
return returnedValue
endEnum values in doc comments should be specified by the name of the table that holds it. Using ... should simply be writte as such.
--[[
@param [Animation.easing] easing -- the easing function of the animation
@param ... -- the arguments
]]In source files, locals should be defined at the top, followed by classes, then the class' methods. Class methods should be defined using colon syntax. For example,
local function printInfo( ... )
log( "Info: ", ... )
end
class "MyClass" {
name = "Object";
}
function MyClass:printInfo()
printInfo( self.name )
end" should be used to define strings, not '
A blank line should be left at the top and bottom of files, just to make it look a bit "prettier".
English spelling should be used (not American-English), so "colour" instead of "color", "grey" instead of "gray".
Replace single quotes with double:
Find: '(\w+)'
Replace: "$1"
Add spaces around brackets:
Find: \(([^-\s]+)\)
Replace: ( $1 )
Replace @instance comments on :initialise functions with @constructor:
Find: (?s)(\n\n--\[\[\n\t@)instance((.+):initialise\()
Replace: $1constructor$2
Find event functions that don't return true or false
function \w+:on.)\n(.(?<!return false)(?<!return true)\n)*?end
Change old event functions to have the correct argument ValueType
Find: ((?s)self:event(\s*(\w+)\w*,\sself.(\w+).+:\3(\s)Event Replace: