I wonder how I can use removed modules again. When doing something like this:
-- Module local mod={} local gfx={} local another=require("anotherModule") local createGraphics= function(group) -- create Graphics here gfx.ball=display.newCircle... end local deleteStuff = function() package.loaded[("anotherModule] = nil another = nil end mod.createGraphics = createGraphics mod.deleteStuff = deleteStuff return mod
When I call the deleteStuff function from the mainfile where I have required the module above the local another variable is set to nil after the “anotherModule” was “unrequired” and set to nil.
When using the above module again I get an error like this:
attempt to index upvalue “another”
How can I make sure the local another is created again?