“模块:Ship Specs”的版本间的差异

来自星际公民宇宙百科
跳转至: 导航搜索
第16行: 第16行:
 
["max_retro_thruster"] = "制动推进器上限",
 
["max_retro_thruster"] = "制动推进器上限",
 
["type"] = "类型",
 
["type"] = "类型",
["specs"] = " 规格",
+
["size_count"] = " 尺寸/数量",
["factory_propulsion"] = "原厂推进设备",
 
["factory_ordnance"] = "原厂武器设备",
 
["factory_modular"] = "原厂模块设备",
 
["factory_avionics"] = "原厂航电设备",
 
 
["length_unit"] = "M",
 
["length_unit"] = "M",
 
["mass_unit"] = "KG",
 
["mass_unit"] = "KG",
第26行: 第22行:
 
["crew_unit"] = "人",
 
["crew_unit"] = "人",
 
["size_unit"] = "级",
 
["size_unit"] = "级",
 +
 +
["factory_propulsion"] = "原厂推进设备",
 +
["propulsion_specs_format"] = "S%d x%d",
 +
["propulsion_factory_format"] = "%s(%d) x%d",
 
["propulsion:Primary"] = "主推进器",
 
["propulsion:Primary"] = "主推进器",
 
["propulsion:Maneuvering"] = "机动推进器",
 
["propulsion:Maneuvering"] = "机动推进器",
 
["propulsion:Retro"] = "制动推进器",
 
["propulsion:Retro"] = "制动推进器",
["propulsion:Unknow"] = " 未知推进 设备",
+
 
["propulsion_specs_format"] = "%d 级推进器 x %d",
+
["factory_ordnance"] = "原厂武器设备",
["propulsion_factory_format"] = "%s(%d) x %d",
+
["ordnance_class_format"] = "%s类武器",
 +
["ordnance_specs_format"] = "S%d x%d",
 +
["ordnance_factory_format"] = "%s(%d) x%d",
 +
 
 +
["factory_modular"] = "原厂模块设备",
 +
["modular_specs_format"] = "S%d x%d",
 +
["modular_factory_format"] = "%s(%d) x%d",
 +
["modular:Shield"] = "护盾",
 +
["modular:Power Plant"] = "能源装置",
 +
["modular:Additional"] = " 附加装备",
 +
 
 +
["factory_avionics"] = "原厂航电 设备",
 +
["avionics_specs_format"] = "S%d x%d",
 +
["avionics_factory_format"] = "%s(%d) x%d",
 
}
 
}
  
第117行: 第130行:
 
if shipCount > 1 then
 
if shipCount > 1 then
 
h_tr:tag("td")
 
h_tr:tag("td")
 +
h_td = h_tr:tag("td"):attr({ colspan="2" })
 +
else
 
h_td = h_tr:tag("td"):attr({ colspan="3" })
 
h_td = h_tr:tag("td"):attr({ colspan="3" })
else
 
h_td = h_tr:tag("td"):attr({ colspan="2" })
 
 
end
 
end
 
local name = nameRow[i]
 
local name = nameRow[i]
 
if name then
 
if name then
h_tr:tag("b"):wikitext(name)
+
h_td:tag("b"):wikitext(name)
 
end
 
end
 
end
 
end
第135行: 第148行:
 
if shipCount > 1 then
 
if shipCount > 1 then
 
h_tr:tag("td")
 
h_tr:tag("td")
 +
h_td = h_tr:tag("td"):attr({ colspan="2" })
 +
else
 
h_td = h_tr:tag("td"):attr({ colspan="3" })
 
h_td = h_tr:tag("td"):attr({ colspan="3" })
else
 
h_td = h_tr:tag("td"):attr({ colspan="2" })
 
 
end
 
end
 
local image = imageRow[i]
 
local image = imageRow[i]
 
if image then
 
if image then
h_tr:wikitext(image)
+
h_td:wikitext(image)
 
end
 
end
 
end
 
end
第183行: 第196行:
 
if productionStatus then
 
if productionStatus then
 
h_td:wikitext(productionStatus)
 
h_td:wikitext(productionStatus)
h_td:newline()
+
if productionNote then
 +
h_td:wikitext("<br />")
 +
end
 
end
 
end
 
if productionNote then
 
if productionNote then
第296行: 第311行:
  
 
local propulsion_row = shipTableRows["propulsion"]
 
local propulsion_row = shipTableRows["propulsion"]
if propulsion_row then
+
if propulsion_row and (#propulsion_row > 0) then
 
local h_tr = h_table:tag("tr"):addClass("sps-propulsion")
 
local h_tr = h_table:tag("tr"):addClass("sps-propulsion")
 
h_tr:tag("td"):wikitext(itemNames["type"])
 
h_tr:tag("td"):wikitext(itemNames["type"])
 
for shipIndex=1,shipCount do
 
for shipIndex=1,shipCount do
h_tr:tag("td"):wikitext(itemNames["specs"])
+
h_tr:tag("td"):wikitext(itemNames["size_count"])
 
h_tr:tag("td"):wikitext(itemNames["factory_propulsion"])
 
h_tr:tag("td"):wikitext(itemNames["factory_propulsion"])
 
end
 
end
 
for p_type, p_row in pairs(propulsion_row) do
 
for p_type, p_row in pairs(propulsion_row) do
 
h_tr = h_table:tag("tr"):addClass("sps-propulsion")
 
h_tr = h_table:tag("tr"):addClass("sps-propulsion")
h_tr:tag("td"):wikitext(defualtWhenNil(itemNames["propulsion:" .. p_type]), itemNames["propulsion:Unknow"])
+
h_tr:tag("td"):wikitext(defualtWhenNil(itemNames["propulsion:" .. p_type], p_type))
 
for shipIndex=1,shipCount do
 
for shipIndex=1,shipCount do
 
local h_td_specs = h_tr:tag("td")
 
local h_td_specs = h_tr:tag("td")
第315行: 第330行:
 
for specs_size, specs_count in pairs(p_row_ship_specs) do
 
for specs_size, specs_count in pairs(p_row_ship_specs) do
 
h_td_specs:wikitext(string.format(itemNames["propulsion_specs_format"], specs_size, specs_count))
 
h_td_specs:wikitext(string.format(itemNames["propulsion_specs_format"], specs_size, specs_count))
h_td_specs:newline()
+
h_td_specs:wikitext("<br />")
 
end
 
end
 
end
 
end
第322行: 第337行:
 
for factory_component_index, factory_component in ipairs(p_row_ship_factory) do
 
for factory_component_index, factory_component in ipairs(p_row_ship_factory) do
 
h_td_factory:wikitext(string.format(itemNames["propulsion_factory_format"], factory_component.name, factory_component.size, factory_component.count))
 
h_td_factory:wikitext(string.format(itemNames["propulsion_factory_format"], factory_component.name, factory_component.size, factory_component.count))
h_td_factory:newline()
+
h_td_factory:wikitext("<br />")
 +
end
 +
end
 +
end
 +
 
 +
end
 +
end
 +
end
 +
 
 +
local ordnance_row = shipTableRows["ordnance"]
 +
if ordnance_row and (#ordnance_row > 0) then
 +
local h_tr = h_table:tag("tr"):addClass("sps-ordnance")
 +
h_tr:tag("td"):wikitext(itemNames["type"])
 +
for shipIndex=1,shipCount do
 +
h_tr:tag("td"):wikitext(itemNames["size_count"])
 +
h_tr:tag("td"):wikitext(itemNames["factory_ordnance"])
 +
end
 +
for p_class, p_row in pairs(ordnance_row) do
 +
h_tr = h_table:tag("tr"):addClass("sps-ordnance")
 +
h_tr:tag("td"):wikitext(string.format(itemNames["ordnance_class_format"], p_class))
 +
for shipIndex=1,shipCount do
 +
local h_td_specs = h_tr:tag("td")
 +
local h_td_factory = h_tr:tag("td")
 +
local p_row_ship = p_row[shipIndex]
 +
if p_row_ship then
 +
local p_row_ship_specs = p_row_ship["specs"]
 +
if p_row_ship_specs then
 +
for specs_size, specs_count in pairs(p_row_ship_specs) do
 +
h_td_specs:wikitext(string.format(itemNames["ordnance_specs_format"], specs_size, specs_count))
 +
h_td_specs:wikitext("<br />")
 +
end
 +
end
 +
local p_row_ship_factory = p_row_ship["factory"]
 +
if p_row_ship_factory then
 +
for factory_component_index, factory_component in ipairs(p_row_ship_factory) do
 +
h_td_factory:wikitext(string.format(itemNames["ordnance_factory_format"], factory_component.name, factory_component.size, factory_component.count))
 +
h_td_factory:wikitext("<br />")
 +
end
 +
end
 +
end
 +
 
 +
end
 +
end
 +
end
 +
 
 +
local modular_row = shipTableRows["modular"]
 +
if modular_row and (#modular_row > 0) then
 +
local h_tr = h_table:tag("tr"):addClass("sps-modular")
 +
h_tr:tag("td"):wikitext(itemNames["type"])
 +
for shipIndex=1,shipCount do
 +
h_tr:tag("td"):wikitext(itemNames["size_count"])
 +
h_tr:tag("td"):wikitext(itemNames["factory_modular"])
 +
end
 +
for p_type, p_row in pairs(modular_row) do
 +
h_tr = h_table:tag("tr"):addClass("sps-modular")
 +
h_tr:tag("td"):wikitext(defualtWhenNil(itemNames["modular:" .. p_type], p_type))
 +
for shipIndex=1,shipCount do
 +
local h_td_specs = h_tr:tag("td")
 +
local h_td_factory = h_tr:tag("td")
 +
local p_row_ship = p_row[shipIndex]
 +
if p_row_ship then
 +
local p_row_ship_specs = p_row_ship["specs"]
 +
if p_row_ship_specs then
 +
for specs_size, specs_count in pairs(p_row_ship_specs) do
 +
h_td_specs:wikitext(string.format(itemNames["modular_specs_format"], specs_size, specs_count))
 +
h_td_specs:wikitext("<br />")
 +
end
 +
end
 +
local p_row_ship_factory = p_row_ship["factory"]
 +
if p_row_ship_factory then
 +
for factory_component_index, factory_component in ipairs(p_row_ship_factory) do
 +
h_td_factory:wikitext(string.format(itemNames["modular_factory_format"], factory_component.name, factory_component.size, factory_component.count))
 +
h_td_factory:wikitext("<br />")
 +
end
 +
end
 +
end
 +
 
 +
end
 +
end
 +
end
 +
 
 +
local avionics_row = shipTableRows["avionics"]
 +
if avionics_row and (#avionics_row > 0) then
 +
local h_tr = h_table:tag("tr"):addClass("sps-avionics")
 +
h_tr:tag("td"):wikitext(itemNames["type"])
 +
for shipIndex=1,shipCount do
 +
h_tr:tag("td"):wikitext(itemNames["size_count"])
 +
h_tr:tag("td"):wikitext(itemNames["factory_avionics"])
 +
end
 +
for p_type, p_row in pairs(avionics_row) do
 +
h_tr = h_table:tag("tr"):addClass("sps-avionics")
 +
h_tr:tag("td"):wikitext(defualtWhenNil(itemNames["avionics:" .. p_type], p_type))
 +
for shipIndex=1,shipCount do
 +
local h_td_specs = h_tr:tag("td")
 +
local h_td_factory = h_tr:tag("td")
 +
local p_row_ship = p_row[shipIndex]
 +
if p_row_ship then
 +
local p_row_ship_specs = p_row_ship["specs"]
 +
if p_row_ship_specs then
 +
for specs_size, specs_count in pairs(p_row_ship_specs) do
 +
h_td_specs:wikitext(string.format(itemNames["avionics_specs_format"], specs_size, specs_count))
 +
h_td_specs:wikitext("<br />")
 +
end
 +
end
 +
local p_row_ship_factory = p_row_ship["factory"]
 +
if p_row_ship_factory then
 +
for factory_component_index, factory_component in ipairs(p_row_ship_factory) do
 +
h_td_factory:wikitext(string.format(itemNames["avionics_factory_format"], factory_component.name, factory_component.size, factory_component.count))
 +
h_td_factory:wikitext("<br />")
 
end
 
end
 
end
 
end

2015年10月6日 (二) 13:51的版本

此模块的文档可以在模块:Ship Specs/doc创建

local p = {}
local itemNames = {
	["manufacturer"] = "制造商",
	["focus"] = "定位",
	["production_status"] = "生产状态",
	["length"] = "长",
	["beam"] = "宽",
	["height"] = "高",
	["mass"] = "空重",
	["cargo_capacity"] = "载货量",
	["max_crew"] = "船员上限",
	["max_power_plant_size"] = "能源装置尺寸上限",
	["max_shield"] = "护盾上限",
	["max_primary_thruster"] = "主推进器上限",
	["max_maneuvering_thruster"] = "机动推进器上限",
	["max_retro_thruster"] = "制动推进器上限",
	["type"] = "类型",
	["size_count"] = "尺寸/数量",
	["length_unit"] = "M",
	["mass_unit"] = "KG",
	["cargo_unit"] = "SCU",
	["crew_unit"] = "人",
	["size_unit"] = "级",

	["factory_propulsion"] = "原厂推进设备",
	["propulsion_specs_format"] = "S%d x%d",
	["propulsion_factory_format"] = "%s(%d) x%d",
	["propulsion:Primary"] = "主推进器",
	["propulsion:Maneuvering"] = "机动推进器",
	["propulsion:Retro"] = "制动推进器",

	["factory_ordnance"] = "原厂武器设备",
	["ordnance_class_format"] = "%s类武器",
	["ordnance_specs_format"] = "S%d x%d",
	["ordnance_factory_format"] = "%s(%d) x%d",

	["factory_modular"] = "原厂模块设备",
	["modular_specs_format"] = "S%d x%d",
	["modular_factory_format"] = "%s(%d) x%d",
	["modular:Shield"] = "护盾",
	["modular:Power Plant"] = "能源装置",
	["modular:Additional"] = "附加装备",

	["factory_avionics"] = "原厂航电设备",
	["avionics_specs_format"] = "S%d x%d",
	["avionics_factory_format"] = "%s(%d) x%d",
}

local function defualtWhenNil( value, defaultValue )
	if value then
		return value
	else
		return defaultValue
	end
end

local function countInTable( table, key, num)
	if table[key] then
		table[key] = table[key] + num
	else
		table[key] = num	
	end
end

local function ensureSubTable( table, key )
	local subTable
	if table[key] then
		subTable = table[key]
	else
		subTable = {}
		table[key] = subTable
	end
	return subTable
end

local function shipTableRows( shipSpecsList )
	local rows = {}
	for shipIndex, shipSpecs in ipairs(shipSpecsList) do
		--mw.log(string.format("shipIndex:%d", shipIndex))
		for shipSpecs_key, shipSpecs_value in pairs(shipSpecs) do
			--mw.log(string.format("shipSpecs_key:%s", shipSpecs_key))
			local row = ensureSubTable(rows, shipSpecs_key)
			if (shipSpecs_key == "propulsion") or (shipSpecs_key == "ordnance") or (shipSpecs_key == "modular") or (shipSpecs_key == "avionics") then
				for ss_p_item_name, ss_p_item in pairs(shipSpecs_value) do
					if ss_p_item then
						local ss_p_item_type;
						if shipSpecs_key == "ordnance" then
							ss_p_item_type = ss_p_item["class"]
						else
							ss_p_item_type = ss_p_item["type"]
						end
						local ss_p_item_max_size = tonumber(ss_p_item["max_size"])
						local ss_p_item_count = tonumber(ss_p_item["count"])
						if not ss_p_item_count then
							ss_p_item_count = 1
						end
						if ss_p_item_type and ss_p_item_max_size and (ss_p_item_max_size > 0) and (ss_p_item_count > 0) then
							local row_p = ensureSubTable(row, ss_p_item_type)
							local row_p_ship = ensureSubTable(row_p, shipIndex)
							local row_p_ship_specs = ensureSubTable(row_p_ship, "specs")
							local row_p_ship_factory = ensureSubTable(row_p_ship, "factory")
							countInTable(row_p_ship_specs, ss_p_item_max_size, ss_p_item_count)

							local ss_p_item_components = ss_p_item["components"]
							if ss_p_item_components then
								for ss_p_item_component_index, ss_p_item_component in ipairs(ss_p_item_components) do
									row_p_ship_factory[#row_p_ship_factory + 1] = { ["name"] = ss_p_item_component.name, ["size"] = ss_p_item_component.size, ["count"] = ss_p_item_component.count}
								end
							end
						end
					end
				end
			else
				row[shipIndex] = shipSpecs_value
			end
		end
	end
	return rows
end

local function createShipTable(shipTableRows, shipCount)
	local table_col_num = (2 * shipCount) + 1
	local h_table = mw.html.create("table"):addClass("ship-specs-table")

	local nameRow = shipTableRows["name"]
	if nameRow then
		local h_tr = h_table:tag("tr"):addClass("sps-name");
		for i=1,shipCount do
			local h_td
			if shipCount > 1 then
				h_tr:tag("td")
				h_td = h_tr:tag("td"):attr({ colspan="2" })
			else
				h_td = h_tr:tag("td"):attr({ colspan="3" })
			end
			local name = nameRow[i]
			if name then
				h_td:tag("b"):wikitext(name)
			end
		end
	end

	local imageRow = shipTableRows["image"]
	if imageRow then
		local h_tr = h_table:tag("tr"):addClass("sps-image");
		for i=1,shipCount do
			local h_td
			if shipCount > 1 then
				h_tr:tag("td")
				h_td = h_tr:tag("td"):attr({ colspan="2" })
			else
				h_td = h_tr:tag("td"):attr({ colspan="3" })
			end
			local image = imageRow[i]
			if image then
				h_td:wikitext(image)
			end
		end
	end

	local manufacturerRow = shipTableRows["manufacturer"]
	if manufacturerRow then
		local h_tr = h_table:tag("tr"):addClass("sps-base")
		h_tr:tag("td"):wikitext(itemNames["manufacturer"])
		for i=1,shipCount do
			local h_td = h_tr:tag("td"):attr({ colspan="2" })
			local manufacturer = manufacturerRow[i]
			if manufacturer then
				h_td:wikitext("[[" .. manufacturer .. "]]")
			end
		end
	end

	local focusRow = shipTableRows["focus"]
	if focusRow then
		local h_tr = h_table:tag("tr"):addClass("sps-base")
		h_tr:tag("td"):wikitext(itemNames["focus"])
		for i=1,shipCount do
			local h_td = h_tr:tag("td"):attr({ colspan="2" })
			local focus = focusRow[i]
			if focus then
				h_td:wikitext(focus)
			end
		end
	end

	local productionStatusRow = shipTableRows["production_status"]
	local productionNoteRow = shipTableRows["production_note"]
	if productionStatusRow then
		local h_tr = h_table:tag("tr"):addClass("sps-base")
		h_tr:tag("td"):wikitext(itemNames["production_status"])
		for i=1,shipCount do
			local productionStatus = productionStatusRow[i]
			local productionNote = productionNoteRow[i]
			local h_td = h_tr:tag("td"):attr({ colspan="2" })
			if productionStatus then
				h_td:wikitext(productionStatus)
				if productionNote then
					h_td:wikitext("<br />")
				end
			end
			if productionNote then
				h_td:wikitext(productionNote)
			end
		end
	end

	local lengthRow = shipTableRows["length"]
	if lengthRow then
		local h_tr = h_table:tag("tr"):addClass("sps-measurement")
		h_tr:tag("td"):wikitext(itemNames["length"])
		for i=1,shipCount do
			local h_td = h_tr:tag("td"):attr({ colspan="2" })
			local length = lengthRow[i]
			if length then
				h_td:wikitext(length, " " .. itemNames["length_unit"])
			end
		end
	end

	local beamRow = shipTableRows["beam"]
	if beamRow then
		local h_tr = h_table:tag("tr"):addClass("sps-measurement")
		h_tr:tag("td"):wikitext(itemNames["beam"])
		for i=1,shipCount do
			local h_td = h_tr:tag("td"):attr({ colspan="2" })
			local beam = beamRow[i]
			if beam then
				h_td:wikitext(beam, " " .. itemNames["length_unit"])
			end
		end
	end

	local heightRow = shipTableRows["height"]
	if heightRow then
		local h_tr = h_table:tag("tr"):addClass("sps-measurement")
		h_tr:tag("td"):wikitext(itemNames["height"])
		for i=1,shipCount do
			local h_td = h_tr:tag("td"):attr({ colspan="2" })
			local height = heightRow[i]
			if height then
				h_td:wikitext(height, " " .. itemNames["length_unit"])
			end
		end
	end

	local massRow = shipTableRows["mass"]
	if massRow then
		local h_tr = h_table:tag("tr"):addClass("sps-measurement")
		h_tr:tag("td"):wikitext(itemNames["mass"])
		for i=1,shipCount do
			local h_td = h_tr:tag("td"):attr({ colspan="2" })
			local mass = massRow[i]
			if mass then
				h_td:wikitext(mass, " " .. itemNames["mass_unit"])
			end
		end
	end

	local cargo_capacity_row = shipTableRows["cargo_capacity"]
	if cargo_capacity_row then
		local h_tr = h_table:tag("tr"):addClass("sps-structural")
		h_tr:tag("td"):wikitext(itemNames["cargo_capacity"])
		for i=1,shipCount do
			local h_td = h_tr:tag("td"):attr({ colspan="2" })
			local cargo_capacity = cargo_capacity_row[i]
			if cargo_capacity then
				h_td:wikitext(cargo_capacity, " " .. itemNames["cargo_unit"])
			end
		end
	end

	local max_crew_row = shipTableRows["max_crew"]
	if max_crew_row then
		local h_tr = h_table:tag("tr"):addClass("sps-structural")
		h_tr:tag("td"):wikitext(itemNames["max_crew"])
		for i=1,shipCount do
			local h_td = h_tr:tag("td"):attr({ colspan="2" })
			local max_crew = max_crew_row[i]
			if max_crew then
				h_td:wikitext(max_crew, " " .. itemNames["crew_unit"])
			end
		end
	end

	local max_power_plant_size_row = shipTableRows["max_power_plant_size"]
	if max_power_plant_size_row then
		local h_tr = h_table:tag("tr"):addClass("sps-structural")
		h_tr:tag("td"):wikitext(itemNames["max_power_plant_size"])
		for i=1,shipCount do
			local h_td = h_tr:tag("td"):attr({ colspan="2" })
			local max_power_plant_size = max_power_plant_size_row[i]
			if max_power_plant_size then
				h_td:wikitext(max_power_plant_size, " " .. itemNames["size_unit"])
			end
		end
	end

	local max_shield_row = shipTableRows["max_shield"]
	if max_shield_row then
		local h_tr = h_table:tag("tr"):addClass("sps-structural")
		h_tr:tag("td"):wikitext(itemNames["max_shield"])
		for i=1,shipCount do
			local h_td = h_tr:tag("td"):attr({ colspan="2" })
			local max_shield = max_shield_row[i]
			if max_shield then
				h_td:wikitext(max_shield, " " .. itemNames["size_unit"])
			end
		end
	end

	local propulsion_row = shipTableRows["propulsion"]
	if propulsion_row and (#propulsion_row > 0) then
		local h_tr = h_table:tag("tr"):addClass("sps-propulsion")
		h_tr:tag("td"):wikitext(itemNames["type"])
		for shipIndex=1,shipCount do
			h_tr:tag("td"):wikitext(itemNames["size_count"])
			h_tr:tag("td"):wikitext(itemNames["factory_propulsion"])
		end
		for p_type, p_row in pairs(propulsion_row) do
			h_tr = h_table:tag("tr"):addClass("sps-propulsion")
			h_tr:tag("td"):wikitext(defualtWhenNil(itemNames["propulsion:" .. p_type], p_type))
			for shipIndex=1,shipCount do
				local h_td_specs = h_tr:tag("td")
				local h_td_factory = h_tr:tag("td")
				local p_row_ship = p_row[shipIndex]
				if p_row_ship then
					local p_row_ship_specs = p_row_ship["specs"]
					if p_row_ship_specs then
						for specs_size, specs_count in pairs(p_row_ship_specs) do
							h_td_specs:wikitext(string.format(itemNames["propulsion_specs_format"], specs_size, specs_count))
							h_td_specs:wikitext("<br />")
						end
					end
					local p_row_ship_factory = p_row_ship["factory"]
					if p_row_ship_factory then
						for factory_component_index, factory_component in ipairs(p_row_ship_factory) do
							h_td_factory:wikitext(string.format(itemNames["propulsion_factory_format"], factory_component.name, factory_component.size, factory_component.count))
							h_td_factory:wikitext("<br />")
						end
					end
				end

			end
		end
	end

	local ordnance_row = shipTableRows["ordnance"]
	if ordnance_row and (#ordnance_row > 0) then
		local h_tr = h_table:tag("tr"):addClass("sps-ordnance")
		h_tr:tag("td"):wikitext(itemNames["type"])
		for shipIndex=1,shipCount do
			h_tr:tag("td"):wikitext(itemNames["size_count"])
			h_tr:tag("td"):wikitext(itemNames["factory_ordnance"])
		end
		for p_class, p_row in pairs(ordnance_row) do
			h_tr = h_table:tag("tr"):addClass("sps-ordnance")
			h_tr:tag("td"):wikitext(string.format(itemNames["ordnance_class_format"], p_class))
			for shipIndex=1,shipCount do
				local h_td_specs = h_tr:tag("td")
				local h_td_factory = h_tr:tag("td")
				local p_row_ship = p_row[shipIndex]
				if p_row_ship then
					local p_row_ship_specs = p_row_ship["specs"]
					if p_row_ship_specs then
						for specs_size, specs_count in pairs(p_row_ship_specs) do
							h_td_specs:wikitext(string.format(itemNames["ordnance_specs_format"], specs_size, specs_count))
							h_td_specs:wikitext("<br />")
						end
					end
					local p_row_ship_factory = p_row_ship["factory"]
					if p_row_ship_factory then
						for factory_component_index, factory_component in ipairs(p_row_ship_factory) do
							h_td_factory:wikitext(string.format(itemNames["ordnance_factory_format"], factory_component.name, factory_component.size, factory_component.count))
							h_td_factory:wikitext("<br />")
						end
					end
				end

			end
		end
	end

	local modular_row = shipTableRows["modular"]
	if modular_row and (#modular_row > 0) then
		local h_tr = h_table:tag("tr"):addClass("sps-modular")
		h_tr:tag("td"):wikitext(itemNames["type"])
		for shipIndex=1,shipCount do
			h_tr:tag("td"):wikitext(itemNames["size_count"])
			h_tr:tag("td"):wikitext(itemNames["factory_modular"])
		end
		for p_type, p_row in pairs(modular_row) do
			h_tr = h_table:tag("tr"):addClass("sps-modular")
			h_tr:tag("td"):wikitext(defualtWhenNil(itemNames["modular:" .. p_type], p_type))
			for shipIndex=1,shipCount do
				local h_td_specs = h_tr:tag("td")
				local h_td_factory = h_tr:tag("td")
				local p_row_ship = p_row[shipIndex]
				if p_row_ship then
					local p_row_ship_specs = p_row_ship["specs"]
					if p_row_ship_specs then
						for specs_size, specs_count in pairs(p_row_ship_specs) do
							h_td_specs:wikitext(string.format(itemNames["modular_specs_format"], specs_size, specs_count))
							h_td_specs:wikitext("<br />")
						end
					end
					local p_row_ship_factory = p_row_ship["factory"]
					if p_row_ship_factory then
						for factory_component_index, factory_component in ipairs(p_row_ship_factory) do
							h_td_factory:wikitext(string.format(itemNames["modular_factory_format"], factory_component.name, factory_component.size, factory_component.count))
							h_td_factory:wikitext("<br />")
						end
					end
				end

			end
		end
	end

	local avionics_row = shipTableRows["avionics"]
	if avionics_row and (#avionics_row > 0) then
		local h_tr = h_table:tag("tr"):addClass("sps-avionics")
		h_tr:tag("td"):wikitext(itemNames["type"])
		for shipIndex=1,shipCount do
			h_tr:tag("td"):wikitext(itemNames["size_count"])
			h_tr:tag("td"):wikitext(itemNames["factory_avionics"])
		end
		for p_type, p_row in pairs(avionics_row) do
			h_tr = h_table:tag("tr"):addClass("sps-avionics")
			h_tr:tag("td"):wikitext(defualtWhenNil(itemNames["avionics:" .. p_type], p_type))
			for shipIndex=1,shipCount do
				local h_td_specs = h_tr:tag("td")
				local h_td_factory = h_tr:tag("td")
				local p_row_ship = p_row[shipIndex]
				if p_row_ship then
					local p_row_ship_specs = p_row_ship["specs"]
					if p_row_ship_specs then
						for specs_size, specs_count in pairs(p_row_ship_specs) do
							h_td_specs:wikitext(string.format(itemNames["avionics_specs_format"], specs_size, specs_count))
							h_td_specs:wikitext("<br />")
						end
					end
					local p_row_ship_factory = p_row_ship["factory"]
					if p_row_ship_factory then
						for factory_component_index, factory_component in ipairs(p_row_ship_factory) do
							h_td_factory:wikitext(string.format(itemNames["avionics_factory_format"], factory_component.name, factory_component.size, factory_component.count))
							h_td_factory:wikitext("<br />")
						end
					end
				end

			end
		end
	end

	return tostring(h_table)
end

function p.shipTable( frame )
	local count = 0
	local specsList = {}
	for name, arg in pairs(frame.args) do
		local specs = mw.text.jsonDecode(arg)
		if specs and specs["name"] then
			count = count + 1
			specsList[count] = specs
		end
	end
	if(count > 0) then
		--mw.log(mw.logObject(specsList))
		local rows = shipTableRows(specsList)
		--mw.log(mw.logObject(rows))
		return createShipTable(rows, count)
	end
end

return p