-
-
Save xordspar0/92a8618751becec4bc14ea220eb9f250 to your computer and use it in GitHub Desktop.
Separate __parent from the metatable
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 enabledFunctions = require("gamestates/enabledFunctions") | |
local function emptyFunction() end | |
local function index(t, key) return t.__parent[key] end | |
local function indexMeta(t, k) return enabledFunctions[key] and emptyFunction end | |
local function call(self) return setmetatable({__parent = self}, {__index = index}) end | |
local GameState = setmetatable({}, {__index = indexMeta, __call = call}) | |
return GameState |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
{__index = index} Does this creates a new metatable each time?