Module:Sandbox/一条茧
跳到导航
跳到搜索
function test()
n = random(10)
m = random(10,20)
s = f[[{{color|#66ccff|$n}}
<b>
$m, $nnnil
</b>
]]
code = read('U:一条茧')
return _(f'$s$code<pre>$code</pre>')
end
x = '{{color|#66ccff|aaa}} <b>bbb</b>'
function a()
return x
end
function b()
return _('{{PAGENAME}}') == 'Sandbox/一条茧' and _(x) or x
end
--------
function tip()
tips = {}
for i in read('U:一条茧/tips'):gsub('==END==.*',''):gmatch('#[^\n]*') do
tips[#tips+1] = i:sub(2)
end
return tips[random(#tips)]
end
function sign()
color = '#7F8070'
return f'[[U:一条茧|<i style=color:$color>一条茧</i>]]'
end
--------
function f(s, t)
t = t or _G
return (s:gsub("%$[a-zA-Z0-9_]*", function(block)
local key, fmt = block:match("%$([a-zA-Z0-9_]*)")
local val = t[key]
return tostring(val == nil and '$'..key or val)
end))
end
function _(s, t)
s = t and s or s:gsub('\n%s*', '')
return mw and mw.getCurrentFrame():preprocess(s) or s
end
function read(page)
return mw and mw.title.new(page):getContent() or ''
end
_random_seed = 0.1
function random(a,b)
a, b = a or 65536, b or 1
if a > b then a,b = b,a end
_random_seed = tonumber('0.'..tostring(os.clock()*2^_random_seed):sub(3):reverse())
return a+math.floor(_random_seed*(b-a))
end
return mw and _G or print(test())