모듈:@ko/No globals

최근 편집: 2021년 4월 12일 (월) 21:51
페미위키 깃헙 가젯 봇 (토론 | 기여)님의 2021년 4월 12일 (월) 21:51 판 (Github @lens0021의 https://github.com/femiwiki/remote-gadgets/commit/b60cb09a)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

이 모듈에 대한 설명문서는 모듈:@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)