Difference between revisions 52138 and 52139 on wikimaniawikilocal mt = getmetatable(_G) or {}
local oldIndex = mt.__index or function() return nil end⏎
function mt.__index = function(t, k)
if k ~= 'name' and k ~= 'arg' then
error('Tried to read nil global ' .. tostring(k), 2)
end
return oldIndex(t, k)
end
local oldNewindex = mt.__newindex or rawsetnil
end
function mt.__newindex(t, k, v)
if k ~= 'name' and k ~= 'arg' then
error('Tried to write global ' .. tostring(k), 2)
end
oldNewindexrawset(t, k, v)
end
setmetatable(_G, mt)
This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|