跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
特殊页面
Minimalist Tower Defense Wiki
搜索
搜索
外观
创建账号
登录
个人工具
创建账号
登录
查看“︁模块:TowerTable/sandbox”︁的源代码
模块
讨论
English
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
页面信息
外观
移至侧栏
隐藏
←
模块:TowerTable/sandbox
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p = {} local cfg = { wrapStyle = 'overflow-x:auto;width:100%;', tableStyle = 'background-color:#212121;color: #EAECF0;white-space: nowrap;', defaultClass = 'wikitable', firstHeader = "'''防御塔等级与属性项(总和)'''", errCategory = '[[Category:防御塔表格需要修复]]', } local function trim(s) return mw.text.trim(s or '') end local function cell(header, value) return '{{c|' .. header .. '|' .. value .. '}}' end local function fallbackLabel(call) local body = call:gsub('^{{%s*[Tt]wtl%s*|', ''):gsub('%s*}}$', '') local parts = {} for a in mw.text.gsplit(body, '|') do parts[#parts + 1] = trim(a) end local key = parts[1] or '' local arg = parts[2] or '' local map = { ['基础面板'] = '<strong>基础面板</strong>', ['基础升级'] = '<strong>{{c|2|基础升级}}</strong>', ['进阶升级'] = '<strong>{{c|3|进阶升级}}</strong>', ['q'] = '<strong>{{c|4|分支Q:' .. arg .. '}}</strong>', ['w'] = '<strong>{{c|4|分支W:' .. arg .. '}}</strong>', ['5q'] = '<strong>{{c|5|分支Q:' .. arg .. '}}</strong>', ['5w'] = '<strong>{{c|5|分支W:' .. arg .. '}}</strong>', ['4q5q'] = '<strong>{{c|4|(分支Q:)}}{{c|5|分支Q:' .. arg .. '}}</strong>', ['4q5w'] = '<strong>{{c|4|(分支Q:)}}{{c|5|分支W:' .. arg .. '}}</strong>', ['4w5q'] = '<strong>{{c|4|(分支W:)}}{{c|5|分支Q:' .. arg .. '}}</strong>', ['4w5w'] = '<strong>{{c|4|(分支W:)}}{{c|5|分支W:' .. arg .. '}}</strong>', ['1'] = '<strong>' .. arg .. '</strong>', ['2'] = '<strong>{{c|2|' .. arg .. '}}</strong>', ['3'] = '<strong>{{c|3|' .. arg .. '}}</strong>', ['4'] = '<strong>{{c|4|' .. arg .. '}}</strong>', ['5'] = '<strong>{{c|5|' .. arg .. '}}</strong>', ['wno'] = '<strong>{{c|4|分支W:无W分支}}</strong> || colspan="' .. arg .. '" |', ['noup'] = '<strong>该防御塔无升级</strong> || colspan="' .. arg .. '" |', } return '| ' .. (map[key] or '未知的章节') end function p.main(frame) local args = frame.args local parent = frame:getParent() if parent and parent.args and (parent.args.header or parent.args.rows) then args = parent.args end local class = args.class or cfg.defaultClass local headerStr = trim(args.header) local rowsStr = trim(args.rows) local footerStr = trim(args.footer) local issues = {} if headerStr == '' then return cfg.errCategory end local headers = {} for h in mw.text.gsplit(headerStr, ',') do headers[#headers + 1] = trim(h) end local ncol = #headers if ncol == 0 then return cfg.errCategory end local useFallback = args.forcefallback == '1' or not mw.title.new('Template:Twtl').exists local tableText = '<div style="' .. cfg.wrapStyle .. '">\n' .. '{| class="' .. class .. '" style="' .. cfg.tableStyle .. '"\n' .. '| ' .. cfg.firstHeader for _, h in ipairs(headers) do tableText = tableText .. ' || ' .. cell(h, h) end tableText = tableText .. '\n' for row in mw.text.gsplit(rowsStr, ';') do local rowTrim = trim(row) if rowTrim ~= '' then local cells = {} for c in mw.text.gsplit(rowTrim, ',') do cells[#cells + 1] = trim(c) end local firstCol = cells[1] or '' local rowText if firstCol:match('^{{') then if useFallback and firstCol:match('^{{%s*[Tt]wtl%s*|') then rowText = '|-\n' .. fallbackLabel(firstCol) else rowText = firstCol end else firstCol = firstCol:gsub('^|%-%s*', '') if firstCol == '' then issues[#issues + 1] = 'empty-first-cell' firstCol = ' ' end rowText = '|-\n| ' .. firstCol end tableText = tableText .. rowText .. '\n' for i = 2, #cells do local header = headers[i - 1] if header == nil then issues[#issues + 1] = 'extra-cell' break end local value = cells[i]:gsub('|', '{{!}}') tableText = tableText .. (i == 2 and '| ' or ' || ') .. cell(header, value) end if #cells - 1 < ncol then issues[#issues + 1] = 'missing-cell' for i = #cells + 1, ncol + 1 do tableText = tableText .. (i == 2 and '| ' or ' || ') .. cell(headers[i - 1], '') end end tableText = tableText .. '\n' end end if footerStr ~= '' then tableText = tableText .. '|-\n| ' .. footerStr .. '\n' end tableText = tableText .. '|}\n</div>' local out = frame:preprocess(tableText) if #issues > 0 then out = out .. cfg.errCategory end return out end return p
此页面嵌入的页面:
模块:TowerTable/sandbox/doc
(
查看源代码
)
返回
模块:TowerTable/sandbox
。
搜索
搜索
查看“︁模块:TowerTable/sandbox”︁的源代码
添加话题