Module:Param Parse: Difference between revisions
Smw support for number ranges
(Level range support) |
(Smw support for number ranges) |
||
Line 23:
end
-- Standardized number range: Accepts '1' and '1-5'
function parse.
local
local count = 0
for out in string.gmatch(prenum, "[^-]+") do
if count == 1 then
elseif count == 3 then
return nil
end
num =
return nil
end▼
ret = ret .. num
count = count + 1
end
return
end
function parse.number_or_number_range_low(prenum)
local count = 0
local value = nil
for out in string.gmatch(prenum, "[^-]+") do
if parse.number(out) == nil then
return nil
end
count = count + 1
if count == 1 then
value = out
end
if count > 2 then
return nil
end
end
return parse.number(value)
end
function parse.number_or_number_range_high(prenum)
local count = 0
local value = nil
for out in string.gmatch(prenum, "[^-]+") do
if parse.number(out) == nil then
return nil
end
count = count + 1
if count == 2 then
value = out
end
if count > 2 then
return nil
end
end
return parse.number(value)
end
Line 253 ⟶ 293:
}
-- Profession
function parse.profession_bubble_func(profession, level)
local profession_valid = parse.has_content(profession)
local profession_valid_link = profession_valid
local level_valid = parse.
local category_error = false
if not profession_valid and not level_valid then
Line 269 ⟶ 309:
end
if profession_valid and not level_valid then
--
level_valid =
▲ if not level_valid then
▲ category_error = true
▲ end
end
return '[[File:'..profession_valid..' icon.png|x30px|link='..profession_valid_link..']] '..level_valid..(category_error and '[[Category:Invalid profession bubble]]' or '')
Line 303 ⟶ 339:
parse.profession_a_level_smw = {
name = 'profession_a_level',
func = parse.
smw_property = 'Profession Level A',
}
parse.profession_a_level_high_smw = {
name = 'profession_a_level_high',
func = {name = parse.number_or_number_range_high, params = {Infobox.raw_param('profession_a_level')}},
smw_property = 'Profession Level A High',
}
parse.profession_bubble_b = {
Line 319 ⟶ 360:
parse.profession_b_level_smw = {
name = 'profession_b_level',
func = parse.
smw_property = 'Profession Level B',
}
parse.profession_b_level_high_smw = {
name = 'profession_b_level_high',
func = {name = parse.number_or_number_range_high, params = {Infobox.raw_param('profession_b_level')}},
smw_property = 'Profession Level B High',
}
|