Module:Param Parse: Difference between revisions

Working on profession bubbles
(Change value to use parse.number instead of tonumber (supports commas in numbers))
(Working on profession bubbles)
Line 225:
 
-- Profession (TODO)
function parse.profession_bubble_func(profession, level)
local profession_valid = parse.has_content(profession)
local level_valid = parse.number(level)
local category_error = false
if not profession_valid and not level_valid then
return nil
end
if not profession_valid and level_valid then
-- Profession undefined but level defined, invalid, show an unknown profession
profession_valid = 'Unknown Profession'
category_error = true
end
if profession_valid and not level_valid then
-- Profession defined without level, invalid, show an unknown level
level_valid = '?'
category_error = true
end
return '[[File:'..profession_valid..' icon.png|x30px]] '..level_valid..category_error and '[[Category:Invalid Profession Bubble]]' or ''
end
function parse.profession_bubble_smw(profession, level)
local profession_valid = parse.has_content(profession)
local level_valid = parse.number(level)
if not profession_valid then
return nil
end
if not level_valid then
return nil
end
return profession_valid..','..level_valid
end
parse.profession_a = {
name = 'profession_a',
func = parse.has_content
}
parse.profession_a_level = {
name = 'profession_a_level',
func = parse.has_content
}
parse.profession_b = {
name = 'profession_b',
func = parse.has_content
}
parse.profession_b_level = {
name = 'profession_b_level',
func = parse.has_content
}
parse.profession_bubble_a = {
name = 'profession_bubble_a',
func = {name = parse.profession_bubble_func, params = {Infobox.raw_param('profession_a'), Infobox.raw_param('profession_a_level')}},
smw_property = 'Profession Requirement A',
smw_func = {name = parse.profession_bubble_smw, params = {Infobox.raw_param('profession_a'), Infobox.raw_param('profession_a_level')}},
}
parse.profession_bubble_b = {
name = 'profession_bubble_b',
func = {name = parse.profession_bubble_func, params = {Infobox.raw_param('profession_b'), Infobox.raw_param('profession_b_level')}},
smw_property = 'Profession Requirement A',
smw_func = {name = parse.profession_bubble_smw, params = {Infobox.raw_param('profession_b'), Infobox.raw_param('profession_b_level')}},
}
 
parse.profession = {
name = 'profession',