Neverwinter Wiki
Регистрация
Advertisement

Для документации этого модуля может быть создана страница Модуль:Test Project Companion equip/doc

local item_icon = require('Модуль:Item_icon')
local item_acquisition = require('Модуль:Item/Item acquisition')
local attributes = mw.loadData('Модуль:Item/Attributes') -- База данных параметров предметов

local p = {}

function p.Main( frame )
    local cargo = mw.ext.cargo
    local tables = 'Items, Items__categories=typeA, Items__categories=typeB'
    local fields = 'Items.name, Items.icon, Items.item_level, Items.categories__full'

    for _, attribute in ipairs(attributes) do
    	fields = fields .. ', Items.' .. attribute.fields_cargo
	end

    local args = {
    	join = 'Items._ID=typeA._rowID,Items._ID=typeB._rowID',
        where = 'typeA._value="только для спутников" AND typeB._value="' .. frame.args['тип'] .. '"',
        orderBy = 'Items.item_level DESC, name,'
    }

    local result = cargo.query( tables, fields, args )

    local tbl = mw.html.create('table')
	tbl:addClass('wikitable sortable filter-table')
	tbl:tag("th"):attr('style', 'width: 27%'):wikitext("Предмет"):done()
    tbl:tag("th"):attr('style', 'width: 25%'):wikitext("Параметры"):done()
    tbl:tag("th"):attr('style', 'width: 25%'):wikitext("Получение"):done()   
    tbl:done()

    for _, row in ipairs(result) do
        tr = tbl:tag("tr")
        tr:tag("td"):wikitext(item_icon.Main({args={row["Items.name"],""}}) .. string.format('<br><span style="font-size: 13px"><b>Уровень предмета: %s</b></span>', row["Items.item_level"])):done()

        local formatted_wikitext = {}
        for _, attrib in ipairs(attributes) do
            if row["Items." .. attrib.fields_cargo] then
                table.insert(formatted_wikitext, '+' .. row["Items." .. attrib.fields_cargo] .. ' [[' .. attrib.name[1] .. '|<span class="slate">' .. attrib.name[1] .. '</span>]]')
            end
        end
        tr:tag("td"):wikitext(table.concat(formatted_wikitext, '<br>')):done()
        tr:tag("td"):wikitext(item_acquisition.itemAcquisition({args={row["Items.name"], ""}})):done()
	end

	return tbl
end
return p
Advertisement