Module:Param Parse: Difference between revisions

m
no edit summary
No edit summary
mNo edit summary
Line 4:
-- <nowiki>
 
local paramparse = {}
 
 
-- Standardized "has content" function
function paramparse.has_content(arg)
-- Return arg if any non-whitespace character is found
return string.match(arg or '', '%S') and arg or nil
Line 15:
 
-- Standardized image function
function paramparse.image(img)
if img and img:find('%S') then
return img
Line 21:
return nil
end
function paramparse.image_smw(img)
return string.match(img, "File:.-%.png")
end
Line 27:
 
-- Standardized numbers
function paramparse.number(num)
num = string.gsub(num or '',',','')
return tonumber(num)
Line 35:
-- Episode
local valid_episodes = {['Hopeport'] = 1, ['Hopeforest'] = 1, ['Mine of Mantuban'] = 1, ['Crenopolis'] = 1}
function paramparse.episode(episode)
if valid_episodes[episode] then
return '[[File:'..episode..' episode icon.png|18px]] [['..episode..']]'
Line 41:
return nil
end
function paramparse.episode_smw(episode)
if valid_episodes[episode] then
return episode
Line 48:
end
 
return paramparse
 
-- </nowiki>