I'm in the midst of a new Löve project and trying to use fewer globals this time around. :-)
As such, I've made my modules something along the lines of this:
Code: Select all
local module = {}
local a = 0
local function doThing()
print("Hello")
a = 5
end
module.a = a
module.doThing = doThing
return module
Code: Select all
local mod = require("module")
function love.load()
mod.doThing()
print(mod.a)
end
Code: Select all
"Hello"
0
I could always grab them as a table via a function, I suppose, but is there a more elegant way to expose variables like this?