Module:Paramtest: Difference between revisionsGive feedback
osrsw>The Mol Man mNo edit summary |
osrsw>Spineweilder No edit summary |
||
| Line 9: | Line 9: | ||
-- | -- | ||
function p.is_empty( arg ) | function p.is_empty(arg) | ||
return not arg or not arg:find('%S') | |||
end | end | ||
| Line 30: | Line 26: | ||
-- | -- | ||
-- | -- Returns a list of paramaters if it has any content, or the default | ||
-- | -- | ||
function p.defaults(...) | |||
function p. | local ret = {} | ||
if | for i, v in ipairs(...) do | ||
if v[1] and v[1]:find('%S') then | |||
table.insert(ret,v[1]) | |||
else | |||
-- or false, because nil is removed | |||
table.insert(ret,v[2] or false) | |||
end | |||
end | end | ||
return unpack(ret) | |||
return | |||
end | end | ||
-- | -- | ||
-- Tests if the parameter has | -- Tests if the parameter has content | ||
-- | -- The same as !is_empty, but this is more readily clear | ||
-- | -- | ||
function p. | function p.has_content(arg) | ||
return | return arg and arg:find('%S') | ||
end | end | ||
| Line 67: | Line 54: | ||
-- | -- | ||
function p.ucfirst( arg ) | function p.ucfirst(arg) | ||
if not arg or arg:len() == 0 then | if not arg or arg:len() == 0 then | ||
return nil | return nil | ||
| Line 81: | Line 68: | ||
-- | -- | ||
function p.ucflc( arg ) | function p.ucflc(arg) | ||
if not arg or arg:len() == 0 then | if not arg or arg:len() == 0 then | ||
return nil | return nil | ||