Module:Notice

-- @protect -- @module      Notice -- @description Module for Notice Templates. -- @version     1.0 -- @usage -- @author      TheGoldenPatrik1 -- @release     Beta

local p = {} local yesno = require('Dev:Yesno') local userError = require('Dev:User error') local data = mw.loadData('Module:Notice/data')

function p.text(templateargs) local str = {} local len = 0 for i, v in ipairs(templateargs) do       table.insert(str, v)        len = i    end if len == 1 then return str[1] elseif len == 2 then return table.concat(str, ' and ') else str[len] = 'and ' .. str[len] return table.concat(str, ', ') end end function p.beta(frame) local pargs = frame:getParent.args local text = p.text(pargs) end

-- @method      p.fanon -- @description Creates a fanon notice template -- @param       {String} version - The type of template -- @param       {String} a - The first arg -- @param       {String} b - The second arg -- @param       {String} c - The third arg -- @param       {String} free - The free arg function p.fanon(version, a, b, c, free) if yesno(free, true) then if a then if b then return data[version].intro....a..' and '..b....data[version].disclaimer..data[version].free..data[version].conclusion else return data[version].intro....a....data[version].disclaimer..data[version].free..data[version].conclusion end else return data[version].intro..'a fan of MooMoo.io'..data[version].disclaimer..data[version].free..data[version].conclusion end elseif a then if b then return data[version].intro....a..' and '..b....data[version].disclaimer..data[version].closed..data[version].conclusion else return data[version].intro....a....data[version].disclaimer..data[version].closed..data[version].conclusion end else return data[version].intro..'a fan of MooMoo.io'..data[version].disclaimer..data[version].closed..data[version].conclusion end end

-- @method      p.notice -- @description Builds the notice template -- @param       {String} frame - User input function p.notice(frame) local variant = frame.args[1] local param = frame:getParent.args local a = param[1] local b = param[2] local c = param[3] local free = param['free'] if       variant == 'fanon' or        variant == 'story' or        variant == 'minigame' then return p.fanon(variant, a, b, c, free) else return userError('invalid notice type', 'Pages with user errors') end end

return p