Module:WeightToPercent

De eMushpedia
Version datée du 2 mars 2026 à 18:06 par Evian (discussion | contributions) (Annulation des modifications 5363 de Evian (discussion))
(diff) ← Version précédente | Version actuelle (diff) | Version suivante → (diff)
Aller à la navigation Aller à la recherche

La documentation pour ce module peut être créée à Module:WeightToPercent/doc

local p = {}

function p.convert(frame)
	local weight = frame.args['weight']
	local totalweight = frame.args['total']
	
	if weight == nil then return "ERROR: weight input (1rst arg) is nil"
	elseif totalweight == nil then return "ERROR: totalweight (2nd arg) input is nil"
	elseif weight == 0 then return 0
    end
    return tonumber(string.format("%.1f", weight * 100 / totalweight))
end
 
return p