Skip to content

Instantly share code, notes, and snippets.

@itsfrank
Created April 6, 2024 20:18
Show Gist options
  • Save itsfrank/c3e193338612eb00324dc2340aaffa79 to your computer and use it in GitHub Desktop.
Save itsfrank/c3e193338612eb00324dc2340aaffa79 to your computer and use it in GitHub Desktop.
Temporary workaround for lune issue with module caching
-- this file is only necessary because lune currently does not cache modules properly
-- see: https://github.com/lune-org/lune/issues/138
if _G._modulestate == nil then
_G._modulestate = {}
end
local modulestate = {}
-- if the state has not been initialized yet, we will use init to set values
function modulestate.get_state(s: string, init: { [any]: any }?): { [any]: any }
if _G._modulestate[s] == nil then
_G._modulestate[s] = {}
if init ~= nil then
for k, v in pairs(init) do
_G._modulestate[s][k] = v
end
end
end
return _G._modulestate[s]
end
return modulestate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment