Module:Param Parse: Difference between revisions
Support unlock_level = N/A for things that aren't unlocked (like Training Dummy and quest bosses)
mNo edit summary |
(Support unlock_level = N/A for things that aren't unlocked (like Training Dummy and quest bosses)) |
||
Line 672:
-- Unlock Level
function parse.unlock_profession_func(unlock_profession, profession, level)
if level == 'N/A' then
return parse.has_content(unlock_profession) or parse.has_content(profession)▼
return parse.has_content(unlock_profession or 'N/A')
end
end
function parse.unlock_profession_func_smw(unlock_profession, profession, level)
local prof = parse.unlock_profession_func(unlock_profession, profession, level)
if prof == 'N/A' then
return nil
end
return prof
end
function parse.unlock_level_func(unlock_profession, profession, level)
if parse.has_content(level) == 'N/A' then
-- unlock_profession set but level = N/A is not handled, handle it here
-- (and in the smw func) if needed for whatever reason
return 'N/A'
end
local level_valid = parse.number(level)
local profession_valid = parse.unlock_profession_func(unlock_profession, profession, level)
local profession_valid_link = profession_valid
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
Line 690 ⟶ 707:
profession_valid_link = ''
end
if profession_valid and not level_valid then
-- Profession defined without level, invalid, show an unknown level
level_valid = '?'
end
return '[[File:'..profession_valid..'_icon.png|link='..profession_valid_link..'|width=18x18]] '..level_valid
end
function parse.unlock_level_smw(unlock_profession, profession, level)
if parse.has_content(level) == 'N/A' then
return nil
end
local profession_valid = parse.unlock_profession_func(unlock_profession, profession)
local level_valid = parse.number(level)
if not profession_valid then
return nil
end
if not level_valid then
return nil
Line 716 ⟶ 736:
parse.unlock_profession = {
name = 'unlock_profession',
func = {name = parse.unlock_profession_func, params = {Infobox.raw_param('unlock_profession'), Infobox.raw_param('profession_a'), Infobox.raw_param('unlock_level')}},
smw_property = 'Unlock profession',
smw_func = {name = parse.unlock_profession_func_smw, params = {Infobox.raw_param('unlock_profession'), Infobox.raw_param('profession_a'), Infobox.raw_param('unlock_level')}},
}
|