Module:Data tables/pods: Difference between revisions
Jump to navigation
Jump to search
take common chunks as args |
change to import common chunks |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local commonHeaders = require('Module:Data tables').commonHeaders | |||
local _commonCells = require('Module:Data tables')._commonCells | |||
-- Builds table formatted for command pods | -- Builds table formatted for command pods | ||
Line 5: | Line 7: | ||
local category = args[1] | local category = args[1] | ||
local family = args[2] | local family = args[2] | ||
-- adds command module values | -- adds command module values |
Revision as of 03:22, 31 January 2025
Documentation for this module may be created at Module:Data tables/pods/doc
local p = {}
local commonHeaders = require('Module:Data tables').commonHeaders
local _commonCells = require('Module:Data tables')._commonCells
-- Builds table formatted for command pods
function p._podTable(args)
local category = args[1]
local family = args[2]
-- adds command module values
local header = commonHeaders ..
"!Crew\n" ..
"!Electric Charge (U)\n" ..
"!Monopropellant (t)\n" ..
"!Torque (kN)\n"
local cells = ""
-- load the full parts list to iterate per given category and family
json = mw.loadJsonData("Data:Collections/parts")
-- each applicable part's data is appended to the table cells
for k, v in pairs(json[category][family]) do
local partJson = mw.loadJsonData("Data:"..k)
local tempCell = p._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 tempTable = header..cells.."|}"
return tempTable
end
return p