Editing Module:Param Parse

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 694: Line 694:


-- Unlock Level
-- Unlock Level
function parse.unlock_profession_func(unlock_profession, profession, level)
function parse.unlock_profession_func(unlock_profession, profession)
return parse.has_content(unlock_profession) or parse.has_content(profession)
if level == 'N/A' then
return parse.has_content(unlock_profession or 'N/A')
end
return parse.has_content(unlock_profession or profession)
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
end


function parse.unlock_level_func(unlock_profession, profession, level)
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 level_valid = parse.number(level)
local profession_valid = parse.unlock_profession_func(unlock_profession, profession, level)
local profession_valid = parse.unlock_profession_func(unlock_profession, profession)
local profession_valid_link = profession_valid
local profession_valid_link = profession_valid

if not profession_valid and not level_valid then
if not profession_valid and not level_valid then
return nil
return nil
end
end

if not profession_valid and level_valid then
if not profession_valid and level_valid then
-- Profession undefined but level defined, invalid, show an unknown profession
-- Profession undefined but level defined, invalid, show an unknown profession
Line 729: Line 712:
profession_valid_link = ''
profession_valid_link = ''
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
-- Profession defined without level, invalid, show an unknown level
level_valid = '?'
level_valid = '?'
end
end

return '[[File:'..profession_valid..'_icon.png|link='..profession_valid_link..'|width=18x18]] '..level_valid
return '[[File:'..profession_valid..'_icon.png|link='..profession_valid_link..'|width=18x18]] '..level_valid
end
end


function parse.unlock_level_smw(unlock_profession, profession, level)
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 profession_valid = parse.unlock_profession_func(unlock_profession, profession)
local level_valid = parse.number(level)
local level_valid = parse.number(level)

if not profession_valid then
if not profession_valid then
return nil
return nil
end
end

if not level_valid then
if not level_valid then
return nil
return nil
Line 758: Line 738:
parse.unlock_profession = {
parse.unlock_profession = {
name = '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')}},
func = {name = parse.unlock_profession_func, params = {Infobox.raw_param('unlock_profession'), Infobox.raw_param('profession_a')}},
smw_property = 'Unlock profession',
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')}},
}
}


Please note that all contributions to Brighter Shores Wiki are considered to be released under the CC BY-NC-SA 3.0 (see Brighter Shores:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template

This page is a member of a hidden category: