Hi folks
Like many noobs, I’ve been learning outdated and depricated tutorials, the latest of which was starting all my modules with module(…, package.seeall)
Then I came across this blog…
https://coronalabs.com/blog/2011/09/05/a-better-approach-to-external-modules/
I’ve now hit a brick wall. I’ve lost 2 days re-writing all my modules and code and re-re-writing, starting all over again and so and so forth. :wacko:
Let me point out that my code worked fine before I removed module(…, package.seeall)
Making my modules into local tables works fine until I try and call them more than once, here’s one of my short modules and the call made to it…
clock.lua
local clock = {}
clockGroup = display.newGroup()
clocks = {}
for i = 1, #loadClock.animClock do
clocks[i] = display.newImageRect( clockGroup, loadClock.animClock[i], 160, 160)
clocks[i].x = _W*0.92
clocks[i].y = _H*0.82
clocks[i].isVisible = false
end
clockGroup.currentClock = 1
clocks[clockGroup.currentClock].isVisible = true
clock.clocks = clocks
return clock
main.lua
local clock = require(“clock”)
The clock works fine the first time round but when I require the clock a second time it doesn’t reset.
I’ve tried package.loaded[“clock”] = nil and clock.remove = true
This happens with every module I call more than once, not just the above example, what am I missing?
Any help would be greatly appreciated.