Changes

format ship types and ignore bogus ship names
Line 3: Line 3:     
local Ship = require('Module:Ship')
 
local Ship = require('Module:Ship')
 +
local Formatting = require('Module:Formatting')
    
local DropList = {}
 
local DropList = {}
Line 42: Line 43:  
if tonumber(arg_name) then
 
if tonumber(arg_name) then
 
local ship, nodes = arg:match(args_grammar.ship_and_nodes)
 
local ship, nodes = arg:match(args_grammar.ship_and_nodes)
-- TODO: check ship existence?
   
local ship_table = Ship:get_table(ship, "")
 
local ship_table = Ship:get_table(ship, "")
table.insert(tbl.rows, {})
+
if ship_table and ship_table._type then
local row = tbl.rows[#tbl.rows]
+
    table.insert(tbl.rows, {})
row.id = arg_name
+
    local row = tbl.rows[#tbl.rows]
row.ship = ship
+
    -- row.id = arg_name
row.type = ship_table and ship_table._type or '?'
+
    row.ship = ship
row.nodes = {}
+
    row.type = Formatting:format_ship_code(ship_table._type) or '?'
for _, node in pairs(tbl.nodes) do
+
    row.nodes = {}
row.nodes[node.name] = nil
+
    for _, node in pairs(tbl.nodes) do
end
+
    row.nodes[node.name] = nil
for node_and_diff in string.gmatch(nodes, args_grammar.comma_list) do
+
    end
local node, diff = node_and_diff:match(args_grammar.node_and_diff)
+
    for node_and_diff in string.gmatch(nodes, args_grammar.comma_list) do
if not node or not diff then
+
    local node, diff = node_and_diff:match(args_grammar.node_and_diff)
node = node_and_diff:match(args_grammar.just_node)
+
    if not node or not diff then
diff = nil
+
    node = node_and_diff:match(args_grammar.just_node)
end
+
    diff = nil
-- TODO: check node existence?
+
    end
if node then
+
    if node then
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
end
+
    end
 +
    end
 
end
 
end
 
end
 
end
cssedit, gkautomate
6,926

edits