Created
September 23, 2023 15:47
-
-
Save GoodClover/fdfe38e20d8f79570f5710b8f40c2b4b to your computer and use it in GitHub Desktop.
Change to a modifiable _ENV, whilst keeping access to existing environments.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local mkenvlist_mt = { | |
__index = function(self, index) | |
for _, env in ipairs(self._ENV_READ_LIST) do | |
local value = env[index] | |
if value != nil then | |
return value | |
end | |
end | |
return nil | |
end, | |
__newindex = function(self, index, value) | |
self._ENV_WRITE[index] = value | |
end, | |
} | |
local function mkenvlist(write, reads) | |
return setmetatable({ _ENV_WRITE=write, _ENV_READ_LIST=reads }, mkenvlist_mt) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
e.g.