Diferencia entre revisiones de «Módulo:No globals»
wikitv>Faustino Sojo (Deshecha la edición 96213819 de ColdMindBRS777 (disc.)) |
wikitves>MusikAnimal (Undid revision 948472525 by [[Special:Contributions/w>DiBabelYurikBot|w>DiBabelYurikBot]] ([[User talk:w>DiBabelYurikBot|talk]])) |
||
Línea 2: | Línea 2: | ||
function mt.__index (t, k) | function mt.__index (t, k) | ||
if k ~= 'arg' then | if k ~= 'arg' then | ||
error(' | error('Tried to read nil global ' .. tostring(k), 2) | ||
end | end | ||
return nil | return nil | ||
Línea 8: | Línea 8: | ||
function mt.__newindex(t, k, v) | function mt.__newindex(t, k, v) | ||
if k ~= 'arg' then | if k ~= 'arg' then | ||
error('Tried to write global ' .. tostring(k), 2) | |||
end | end | ||
rawset(t, k, v) | rawset(t, k, v) | ||
end | end | ||
setmetatable(_G, mt) | setmetatable(_G, mt) |
Revisión del 08:28 1 abr 2020
La documentación para este módulo puede ser creada en Módulo:No globals/doc
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)