Module:Param Parse: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(going to merge episode + location pages bc there is no meaningful distinction)
(Level range support)
Line 21: Line 21:
num = string.gsub(num or '',',','')
num = string.gsub(num or '',',','')
return tonumber(num)
return tonumber(num)
end

-- Standardized number range
function parse.number_range(prenum)
local num = ""
local count = 0
for out in string.gmatch(prenum, "[^-]+") do
if count == 1 then
num = num .. "➨\n"
elseif count == 3 then
return
end
num = num .. string.gsub(out or '',',','')
count = count + 1
end
return num
end
end


Line 253: Line 269:
end
end
if profession_valid and not level_valid then
if profession_valid and not level_valid then
-- Profession defined without level, invalid, show an unknown level
-- check if its a level range instead
level_valid = '?'
level_valid = parse.number_range(level)
if not level_valid then
category_error = true
-- Profession defined without level, invalid, show an unknown level
level_valid = '?'
category_error = true
end
end
end
return '[[File:'..profession_valid..' icon.png|x30px|link='..profession_valid_link..']] '..level_valid..(category_error and '[[Category:Invalid profession bubble]]' or '')
return '[[File:'..profession_valid..' icon.png|x30px|link='..profession_valid_link..']] '..level_valid..(category_error and '[[Category:Invalid profession bubble]]' or '')