Module:Param Parse: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
No edit summary |
(Cleaning up module, and adding episode) |
||
Line 5: | Line 5: | ||
local param = {} |
local param = {} |
||
-- Standardized "name" function |
|||
⚫ | |||
return string.match(arg or '', '%S') and arg or nil |
|||
⚫ | |||
Line 16: | Line 10: | ||
function param.has_content(arg, default) |
function param.has_content(arg, default) |
||
-- Return arg if any non-whitespace character is found |
-- Return arg if any non-whitespace character is found |
||
return string.match(arg or '', '%S') and arg or |
return string.match(arg or '', '%S') and arg or nil |
||
⚫ | |||
-- Create a standardized release function, since so many pages use it |
|||
-- Turns release and update into a single parameter |
|||
function param.release_update(release, update) |
|||
if not Infobox.isDefined(release) then |
|||
⚫ | |||
⚫ | |||
if string.lower(release) == 'no' then |
|||
⚫ | |||
⚫ | |||
if not Infobox.isDefined(update) then |
|||
return string.format('%s (Update unknown)',release) |
|||
end |
|||
if string.lower(update) == 'no' then |
|||
⚫ | |||
end |
|||
return string.format('%s ([[Update:%s|Update]])', release, update) |
|||
end |
end |
||
Line 43: | Line 18: | ||
if img and img:find('%S') then |
if img and img:find('%S') then |
||
return img |
return img |
||
else |
|||
⚫ | |||
end |
end |
||
⚫ | |||
end |
end |
||
-- Strip the brackets from the param |
|||
function param.image_smw(img) |
function param.image_smw(img) |
||
return string.match(img, "File:.-%.png") |
|||
return _img |
|||
end |
end |
||
Line 60: | Line 30: | ||
num = string.gsub(num or '',',','') |
num = string.gsub(num or '',',','') |
||
return tonumber(num) |
return tonumber(num) |
||
⚫ | |||
-- Episode |
|||
local valid_episodes = {['Hopeport'] = 1, ['Hopeforest'] = 1, ['Mine of Mantuban'] = 1, ['Crenopolis'] = 1} |
|||
⚫ | |||
if valid_episodes[episode] then |
|||
return '[[File:'..episode..' episode icon.png|18px]]' |
|||
⚫ | |||
⚫ | |||
⚫ | |||
function param.episode_smw(episode) |
|||
if valid_episodes[episode] then |
|||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||