Module:TEpisodes

local p = {}

function p.peanuts(frame) local tArgs = frame:getParent if not(tArgs.args[1]) then tArgs = frame end local result result = '' pic = '' title = mw.title.getCurrentTitle.text user = '' collapse = 'mw-collapsed' dash = '' for key, value in ipairs(tArgs.args) do       -- remove spaces and \n of values to test editedvalue = string.gsub(string.gsub(value, "\n", "")," ","") if (tonumber(key) ~= nil) then -- Title of video if (key % 2 == 1) then result = result .. '|-\n! style="text-align:left;font-weight:normal;padding-left:5px" colspan="4"|' .. string.gsub(string.gsub(value, "\\", "&#124;"),"!","&#33;") .. '\n' -- YouTube link elseif (key % 2 == 0) then if (editedvalue == 'N/A') then result = result .. '| style="text-align:center" | N/A \n' elseif (string.len(editedvalue) ~= 11) then -- Error: YouTube link does not exist return ' Error! Please check that you have used the template right by checking the documentation here. ' ..                    'Reason: This is meant to be an 11 character YouTube link. There was an error at [' .. key .. ']: ' .. value .. ' '               else result = result .. '| style="text-align:center" |[https://www.youtube.com/watch?v=' .. editedvalue .. ' Watch]\n' end -- Yogscast link else result = result end elseif (key == 'collapse') then if (editedvalue == '1') then -- do not collapse the module collapse = '' end else -- Error: Unknown key return ' Error! Please check that you have used the template right by checking the documentation here. ' ..            'Reason: Unknown key (|randomname=). There was an error at [' .. key .. ']: ' .. value .. ' '       end end user = frame.args.user pic = frame.args.pic title = frame.args.title if (title ==  or title == ) then title = mw.title.getCurrentTitle.text end if (pic ==  or pic ==  ) then picx = '' else picx = '! width="44px" style="min-width:45px; max-width:45px"|' .. pic .. '\n' end if (user == '') then user = '' end title = title:gsub("_", " ") if (title ~=  and user ~= ) then -- removes dash if either title or user don't exist dash = ' — ' end return '{| class="wikitable mw-collapsible ' .. collapse .. ' episodeguide" style="width:100%;clear:both;"' .. '\n' .. picx .. '!style="padding:10px;text-align:left;" colspan="4"|' .. user .. dash .. title .. '\n' .. '|-\n' .. result .. '|}' end

return p