Module:Utils: Difference between revisions

Fredg999 (talk | contribs)
Bug fixing
Fredg999 (talk | contribs)
Bug fixing
Line 8: Line 8:
result = def_value
result = def_value
if type(input) == 'string' then
if type(input) == 'string' then
local denominator = 1
if input:match('/') == '/' then
input, denominator = input:match("^%s*(.-)[/?](.-)%s*$")
local denominator = 1
if string.len(input) > 0 then
input, denominator = input:match("^%s*(.-)[/?](.-)%s*$")
result = tonumber(input)/tonumber(denominator)
result = tonumber(input)/tonumber(denominator)
else
input = input:match("^%s*(.-)%s*$")
result = tonumber(input)
end
end
end
end