--- description: "Use when writing or editing Lua scripts (.lua files). V-Gears Lua style: indentation, naming, locals, end terminators, doxygen comments." applyTo: "**/*.lua" --- # V-Gears Lua Style Essentials Full guide: [doc/STYLE-LUA.md](../../doc/STYLE-LUA.md). - Indent with four spaces. Never use tabs. - Variables: short `snake_case` (`front_color`); larger scope → more descriptive names. - Functions and classes: `PascalCase`. Constants: `ALL_CAPS`. Module names: all `lowercase`. - Always use `local` for variables and functions; avoid globals. - Always close blocks with `end`; on long blocks, annotate the closing `end` with a comment (`end -- if`). - One space after `--` in comments. - Document every block of code with doxygen-style docstrings: ```lua --[[ Retrieves a bit variable. @param bank Memory bank (0-index, as in game). @return 1 or 0 ]] ``` - Test for non-`nil` idiomatically: `if line then`, not `if line ~= nil then`. - Note: Lua generated by the installer's script decompiler follows these rules on a best-effort basis — do not hand-reformat large generated files.