Module:ItemInfoBox: Difference between revisions
From Alundra
No edit summary |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 30: | Line 30: | ||
if image and image ~= "" then | if image and image ~= "" then | ||
out = out .. string.format( | out = out .. string.format( | ||
'<div style="text-align:center;margin-bottom:0.5rem;">[[File:%s|center|64px]]</div><hr/>', | '<div class=pixelart style="text-align:center;margin-bottom:0.5rem;">[[File:%s|center|64px]]</div><hr/>', | ||
image | image | ||
) | ) | ||
| Line 77: | Line 77: | ||
newBlockSet = true | newBlockSet = true | ||
end | end | ||
out = out .. string.format('<div>[[File:250px]]</div>', sFile) | out = out .. string.format('<div>[[File:%s|250px]]</div>', sFile) | ||
end | end | ||
end | end | ||
Latest revision as of 18:58, 23 May 2026
Documentation for this module may be created at Module:ItemInfoBox/doc
local p = {}
local function GenItemProperty(args, label, property, prefix, suffix)
local value = args[property]
if value == nil or value == "" then
return ""
end
prefix = prefix or ""
suffix = suffix or ""
return string.format(
'<div style="display:flex; padding-right:10px"><div>%s</div><div style="flex-grow:1;text-align:right;">%s%s%s</div></div>',
label,
prefix,
value,
suffix
)
end
function p.render(frame)
local args = frame:getParent().args
local newBlockSet = false -- usage of loops
local out = ""
local image = args["image"]
if image and image ~= "" then
out = out .. string.format(
'<div class=pixelart style="text-align:center;margin-bottom:0.5rem;">[[File:%s|center|64px]]</div><hr/>',
image
)
end
out = out .. GenItemProperty(args, "Stack size", "stacksize")
out = out .. GenItemProperty(args, "Damage", "damage")
out = out .. GenItemProperty(args, "Damage charged", "damage_charged")
out = out .. GenItemProperty(args, "Damage reduction", "damage_reduction")
out = out .. GenItemProperty(args, "Health", "health")
out = out .. GenItemProperty(args, "Mana", "mana")
out = out .. GenItemProperty(args, "Price", "price", "", " [[File:Coin_Gold.png]]")
local info = args["info"]
if info and info ~= "" then
out = out .. string.format('<div>%s</div>', info)
end
local itemText = args["item_text"]
if itemText and itemText ~= "" then
out = out .. string.format('<hr/><div>%s</div>', itemText)
end
newBlockSet = false
for i = 1, 10 do
local text = args["anim" .. i .. "_text"]
local file = args["anim" .. i .. "_file"]
local sFile = args["sound" .. i .. "_file"]
if file and file ~= "" then
if newBlockSet == false then
out = out .. '<hr/>'
newBlockSet = true
end
if text and text ~= "" then
out = out .. string.format('<div>%s</div>', text)
end
out = out .. string.format('<div>[[File:%s]]</div>', file)
end
if sFile and sFile ~= "" then
if newBlockSet == false then
out = out .. '<hr/>'
newBlockSet = true
end
out = out .. string.format('<div>[[File:%s|250px]]</div>', sFile)
end
end
return out
end
return p