-
Notifications
You must be signed in to change notification settings - Fork 20
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)
-
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
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```
9. **Long and Informative Variable Names** - as opposed to tons of comments explaining every little thing i.e. `numberOfObjectsToAddPerInterval = 5;` vs `toAdd = 5; --This is the number of objects to add per interval`