Skip to content

Instantly share code, notes, and snippets.

View xordspar0's full-sized avatar

Jordan Christiansen xordspar0

View GitHub Profile
@xordspar0
xordspar0 / GameState.lua
Last active April 3, 2018 15:18 — forked from randomguyeatspotato/GameState.lua
Separate __parent from the metatable
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})