Module:InputBadge

From Dustloop Wiki
Revision as of 19:15, 12 January 2023 by DarthPhallus (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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