Difference between revisions of "Module:No globals"

From 3D printer from scratch
Jump to: navigation, search
(Fixing content model)
m (1 revision imported)
(No difference)

Latest revision as of 15:57, 17 March 2018

Documentation for this module may be created at Module:No globals/doc

sh: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8): No such file or directory
local mt = getmetatable(_G) or {}
function mt.__index (t, k)
	if k ~= 'arg' then
		error('Tried to read nil global ' .. tostring(k), 2)
	return nil
function mt.__newindex(t, k, v)
	if k ~= 'arg' then
		error('Tried to write global ' .. tostring(k), 2)
	rawset(t, k, v)
setmetatable(_G, mt)