Module:Parameters

From Starfield Wiki
Jump to: navigation, search

Documentation for this module may be created at Module:Parameters/Doc

local p = {} --p stands for package

local function parse( row )
	local specials = {
		['-'] = '|colspan=3| ' .. row[1],
		['!'] = '!colspan=3| ' .. row[1],
	}

	return '\n|-\n' .. (specials[row[0]] or ('|' .. row[0] .. '||' .. row[1] .. '||' .. row[2]))
end

function p.line( frame )
	local retval =  ''
	args = frame:getParent().args
	lines = {}
	cells = {}
	for i, v in ipairs(args) do
		--This need to be tested/rewritten for the scenario where 1=foo|4=bar with no other values
		--retval = retval .. '\n' .. i .. ': ' .. v
		idec = i - 1
		row = math.floor(idec/3) + 1
		col = idec % 3
		cells[col] = v
		if (col == 2) then
			lines[row] = cells
			cells = {}
		end
	end

	for k, v in pairs(lines) do
		retval = retval .. parse(v)
	end

	return retval
end

return p