« Module:WeightToPercent » : différence entre les versions
Aller à la navigation
Aller à la recherche
debug 5: seems like it's not working if you don't use magic word parentOnly |
on arrête l'utilisation du module Arguments |
||
| Ligne 1 : | Ligne 1 : | ||
local p = {} | local p = {} | ||
function p. | function p.convert(frame) | ||
local | local weight = frame.args['weight'] | ||
local totalweight = frame.args['total'] | |||
local totalweight = args[ | |||
if weight == nil then return "ERROR: weight input (1rst arg) is nil" | 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 totalweight == nil then return "ERROR: totalweight (2nd arg) input is nil" | ||
elseif weight == 0 then return 0 | elseif weight == 0 then return 0 | ||
end | |||
return 100 * totalweight / weight | |||
end | end | ||
return p | return p | ||
Version du 19 novembre 2025 à 14:42
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 100 * totalweight / weight
end
return p