Line 1: |
Line 1: |
| | | |
| + | local format = require("Module:StringInterpolation").format |
| local getArgs = require('Module:GetArgs') | | local getArgs = require('Module:GetArgs') |
| | | |
Line 50: |
Line 51: |
| | | |
| -- header args | | -- header args |
| + | local boss = string.upper(boss) |
| for node in string.gmatch(args.nodes, args_grammar.comma_list) do | | for node in string.gmatch(args.nodes, args_grammar.comma_list) do |
| local node = node:match(args_grammar.node) | | local node = node:match(args_grammar.node) |
| if node then | | if node then |
− | table.insert(tbl.nodes, { name = node, boss = node == args.boss }) | + | local node = string.upper(node) |
| + | table.insert(tbl.nodes, { name = node, boss = node == boss }) |
| end | | end |
| end | | end |
Line 65: |
Line 68: |
| table.insert(tbl.rows, {}) | | table.insert(tbl.rows, {}) |
| local row = tbl.rows[#tbl.rows] | | local row = tbl.rows[#tbl.rows] |
− | -- row.id = arg_name
| |
| row.ship = ship | | row.ship = ship |
| row.rare = false | | row.rare = false |
Line 86: |
Line 88: |
| end | | end |
| if node then | | if node then |
| + | local node = string.upper(node) |
| row.nodes[node] = { color = diff and diff_colors[diff] or diff_colors['?'], diff = diff and diff_names[diff] or '?' } | | row.nodes[node] = { color = diff and diff_colors[diff] or diff_colors['?'], diff = diff and diff_names[diff] or '?' } |
| end | | end |
Line 99: |
Line 102: |
| local table_format = { | | local table_format = { |
| header = '{| class="article-table sortable" align="center" width="100%" style="text-align:center"\n!Type\n!Ship\n', | | header = '{| class="article-table sortable" align="center" width="100%" style="text-align:center"\n!Type\n!Ship\n', |
− | header_node = '!width="10%%"|%s\n', | + | header_node = '!width="10%%"|${node}\n', |
− | header_boss_node = '!width="10%%" style="background-color:pink;color:red;"|\'\'\'%s\'\'\'\n', | + | header_boss_node = '!width="10%%" style="background-color:pink;color:red;"|\'\'\'${node}\'\'\'\n', |
| row = '|-\n', | | row = '|-\n', |
− | cell = '|%s\n', | + | type_cell = '|${type}\n', |
− | ship_cell = '![[%s]]\n', | + | ship_cell = '|[[${ship}]]\n', |
− | rare_ship_cell = '!style="background-color:pink;"|[[%s]]\n', | + | rare_ship_cell = '|[[${ship}|<span color=red>${ship}</span>]]\n', |
− | node_cell = '|style="background-color:#%s;"|%s\n', | + | node_cell = '|style="background-color:#${color};"|${diff}\n', |
| empty_cell = '|\n', | | empty_cell = '|\n', |
| footer = '|}\n' | | footer = '|}\n' |
Line 116: |
Line 119: |
| -- header | | -- header |
| for _, node in pairs(tbl.nodes) do | | for _, node in pairs(tbl.nodes) do |
− | res = res .. string.format(node.boss and table_format.header_boss_node or table_format.header_node, node.name) | + | res = res .. format{ |
| + | node.boss and table_format.header_boss_node or table_format.header_node, |
| + | node = node.name |
| + | } |
| end | | end |
| | | |
Line 122: |
Line 128: |
| for key, row in pairs(tbl.rows) do | | for key, row in pairs(tbl.rows) do |
| res = res .. table_format.row | | res = res .. table_format.row |
− | -- res = res .. string.format(table_format.cell, row.id) | + | res = res .. format{table_format.type_cell, type = row.type} |
− | res = res .. string.format(table_format.cell, row.type)
| + | res = res .. format{ |
− | res = res .. string.format(row.rare and table_format.rare_ship_cell or table_format.ship_cell, row.ship) | + | row.rare and table_format.rare_ship_cell or table_format.ship_cell, |
| + | ship = row.ship |
| + | } |
| for _, node in pairs(tbl.nodes) do | | for _, node in pairs(tbl.nodes) do |
| local node = row.nodes[node.name] | | local node = row.nodes[node.name] |
− | res = res .. (node and string.format(table_format.node_cell, node.color, node.diff) or table_format.empty_cell) | + | res = res .. (node and format{table_format.node_cell, color = node.color, diff = node.diff} or table_format.empty_cell) |
| end | | end |
| end | | end |