Module:Check

From Coral Island Wiki
Revision as of 02:22, 4 August 2023 by Admin coral island (talk | contribs) (Created page with "-- Module Check -- -- Written by User:Shining-Armor -- -- Version 0.0.1 -- -- Last updated 9-15-2014 --<nowiki> local p = {} -- {{#invoke: Check|isMatch|Case Sensitive|arg1|arg2|ifTrue|ifFalse}} -- -- {{#invoke: Check|isMatch|false|Cat|Dog|Animal is a cat|Animal is not a cat}} -> Animal is not a cat function p.isMatch( frame ) if frame.args[1] == 'true' then frame.args[2] = string.lower(frame.args[2]) frame.args[3] = string.lower(frame.args[3])...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Check/doc

-- Module Check
--
-- Written by [[User:Shining-Armor]]
--
-- Version 0.0.1
--
-- Last updated 9-15-2014
--<nowiki>

local p = {}


-- {{#invoke: Check|isMatch|Case Sensitive|arg1|arg2|ifTrue|ifFalse}}
--
-- {{#invoke: Check|isMatch|false|Cat|Dog|Animal is a cat|Animal is not a cat}} -> Animal is not a cat
function p.isMatch( frame )
    if frame.args[1] == 'true' then
        frame.args[2] = string.lower(frame.args[2])
        frame.args[3] = string.lower(frame.args[3])        
    end

    if frame.args[2] == frame.args[3] then
        return frame.args[4]
    else
        return frame.args[5]
    end
end

-- {{#invoke: Check|arg1}}
--
-- {{#invoke: Check|}} -> true
-- {{#invoke: Check|Cat}} -> false
function p.isNull( frame )
    if frame.args[1] == nil or frame.args[1] == '' then
        return true
    else
        return false
    end
end

-- {{#invoke: Check|arg1|default}}
--
-- {{#invoke: Check||Dog}} -> Dog
-- {{#invoke: Check|Cat|Dog}} -> Cat
function p.isNullDefault( frame )
    if frame.args[1] == nil or frame.args[1] == '' then
        return frame.args[2]
    else
        return frame.args[1]
    end
end

return p
--</nowiki>