Module:Items: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 544: Line 544:


function p.getItemGrid(frame)
function p.getItemGrid(frame)
local resultPart = {}
--melvorD, melvorTotH, melvorAoD
table.insert(resultPart, '{|')
local dlcFunc = function(item, dlc)
for i, item in ipairs(GameData.rawData.items) do
local itemDLC = Shared.getLocalID(item.id)
if i % 17 == 1 then
if dlc == 'all' then
table.insert(resultPart, '\r\n|-\r\n|')
return true
else
end
table.insert(resultPart, '||')
if itemDLC == dlc then
return true
end
return false
end
 
local args = frame:getParent().args
local dlc = args[1] or args.DLC or args.dlc or nil
local columns = args[2] or args.Columns or args.columns or 17
 
local html = mw.html.create('table')
:addClass('wikitable lighttable individual')
 
local curRow = html:tag('tr')
local i = 0
for _, v in pairs(GameData.rawData.items) do
if dlcFunc(v, dlc) == true then
if i == columns then
curRow = html:tag('tr')
i = 0
else
cell = curRow:tag('td')
:css('height', '48px')
:css('width', '48px')
:css('padding', '0px')
cell:tag('div')
:css('padding', '8px')
:wikitext(Icons.Icon({v.name, type='item', notext=true, size='32'}))
-- Mod operator is slow. We use this instead
i = i + 1
end
end
end
table.insert(resultPart, 'style="padding:3px"|'..Icons.Icon({item.name, type='item', notext=true, size='40'}))
end
end
table.insert(resultPart, '\r\n|}')
return table.concat(resultPart)
return tostring(html)
end
end


2,875

edits