Module:Multiblock Slot: Difference between revisions
Appearance
Created page with " local p = {} local aliases = mw.loadData( "Module:Inventory slot/Aliases" ) local function resolveAlias(material) local alias = aliases[material] if type(alias) == "string" then return alias end if type(alias) == "table" then if alias.name then return alias.name end if alias[1] then if type(alias[1]) == "string" then return alias[1] elseif alias[1].name then..." |
No edit summary |
||
| Line 50: | Line 50: | ||
"|alt=" .. material .. "]]" | "|alt=" .. material .. "]]" | ||
) | ) | ||
-- Add stack number, matching original inventory slot styling | |||
if tonumber(amount) and tonumber(amount) > 1 then | if tonumber(amount) and tonumber(amount) > 1 | ||
and tonumber(amount) < 1000 then | |||
icon:tag("span") | icon:tag("span") | ||
:addClass(" | :addClass("invslot-stacksize") | ||
:attr("title", material) | |||
:wikitext(amount) | :wikitext(amount) | ||
end | end | ||
return tostring(icon) | return tostring(icon) | ||
end | end | ||
return p | return p | ||
Revision as of 04:39, 1 November 2026
Documentation for this module may be created at Module:Multiblock Slot/doc
local p = {}
local aliases = mw.loadData(
"Module:Inventory slot/Aliases"
)
local function resolveAlias(material)
local alias = aliases[material]
if type(alias) == "string" then
return alias
end
if type(alias) == "table" then
if alias.name then
return alias.name
end
if alias[1] then
if type(alias[1]) == "string" then
return alias[1]
elseif alias[1].name then
return alias[1].name
end
end
end
return material
end
function p.render(frame)
local args = frame.args or frame:getParent().args
local material = mw.text.trim(args[1] or "")
local amount = mw.text.trim(args[2] or "")
if material == "" then
return ""
end
local spriteName = resolveAlias(material)
local filename = "Invicon " .. spriteName .. ".png"
local icon = mw.html.create("span")
:addClass("multiblock-slot")
:wikitext(
"[[File:" .. filename ..
"|32x32px|link=" .. material ..
"|alt=" .. material .. "]]"
)
-- Add stack number, matching original inventory slot styling
if tonumber(amount) and tonumber(amount) > 1
and tonumber(amount) < 1000 then
icon:tag("span")
:addClass("invslot-stacksize")
:attr("title", material)
:wikitext(amount)
end
return tostring(icon)
end
return p