모듈:@ko/No globals

최근 편집: 2021년 4월 12일 (월) 21:51

이 모듈에 대한 설명문서는 모듈:@ko/No globals/설명문서에서 만들 수 있습니다

--[[
This module was originally on https://ko.wikipedia.org/wiki/모듈:No_globals and forked by Legunto
(https://github.com/femiwiki/legunto).
]]
local mt = getmetatable(_G) or {}
function mt.__index (t, k)
	if k ~= 'arg' then
		error('Tried to read nil global ' .. tostring(k), 2)
	end
	return nil
end
function mt.__newindex(t, k, v)
	if k ~= 'arg' then
		error('Tried to write global ' .. tostring(k), 2)
	end
	rawset(t, k, v)
end
setmetatable(_G, mt)