commit 8d44432e0f3cd5d5d0391988a688f1291ae35d59 Author: Connor Date: Mon May 25 18:56:30 2015 -0700 diff --git a/corepatchlua.lua b/corepatchlua.lua new file mode 100644 index 0000000..b7f3bc9 --- /dev/null +++ b/corepatchlua.lua @@ -0,0 +1,25 @@ +local mt = getmetatable(_G) +if mt == nil then + mt = {} + setmetatable(_G, mt) +end +mt.__declared = {} +function mt.__newindex(t, n, v) + if not mt.__declared[n] then + local info = debug.getinfo(2, "S") + if info and info.what ~= "main" and info.what ~= "C" then + error("cannot assign undeclared global '" .. tostring(n) .. "'", 2) + end + mt.__declared[n] = true + end + rawset(t, n, v) +end + +function mt.__index(t, n) + if not mt.__declared[n] then + local info = debug.getinfo(2, "S") + if info and info.what ~= "main" and info.what ~= "C" then + error("cannot use undeclared global '" .. tostring(n) .. "'", 2) + end + end +end \ No newline at end of file