Module:Sandbox/Frietjes: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 1:
local p = {}
 
local math_module = require("Module:Math")
 
local function rnd(num, digits)
-- This function implements {{rnd}}
return math_module._precision_format(tostring(num), digits)
end
 
function p.wpct(frame)
local w = tonumber(frame.args[1]) or 0
local l = tonumber(frame.args[2]) or 0
if args['legacy'] then
frame:expandTemplate{ title = 'winning percentage', args = {w, l} }
end
if (w + l) > 0 then
return rnd(w / (w + l), 2):gsub('^0', '')
end
return '–'
end
 
function p.extractcolor(frame)