This repository was archived by the owner on Jan 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Lua Style Guide
Gareth YR edited this page Sep 17, 2019
·
6 revisions
Please follow the following rules for lua styling. Note: all lua changes will reviewed according to this style guide, save yourself and the reviewer(s) some time and adhere to this please.
-
Line Endings - Always end with a semicolon. So
local var = "hi";
instead oflocal var = "hi"
-
Local Variable Names - camelCasing. So
local var...
vslocal Var...
andlocal someVar...
vslocal somevar...
orlocal SomeVar...
-
Global Variable Names - PascalCasing. So
Var...
vsvar...
andSomeVar...
vssomevar...
orsomeVar...
orSomevar...
-
Function Names - PascalCase. So
function SomeFunction()
vsfunction someFunction()
orfunction Somefunction()
orfunction somefunction()
orfunction some_function()
- Tabbing vs. Spaces - Use tabs!
-
Spacing Around Symbols (, == = + - * /) - Spaced out except for /. So
x = y + z...
vsx=y+z...
andx = y - z
vsx = y-z
andx = y * z...
vsx = y*z...
andx = y/z
vsx = y / z
andx == y
vsx = y
andfunction(p1, p2, p3)
vsfunction(p1,p2,p3)
-
Long and Informative Variable Names - as opposed to tons of comments explaining every little thing i.e.
numberOfObjectsToAddPerInterval = 5;
vstoAdd = 5; --This is the number of objects to add per interval
-
Commenting Style - No space after
--
and start comment with capital letter. Comments longer than a few words should be on their own line above the line of code.i.e. local v = 5; --The v stands for variable
vslocal v = 5; -- the v stands for variable
and
--The v below stands for variable because that's what it is, it's a variable and it's useful to vary things
local v = 5;
vs
local v = 5; --The v below stands for variable because that's what it is, it's a variable and it's useful to vary things