置顶公告:【置顶】关于临时开启评论区所有功能的公告(2022.10.22) | 【置顶】关于本站Widget恢复使用的公告
  • 你好~!欢迎来到萌娘百科镜像站!如需查看或编辑,请联系本站管理员注册账号。
  • 本镜像站和其他萌娘百科的镜像站无关,请注意分别。

Module:Sandbox/一条茧

猛汉♂百科,万男皆可猛的百科全书!转载请标注来源页面的网页链接,并声明引自猛汉百科。内容不可商用。
跳到导航 跳到搜索
Template-info.svg 模块文档  [查看] [编辑] [历史] [刷新]

tips:

tips:

{{color|#66ccff|aaa}} bbb

aaa bbb

218, $nnnil

一条茧 2023年1月23日 (一) 06:58 (CST)


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())