I see you have quite a few files already but I'm always in favour of breaking your code into even smaller files (even if it means more files). I tend to do it like this:
Code: Select all
--modules/obj_manager.lua
local activeInstances = require "modules/instances"
--rest of code
Code: Select all
--modules/instances.lua
return {
show = function(id)
--whatever module code you want
end
}
You can then freely call any functions of the activeInstances table and whatnot.
Code: Select all
--modules/obj_manager.lua
local activeInstances = require "modules/instances"
test = activeInstances.show(id)
--rest of code
As far as comments go, I seldom use them but when I do, it is like headers, like this:
Code: Select all
--player.lua
self = {}
self.hp = 100
self.mana = 100
------------------------------------------------
-- Player Health
------------------------------------------------
self.addHp = function(num)
self.hp = self.hp + num
end
return self
I feel it helps sometimes. But in general, I simply avoid large files. I used to have one that was 400 lines of code, it was getting hard to manage it. I broke it into multiple files and now it is 220 lines long - and I'm working on shrinking it further.
Another thing is syntax highlighting - ZB's standard syntax coloring is fine but you might benefit from testing other color schemes. Monokai, Zenburn, etc... all come preinstalled in ZB and, at least for me, make reading code much easier.