Jump to content

Module:Sandbox/Dat Hack3r: Difference between revisions

Dat Hack3r (talk | contribs)
Fixed "string expected, got table" when using a title object.
Dat Hack3r (talk | contribs)
Fixed overly-limited scope of "curr_num".
Line 7: Line 7:
title_format = title_format or string.gsub(title.text, '%d+', '%%d', 1)
title_format = title_format or string.gsub(title.text, '%d+', '%%d', 1)
text_format = text_format or '%d'
text_format = text_format or '%d'
local curr_num
if title_format then
if title_format then
local curr_num = string.match(title.text, string.gsub(title_format, "%%d", "(%%d+)"))
curr_num = tonumber(string.match(title.text, string.gsub(title_format, "%%d", "(%%d+)")))
else
else
local curr_num = string.match(title.text, '%d+')
curr_num = tonumber(string.match(title.text, '%d+'))
end
end