Module:Param Parse: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
No edit summary |
mNo edit summary |
||
Line 4: | Line 4: | ||
-- <nowiki> |
-- <nowiki> |
||
local |
local parse = {} |
||
-- Standardized "has content" function |
-- Standardized "has content" function |
||
function |
function parse.has_content(arg) |
||
-- 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 nil |
return string.match(arg or '', '%S') and arg or nil |
||
Line 15: | Line 15: | ||
-- Standardized image function |
-- Standardized image function |
||
function |
function parse.image(img) |
||
if img and img:find('%S') then |
if img and img:find('%S') then |
||
return img |
return img |
||
Line 21: | Line 21: | ||
return nil |
return nil |
||
end |
end |
||
function |
function parse.image_smw(img) |
||
return string.match(img, "File:.-%.png") |
return string.match(img, "File:.-%.png") |
||
end |
end |
||
Line 27: | Line 27: | ||
-- Standardized numbers |
-- Standardized numbers |
||
function |
function parse.number(num) |
||
num = string.gsub(num or '',',','') |
num = string.gsub(num or '',',','') |
||
return tonumber(num) |
return tonumber(num) |
||
Line 35: | Line 35: | ||
-- Episode |
-- Episode |
||
local valid_episodes = {['Hopeport'] = 1, ['Hopeforest'] = 1, ['Mine of Mantuban'] = 1, ['Crenopolis'] = 1} |
local valid_episodes = {['Hopeport'] = 1, ['Hopeforest'] = 1, ['Mine of Mantuban'] = 1, ['Crenopolis'] = 1} |
||
function |
function parse.episode(episode) |
||
if valid_episodes[episode] then |
if valid_episodes[episode] then |
||
return '[[File:'..episode..' episode icon.png|18px]] [['..episode..']]' |
return '[[File:'..episode..' episode icon.png|18px]] [['..episode..']]' |
||
Line 41: | Line 41: | ||
return nil |
return nil |
||
end |
end |
||
function |
function parse.episode_smw(episode) |
||
if valid_episodes[episode] then |
if valid_episodes[episode] then |
||
return episode |
return episode |
||
Line 48: | Line 48: | ||
end |
end |
||
return |
return parse |
||
-- </nowiki> |
-- </nowiki> |