跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
特殊页面
Minimalist Tower Defense Wiki
搜索
搜索
外观
创建账号
登录
个人工具
创建账号
登录
查看“︁模块:TowerTable”︁的源代码
模块
讨论
English
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
页面信息
外观
移至侧栏
隐藏
←
模块:TowerTable
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p = {} function p.main(frame) -- 获取调用参数 local args = frame:getParent().args local class = args.class or "wikitable towertable" local headerStr = args.header or "" local rowsStr = args.rows or "" local footerStr = args.footer or "" -- 解析列标题 local headers = {} if headerStr ~= "" then for h in mw.text.gsplit(headerStr, ",") do table.insert(headers, mw.text.trim(h)) end end -- 解析数据行 local rows = {} if rowsStr ~= "" then for row in mw.text.gsplit(rowsStr, ";") do local cells = {} for cell in mw.text.gsplit(row, ",") do table.insert(cells, mw.text.trim(cell)) end if #cells > 0 then table.insert(rows, cells) end end end -- 开始构建表格 local result = {} table.insert(result, '{| class="' .. class .. '"\n') -- 表头行 table.insert(result, '| \'\'\'防御塔等级与属性项(总和)\'\'\'') for _, h in ipairs(headers) do table.insert(result, ' || {{c|' .. h .. '|' .. h .. '}}') end table.insert(result, '\n') -- 数据行 for _, rowCells in ipairs(rows) do table.insert(result, '|-\n') -- 第一列,保留原始格式 local firstCol = rowCells[1] or "" table.insert(result, '| ' .. firstCol .. '\n') -- 剩余列 for i = 2, #rowCells do local header = headers[i-1] or "" local cellValue = rowCells[i] or "" local coloredCell = "{{c|" .. header .. "|" .. cellValue .. "}}" if i == 2 then table.insert(result, '| ' .. coloredCell) else table.insert(result, ' || ' .. coloredCell) end end table.insert(result, '\n') end -- 脚注行 if footerStr ~= "" then table.insert(result, '|-\n') table.insert(result, '| ' .. footerStr .. '\n') end -- 结束表格 table.insert(result, '|}') return table.concat(result) end return p
此页面嵌入的页面:
模块:TowerTable/doc
(
查看源代码
)
返回
模块:TowerTable
。
搜索
搜索
查看“︁模块:TowerTable”︁的源代码
添加话题