Module:Data tables/pods: Difference between revisions
Jump to navigation
Jump to search
Tag: Undo |
use common cells subpage to build full cell table |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local _commonCells = require("Module:Data tables/common cells").commonCells | |||
-- Builds table formatted for command pods | -- Builds table formatted for command pods | ||
Line 5: | Line 6: | ||
local category = args[1] | local category = args[1] | ||
local family = args[2] | local family = args[2] | ||
local json = mw.loadJsonData("Data:Collections/parts") | |||
local cells = '' | |||
-- adds command module values | -- adds command module values | ||
Line 13: | Line 16: | ||
"!Torque (kN)\n" | "!Torque (kN)\n" | ||
local | for k, v in pairs(json[category][family]) do | ||
local partJson = mw.loadJsonData("Data:"..k) | |||
local tempCell = _commonCells(partJson) .. | |||
"|"..partJson["modules"]["command_module"]["crew_capacity"].."\n" .. | "|"..partJson["modules"]["command_module"]["crew_capacity"].."\n" .. | ||
"|"..partJson["resources"]["electric_charge"].."\n" .. | "|"..partJson["resources"]["electric_charge"].."\n" .. | ||
"|"..partJson["resources"]["monopropellant"].."\n" .. | "|"..partJson["resources"]["monopropellant"].."\n" .. | ||
"|"..partJson["modules"]["reaction_wheel"]["torque"]["pitch"].."\n" | "|"..partJson["modules"]["reaction_wheel"]["torque"]["pitch"].."\n" | ||
cells = tempCell..cells | |||
end | |||
-- append the cells to the headers and cap off the table wiki text | -- append the cells to the headers and cap off the table wiki text | ||
local | local header_cells = {header, cells} | ||
return | return header_cells | ||
end | end | ||
return p | return p |
Revision as of 05:54, 1 February 2025
Documentation for this module may be created at Module:Data tables/pods/doc
local p = {}
local _commonCells = require("Module:Data tables/common cells").commonCells
-- Builds table formatted for command pods
function p.podTable(args)
local category = args[1]
local family = args[2]
local json = mw.loadJsonData("Data:Collections/parts")
local cells = ''
-- adds command module values
local header =
"!Crew\n" ..
"!Electric Charge (U)\n" ..
"!Monopropellant (t)\n" ..
"!Torque (kN)\n"
for k, v in pairs(json[category][family]) do
local partJson = mw.loadJsonData("Data:"..k)
local tempCell = _commonCells(partJson) ..
"|"..partJson["modules"]["command_module"]["crew_capacity"].."\n" ..
"|"..partJson["resources"]["electric_charge"].."\n" ..
"|"..partJson["resources"]["monopropellant"].."\n" ..
"|"..partJson["modules"]["reaction_wheel"]["torque"]["pitch"].."\n"
cells = tempCell..cells
end
-- append the cells to the headers and cap off the table wiki text
local header_cells = {header, cells}
return header_cells
end
return p