This tutorial is part 1 of a series:

  1. Lua Style Guide ← You Are Here
    1. Formatting with StyLua
  2. Lua Scripting Best Practices
  3. Organizing Lua Code With Modules
  4. Module Best Practices

Style

Be concise and consistent. It’s better to stick to one “good enough” styling rather than constantly experimenting and trying to over optimize. This style guide contains a list of guidelines that you should follow when writing trigger Lua code to make the code more readable and consistent.

First and foremost, be sure to install and properly setup StyLua, which will automatically format your code upon saving : Formatting with StyLua

File Structure

A trigger file generally consists the following parts in order: