« Module:WeightToPercent » : différence entre les versions
Aller à la navigation
Aller à la recherche
debug 2: sanitize ? |
debug 4: localsss |
||
| Ligne 7 : | Ligne 7 : | ||
end | end | ||
function p.convert(weight | function p.convert(args) | ||
if weight == nil then return "ERROR: weight input is nil" | local weight = args[1] | ||
elseif totalweight == nil then return "ERROR: totalweight input is nil" | local totalweight = args[2] | ||
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 | elseif weight == 0 then return 0 | ||
else return 100 * totalweight / weight end | else return 100 * totalweight / weight end | ||
Version du 19 novembre 2025 à 14:24
La documentation pour ce module peut être créée à Module:WeightToPercent/doc
local getArgs = require('Module:Arguments').getArgs
local p = {}
function p.main(frame)
local args = getArgs(frame)
return p.convert(args)
end
function p.convert(args)
local weight = args[1]
local totalweight = args[2]
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
else return 100 * totalweight / weight end
end
return p