Neverwinter Wiki
Advertisement
Версия для печати больше не поддерживается и может содержать ошибки обработки. Обновите закладки браузера и используйте вместо этого функцию печати браузера по умолчанию.

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

local item_icon = require('Модуль:Item_icon')

local p = {}

local professions = {
    ['алхимия'] = '[[Файл:Crafting_Profession_Alchemy.png|20px|ссылка=Алхимия]]',
    ['ковка доспехов'] = '[[Файл:Crafting_Profession_Hvyarmoring.png|20px|ссылка=Ковка доспехов]]',
    ['кройка и шитье'] = '[[Файл:Crafting_Profession_Tailoring.png|20px|ссылка=Кройка и шитье]]',
    ['кузнечное дело'] = '[[Файл:Crafting_Profession_Weaponsmithing.png|20px|ссылка=Кузнечное дело]]',
    ['нанесение узоров'] = '[[Файл:Crafting_Profession_Artificing.png|20px|ссылка=Нанесение узоров]]',
    ['обработка кожи'] = '[[Файл:Crafting_Profession_Leatherworking.png|20px|ссылка=Обработка кожи]]',
    ['ювелирное дело']  = '[[Файл:Crafting_Profession_Jewelcrafting.png|20px|ссылка=Ювелирное дело]]'
}

function p.Main( frame )
    local cargo = mw.ext.cargo
    tables = 'Recipes'
    fields = '_pageName, name, source,quantity,professions,level,material1_quantity,material1_item,material2_quantity,material2_item,material3_quantity,material3_item,material4_quantity,material4_item,material5_quantity,material5_item'
    local args = {
        where   = 'material1_item = "' .. frame.args[1] .. '" OR material2_item = "' .. frame.args[1] .. '" OR material3_item = "' .. frame.args[1] .. '" OR material4_item = "' .. frame.args[1] .. '" OR material5_item = "' .. frame.args[1] .. '"',
        orderBy = 'level, _pageName',
    }
    local result = cargo.query( tables, fields, args )
    local r = result[1]

        --Start the table
	local tbl = mw.html.create('table')

	tbl:addClass('wikitable')
		tbl:tag("th"):attr('style', 'width:25em'):wikitext("Предмет"):done()
		tbl:tag("th"):attr('style', 'width: 100px'):wikitext("Профессия(и)"):done()
        tbl:tag("th"):attr('style', 'width: 40px'):wikitext("Уровень"):done()
        tbl:tag("th"):attr('style', 'width: 140px'):wikitext("Результирующее кол-во"):done()
        tbl:tag("th"):attr('style', 'min-width:25em'):wikitext("Материалы"):done()
	tbl:done()
         --Construct the rows in the table
	for _, row in ipairs(result) do
		tr = tbl:tag("tr"):attr('class', 'simpleCraftCalcRecipeBase')

        
        local source = {}
		if row.source then
			for name in mw.text.gsplit(row.source, ",%s*") do
				table.insert(source, item_icon.Main({args={name, ""}}))
			end
        end

        tr:tag("td"):wikitext((row.name and item_icon.Main({args={row.name, ""}}) or '') .. (row.source and '<br><small>(Изучается из: ' .. table.concat(source, ',<br>') ..')</small>' or '')):done()

		local text  = {}
        for i in mw.text.gsplit(row.professions, ",%s*") do
            table.insert(text, professions[mw.ustring.lower(i)])
        end
        tr:tag("td"):attr('style', 'text-align: center'):wikitext(table.concat(text,' ')):done()
        tr:tag("td"):attr('style', 'text-align: center'):wikitext(row.level):done()

        local resulting_craft_count = tonumber(row.quantity) > 0 and tonumber(row.quantity) or 1
            
		tr:tag("td"):wikitext('<span class="simpleCraftCalcResultCount" data-initial-count="'.. resulting_craft_count  .. '">' .. resulting_craft_count  .. '</span>'):done()
		
		local ingredients = {}
        for i = 1, 5 do
            local item = row['material'..i..'_item']
            local quantity = row['material'..i..'_quantity']
            if item ~= nil then
                table.insert(ingredients, '<div><span class="simpleCraftCalcIngredientCount" style="padding-right: 3px;" data-initial-count="'.. quantity .. '">' .. quantity .. '</span> ' .. item_icon.Main({args={item, ""}}) .. '</div>')
            end
        end
        tr:tag("td"):wikitext(table.concat(ingredients, '\n'))
        
		end
	return tbl
end
return p
Advertisement