Module:Data tables/probes: Difference between revisions

From Kerbal Space Program 2 Wiki
Jump to navigation Jump to search
started probe table
 
updated NS ref
 
Line 7: Line 7:
local category = args[1]
local category = args[1]
local family = args[2]
local family = args[2]
local json = mw.loadJsonData("Data:Collections/parts")
local json = mw.loadJsonData("GameData:Collections/parts")
local cells = ''
local cells = ''
Line 16: Line 16:
for k, v in pairs(json[category][family]) do
for k, v in pairs(json[category][family]) do
local partJson = mw.loadJsonData("Data:"..k)
local partJson = mw.loadJsonData("GameData:"..k)
local tempCell = _commonCells(partJson) ..
local tempCell = _commonCells(partJson) ..
"|"..partJson["resources"]["electric_charge"].."\n" ..
"|"..partJson["resources"]["electric_charge"].."\n" ..

Latest revision as of 05:29, 14 February 2025

Documentation for this module may be created at Module:Data tables/probes/doc

local p = {}
local _commonCells = require("Module:Data tables/common").commonCells
local _commonHeaders = require("Module:Data tables/common").commonHeaders

-- Builds table formatted for command probes
function p.probeTable(args)
	local category = args[1]
	local family = args[2]
	local json = mw.loadJsonData("GameData:Collections/parts")
	local cells = ''
	
	-- adds probes headers
	local headers = _commonHeaders() ..
		"!Electric Charge (U)\n" ..
		"!Torque (kN)\n"
	
	for k, v in pairs(json[category][family]) do
		local partJson = mw.loadJsonData("GameData:"..k)
		local tempCell = _commonCells(partJson) ..
			"|"..partJson["resources"]["electric_charge"].."\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 probeTable = headers..cells.."|}"
	return probeTable
end

return p