Skip to content

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.

  1. Line Endings - Always end with a semicolon. So local var = "hi"; instead of local var = "hi"
  2. Local Variable Names - camelCasing. So local var... vs local Var... and local someVar... vs local somevar... or local SomeVar...
  3. Global Variable Names - PascalCasing. So Var... vs var... and SomeVar... vs somevar... or someVar... or Somevar...
  4. Function Names - PascalCase. So function SomeFunction() vs function someFunction() or function Somefunction() or function somefunction() or function some_function()
  5. Tabbing vs. Spaces - Use tabs!
  6. Spacing Around Symbols (, == = + - * /) - Spaced out except for /. So x = y + z... vs x=y+z... and x = y - z vs x = y-z and x = y * z... vs x = y*z... and x = y/z vs x = y / z and x == y vs x = y and function(p1, p2, p3) vs function(p1,p2,p3)
  7. 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 vs local 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`
Clone this wiki locally