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 180: Line 180:
size = '|x'..height..'px'
size = '|x'..height..'px'
end
end
if name then
local imagecheck = name and mw.smw.ask('[['..name..']]|?Modification date=data')
imagecheck = imagecheck~=nil and imagecheck[1]~=nil and imagecheck[1].data~=nil
if name and imagecheck then
return '[['..name..size..']]'
return '[['..name..size..']]'
elseif name then
return '[['..name..size..']][[Category:Needs image]]'
end
end
return nil
return nil
Line 213: Line 209:
-- Episode
-- Episode
local valid_episodes = {
local valid_episodes = {
['none'] = { 0, 'None' },
['none'] = 'None',
['hopeport'] = { 1, 'Hopeport' },
['hopeport'] = 'Hopeport',
['hopeforest'] = { 2, 'Hopeforest' },
['hopeforest'] = 'Hopeforest',
['mine of mantuban'] = { 3, 'Mine of Mantuban' },
['mine of mantuban'] = 'Mine of Mantuban',
['crenopolis'] = { 4, 'Crenopolis' },
['crenopolis'] = 'Crenopolis',
['stonemaw hill'] = { 5, 'Stonemaw Hill' },
['stonemaw hill'] = 'Stonemaw Hill',
['bleakholm crags'] = { 6, 'Bleakholm Crags' },
['bleakholm crags'] = 'Bleakholm Crags'
}
}
function parse.episode_func(episode)
function parse.episode_func(episode)
local valid_episode = valid_episodes[string.lower(episode or '')]
local valid_episode = valid_episodes[string.lower(episode or '')]
if valid_episode then
if valid_episode then
if valid_episode == 'None' then
local sort = valid_episode[1]
return '[[File:Unknown episode icon.png|18px|link=]] None'
local name = valid_episode[2]
else
local link = name
return '[[File:'..valid_episode..' episode icon.png|18px|link='..valid_episode..']] [['..valid_episode..']]'
local label = '[[' .. name .. ']]'
if sort == 0 then
name = 'Unknown'
link = ''
label = 'None'
end
end
return ('<span data-sort-value="%s">[[File:%s episode icon.png|18px|link=%s]] %s</span>'):format(sort, name, link, label)
end
end
return nil
return nil
Line 240: Line 231:
local valid_episode = valid_episodes[string.lower(episode or '')]
local valid_episode = valid_episodes[string.lower(episode or '')]
if valid_episode then
if valid_episode then
return valid_episode[2]
return valid_episode
end
end
return nil
return nil
Line 456: Line 447:
end
end
function parse.variant_category_func(v)
function parse.variant_category_func(v)
v = parse.has_content(v)
if v == nil then
if v == nil then
return nil
return nil
Line 468: Line 458:
end
end
return ('[[%s|%s]]'):format(v, name)
return ('[[%s|%s]]'):format(v, name)
end
function parse.variant_smw_func(v)
v = parse.has_content(v)
if v == 'N/A' then
return
end
return v
end
end
local function name_without_variant_category(name, variant_name)
local function name_without_variant_category(name, variant_name)
variant_name = parse.variant_smw_func(variant_name)
if name:sub(-1-#variant_name) == ' '..variant_name then
if variant_name and name:sub(-1-#variant_name) == ' '..variant_name then
-- Ends with the variant name. Remove it
-- Ends with the variant name. Remove it
name = name:sub(1, -2-#variant_name)
name = name:sub(1, -2-#variant_name)
Line 485: Line 467:
end
end
local function name_with_variant_category(name, v, passive, is_for_smw)
local function name_with_variant_category(name, v, passive, is_for_smw)
v = parse.variant_smw_func(v)
if v == nil then
if v == nil then
return name
return name
Line 529: Line 510:
name = 'variant',
name = 'variant',
func = parse.variant_category_func,
func = parse.variant_category_func,
smw_func = parse.variant_smw_func,
smw_func = parse.has_content,
smw_property = 'Variant of',
smw_property = 'Variant of',
category_incomplete = 'Needs variant'
category_incomplete = 'Needs variant'
Line 553: Line 534:
['monster'] = 'Monster',
['monster'] = 'Monster',
['skill node'] = 'Skill node',
['skill node'] = 'Skill node',
['venture'] = 'Venture',
['venture'] = 'Venture'
['bounty'] = 'Bounty'
}
}
function parse.variant_type_func(type)
function parse.variant_type_func(type)
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: