Module:WeightToPercent: Difference between revisions
Jump to navigation
Jump to search
imported>Septembre debug 2: on essaye de récupérer des arguments |
imported>Evian Annulation des modifications 5363 de Evian (discussion) |
||
| (7 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p. | function p.convert(frame) | ||
local args = | local weight = frame.args['weight'] | ||
return | 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 | end | ||
return p | return p | ||
Latest revision as of 18:06, 2 March 2026
Documentation for this module may be created at 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