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

Module:Gochicolor

猛汉♂百科,万男皆可猛的百科全书!转载请标注来源页面的网页链接,并声明引自猛汉百科。内容不可商用。
跳到导航 跳到搜索
Template-info.svg 模块文档  [创建] [刷新]
  1. local hex_table = mw.loadData("Module:Gochicolor/Dataset")
  2. local p = {}
  3. local function find_hex(chara, colortype)
  4. local hex
  5. hex = hex_table[chara] and hex_table[chara][colortype]
  6. if hex then
  7. return hex
  8. else
  9. hex = hex_table["default"]["base"]
  10. return hex
  11. end
  12. end
  13. function p.code(frame)
  14. local chara = frame.args[1]
  15. local colortype = frame.args[2]
  16. local hex_code = find_hex(chara, colortype)
  17. return mw.text.nowiki(hex_code)
  18. end
  19. function p.block(frame)
  20. local chara = frame.args[1]
  21. local hex_text = frame.args[2]
  22. local hex_block = find_hex(chara, "base")
  23. local chara_link = find_hex(chara, "link")
  24. local block = '<span style="width:0.8em; height:0.8em; background-color:' .. hex_block .. ';display:inline-block;"></span>'
  25. local text = block .. ' [[:' .. chara_link .. '|' .. chara .. ']]'
  26. if hex_text then
  27. if hex_text == "color" then
  28. hex_text = find_hex(chara, "dark")
  29. end
  30. text = block .. ' [[:' .. chara_link .. '|<span style="color:' .. hex_text .. '">' .. chara .. '</span>]]'
  31. end
  32. return text
  33. end
  34. return p