Module:InputBadge

From BerserkerLoop
Revision as of 09:06, 31 May 2023 by Crimsongaia (talk | contribs) (Created page with "local p = {} function p.drawInputBadge(frame) local wikitext = "" local numInputs = count(frame.args[1], '\\') + 1 local index = 1 for token in string.gmatch(frame.args[1], '([^\\]+)') do input = token wikitext = wikitext .. "<span class=\"input-badge\"><b\>" .. input .. "</b></span>" if index ~= numInputs then wikitext = wikitext .. " or " end index = index + 1 end return wikitext end function count(base, pattern) retu...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

local p = {}

function p.drawInputBadge(frame)
  local wikitext = ""
  local numInputs = count(frame.args[1], '\\') + 1
  local index = 1
  for token in string.gmatch(frame.args[1], '([^\\]+)') do
    input = token

    wikitext = wikitext .. "<span class=\"input-badge\"><b\>" .. input .. "</b></span>"
  
    if index ~= numInputs then
      wikitext = wikitext .. " or "
    end

    index = index + 1
  end
  
  return wikitext
end

function count(base, pattern)
    return select(2, string.gsub(base, pattern, ""))
end

return p