Module:InfoboxItem: Difference between revisions
Jump to navigation
Jump to search
Created page with "-- Module:InfoboxItem local p = {} function p.show(frame) local itemModule = frame.args[1] if not itemModule or itemModule == "" then return "❌ No data module provided" end local data = mw.loadData('Module:Data/' .. itemModule) local description = "" if data.DescriptionParts and #data.DescriptionParts > 0 then description = table.concat(data.DescriptionParts[1], " ") end local out = {} table.insert(out, '{| cl..." |
No edit summary |
||
Line 18: | Line 18: | ||
table.insert(out, '{| class="infobox"') | table.insert(out, '{| class="infobox"') | ||
table.insert(out, '|-') | table.insert(out, '|-') | ||
table.insert(out, '| colspan="2" style="text-align:center;" | [[File:' .. (data.Image or '') .. '|64px]]') | table.insert(out, '| colspan="2" style="text-align:center;" | [[File:' .. (data.Image..'.png' or '') .. '|64px]]') | ||
table.insert(out, '|-') | table.insert(out, '|-') | ||
table.insert(out, '! Name') | table.insert(out, '! Name') |
Revision as of 07:58, 31 July 2025
Documentation for this module may be created at Module:InfoboxItem/doc
-- Module:InfoboxItem
local p = {}
function p.show(frame)
local itemModule = frame.args[1]
if not itemModule or itemModule == "" then
return "❌ No data module provided"
end
local data = mw.loadData('Module:Data/' .. itemModule)
local description = ""
if data.DescriptionParts and #data.DescriptionParts > 0 then
description = table.concat(data.DescriptionParts[1], " ")
end
local out = {}
table.insert(out, '{| class="infobox"')
table.insert(out, '|-')
table.insert(out, '| colspan="2" style="text-align:center;" | [[File:' .. (data.Image..'.png' or '') .. '|64px]]')
table.insert(out, '|-')
table.insert(out, '! Name')
table.insert(out, '| ' .. (data.Name or ''))
table.insert(out, '|-')
table.insert(out, '! Stack size')
table.insert(out, '| ' .. (data.StackSize or ''))
table.insert(out, '|-')
table.insert(out, '! Description')
table.insert(out, '| ' .. description)
table.insert(out, '|}')
return table.concat(out, '\n')
end
return p