Module:Sandbox/Alexiscoutinho

This is an old revision of this page, as edited by Alexiscoutinho (talk | contribs) at 22:38, 24 March 2020 (Undid revision 947203469 by Alexiscoutinho (talk)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}

function p.buildRows( frame )
	local barwidth = frame.args.barwidth
	local data = frame.args.data
	local divisor = frame.args.divisor
	local numwidth = frame.args.numwidth
	local collapsible = frame.args.collapsible

	local lines = mw.text.split( data, '\n' )
	mw.log(lines)
	mw.log(divisor)
	if not divisor then
		local i = 1
		local total1, total2 = 0, 0

		for parameter in mw.text.gsplit( lines[#lines], ';' ) do
			mw.log(i)
			mw.log(parameter)
			if string.find( parameter, '^ *%A' ) then
				if i == 6 then
					total1 = tonumber( string.gsub( parameter, '%D', '' ) )
					mw.log(total1)
					if not total1 then
						total1 = 0
					end
					mw.log(total1)
				elseif i == 8 then
					total2 = tonumber( string.gsub( parameter, '%D', '' ) )
					mw.log(total2)
					if not total2 then
						total2 = 0
					end
					mw.log(total2)
					break
				end
				i = i + 1
			end
		end
		divisor = math.max( total1, total2 ) / ( 0.95 * barwidth )
	end
	return divisor
end
return p