Module:Loops

-- Module for various loops used in various templates on the wiki -- Author: KockaAdmiralac -- local p = {};

function template_args return mw.getCurrentFrame:getParent.args end

function p.translation(frame) local args = template_args local ret = '' for i, v in ipairs(args) do       ret = ret .. ' • '   end return frame:preprocess(ret .. '') end

function p.dots(frame) local args = template_args local ret = '' for i, v in ipairs(args) do       ret = ret .. v .. ' • '   end ret = string.gsub(ret, ' • $', '') return ret end

-- Author: SandyTree -- I want refwn to loop, but it won't for some reason. Need to research Scribunto HTML elements more. Maybe XML characters -- Lua will translate among other things into strings function p.arrowdots(frame) local speciesCategory = mw.loadData('Module:Cat') local progdata = mw.loadData('Module:Species')

local args = template_args local ret = '' for i, v in ipairs(args) do       local categorizationCall = frame:preprocess('') ret = ret .. categorizationCall .. progdata[v] .. ' → '   end -- for i, v in ipairs(args) do   --     cat = frame:preprocess('') -- end ret = string.gsub(ret, ' → $', '') -- cat = string.gsub(cat, 'Category' .. , ) return ret end

function p.refwn(frame) local args = template_args local ret = '' local ref1 = mw.text.encode local ref = mw.html.create('ref') for i, v in ipairs(args) do       ret = ref :attr('name', 'wn' .. v)           :wikitext('Chapter ' .. v .. ' (Web Novel)') end -- ret = string(ret, ref, '') return ret end

function p.jobselect(frame) local args = template_args local ret = '' local style = 'background:gold; color:rgb(109, 83, 16); border:1px solid goldenrod; font-weight:450; text-align:center; display:inline-block; padding:.1rem .7rem; border-radius:20rem; align-items:center; margin:.2rem;' for i, v in ipairs(args) do       ret = ret .. ' ' .. v .. ' ' end ret = string.gsub(ret, ' • $', '') return ret end

function p.charAppearance(frame) local args = template_args local ret = '' for i, v in ipairs(args) do       ret = ret .. 'Manga ' .. v .. '.png|link=' .. v .. '|' .. v .. '' .. ' '   end ret = string.gsub(ret, ' • $', '') return ret end

function p.pagetabs(frame) local args = template_args local ret = '' local basepagename = mw.title.getCurrentTitle.baseText local basepage = basepagename .. '/' or frame.args['basepage'] for i, v in ipairs(args) do   	local style = 'float:left; font-weight:bold; text-align:center; min-width:5.0em; max-width:15em; padding:.0em 0.5em; border:1.5px solid gray; border-radius:4px 4px 0px 0px; margin-right:3px; margin-bottom:5px; overflow:hidden;' ret = ret .. '' .. v .. ' ' end ret = string.gsub(ret, ' • $', '') return ret end

function p.loop(frame) local args = template_args local cols = frame.args[1] local template = frame.args[2] local ret = '' local data = {} local del = 0 if frame.args[3] then del = tonumber(frame.args[3]) end for i, v in ipairs(args) do       local ind = i - del local index = math.ceil(ind / cols) if ind > 0 then if not(data[index]) then data[index] = {} end data[index][((ind - 1) % cols) + 1] = v       end end for i, v in ipairs(data) do       ret = ret .. '{' .. '{' .. template .. '/element|' for i2, v2 in ipairs(v) do           ret = ret .. mw.text.trim(v2) .. '|'       end ret = ret .. '}}'   end return frame:preprocess(ret) end

return p --