I’m sure everyone who uses ModuleScripts extensively can relate to wanting to have a way to clear the cache.
I mean sure, if you have a table returning function, you’ll just get a new table from the module, but if you’re just returning a table, the next time you load the same module it will return the exact same bs from cache.
Lua has “package.loaded.modulename = nil” for removing a module from the cache, why shouldn’t roblox?
I feel like this would break a modulescript’s expected behavior
What happens if you delete a modulescript? If you still need it you could replace it with a clone?
Having ModuleScripts act as singletons is actually super valuable, and I’m really happy they act like that. If you want to return a new version of whatever it is, use a function. For instance:
-- Module:
local Foo = {}
function Foo.new()
local foo = {}
return foo
end
return Foo
-- Script:
local Foo = require(FooModule)
local foo = Foo.new()
[quote] Having ModuleScripts act as singletons is actually super valuable, and I’m really happy they act like that. If you want to return a new version of whatever it is, use a function. For instance:
[code]
Module:
local Foo = {}
function Foo.new()
local foo = {}
return foo
end
return Foo
Script:
local Foo = require(FooModule)
local foo = Foo.new()
[/code] [/quote]
What if someone(me) had over 70 modules each returning tables and after a long time realized I needed “new tables” every time I required the modules.
I know that’s just my own stupidity, but there are plenty of uses for this, surely if no-one needed it, Lua didn’t have a way to clear the cache.