Module:InputBadge

From Dustloop Wiki

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