Module:Compare

From Ways of Darkness
Jump to navigation Jump to search

Documentation for this module may be created at Module:Compare/doc

require "Module:BonusMalus"

function Compare(number1,number2,rounding)
	local temp = (number1 / number2) - 1.00
	if rounding ~= nil and rounding ~= 0 and rounding ~= false and rounding ~= "false" then
		temp = math.floor((temp * 40) + 0.5) / 4 * 10 
	else
		temp = temp * 100
	end
	return BonusMalus(temp,"PERC")
end

local p = {}
function p.main(frame)
	return Compare(tonumber(frame.args[1]),tonumber(frame.args[2]),frame.args[3])
end
return p