No edit summary
No edit summary
Line 8: Line 8:
   local output = {}
   local output = {}


   -- Split items by comma
   -- Split items by semicolon
   for filename in string.gmatch(itemParam, '([^;]+)') do
   for filename in string.gmatch(itemParam, '([^;]+)') do
     filename = filename:gsub("^%s*(.-)%s*$", "%1") -- trim spaces
     filename = filename:gsub("^%s*(.-)%s*$", "%1") -- trim spaces
Line 27: Line 27:
   local itemContainer = '<div class="image-sequence" style="width:32px;"><div class="image-sequence-group">' .. table.concat(output, "") .. '</div></div>'
   local itemContainer = '<div class="image-sequence" style="width:32px;"><div class="image-sequence-group">' .. table.concat(output, "") .. '</div></div>'


   local tooltipText = tooltip or (args.item or "")
  -- Use tooltipParam instead of undefined tooltip
   local tooltipText = tooltipParam or (args.item or "")
   if not tooltipText or tooltipText == "" then
   if not tooltipText or tooltipText == "" then
     tooltipText = ""
     tooltipText = ""

Revision as of 06:34, 27 November 2025

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

local p = {}

function p.render(frame)
  local args = frame:getParent().args
  local itemParam = args.item or ""
  local tooltipParam = args.tooltip

  local output = {}

  -- Split items by semicolon
  for filename in string.gmatch(itemParam, '([^;]+)') do
    filename = filename:gsub("^%s*(.-)%s*$", "%1") -- trim spaces

    if not filename:lower():match("%.png$") then
      filename = filename .. ".png"
    end

    local imgTag
    if args.link and args.link ~= "" then
      imgTag = string.format('[[File:%s|link=%s]]', filename, args.link)
    else
      imgTag = string.format('[[File:%s]]', filename)
    end
    table.insert(output, imgTag)
  end

  local itemContainer = '<div class="image-sequence" style="width:32px;"><div class="image-sequence-group">' .. table.concat(output, "") .. '</div></div>'

  -- Use tooltipParam instead of undefined tooltip
  local tooltipText = tooltipParam or (args.item or "")
  if not tooltipText or tooltipText == "" then
    tooltipText = ""
  end

  local result = '<div class="item-slot">' .. itemContainer

  if tooltipText ~= "" then
    result = result .. '<span class="item-tooltip">' .. tooltipText .. '</span>'
  end

  result = result .. '</div>'

  return result
end

return p