PEP8-inspired linting of main.lua

Guidelines used:

1. Top-level function defs have three newlines between them, other lines
separated with one or two for readability
2. Indent either within nested control structures, or when contintuing a
line. Control structure nesting is one indent level, line continuation is
two
3. When continuing lines with operators, operator goes on the preceding
line
4. When assigning keyword arguments, leave no space between kwarg and
value
5. Some other stuff I'm probably not remembering