打开/关闭菜单
打开/关闭个人菜单
未登录
如果您进行任何编辑,您的IP地址会公开展示。

Module:No globals:修订间差异

来自索尼克百科
添加的内容 删除的内容
(ep:修正错误翻译)
imported>Wr
(导入1个版本)
 
(未显示2个用户的5个中间版本)
第2行: 第2行:
function mt.__index (t, k)
function mt.__index (t, k)
if k ~= 'arg' then
if k ~= 'arg' then
error('尝试读取空全局变量:' .. tostring(k), 2)
error('Tried to read nil global ' .. tostring(k), 2)
end
end
return nil
return nil
第8行: 第8行:
function mt.__newindex(t, k, v)
function mt.__newindex(t, k, v)
if k ~= 'arg' then
if k ~= 'arg' then
error('尝试写入全局变量:' .. tostring(k), 2)
error('Tried to write global ' .. tostring(k), 2)
end
end
rawset(t, k, v)
rawset(t, k, v)

2022年7月21日 (四) 09:21的最新版本

可在Module: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)
我们提供服务需要使用Cookie。您使用我们的服务,即表示您同意我们使用Cookie。