Neverwinter Wiki
мНет описания правки
мНет описания правки
(не показано 9 промежуточных версий этого же участника)
Строка 1: Строка 1:
  +
local itemIcon = require('Модуль:Item_icon')
 
local p = {}
 
local p = {}
  +
function p.main(frame)
+
function p.main( frame )
local result = mw.ext.cargo.query('Contains','name','quantity',{
 
  +
local cargo = mw.ext.cargo
where = string.format('contains_item = "%s"',frame.args[1]),
 
  +
tables = 'Contains'
limit = 999
 
  +
fields = '_pageName,name,contains_item,quantity'
})
 
local text = {}
+
local args = {
 
where='contains_item = "'..frame.args[1]..'"',
  +
orderBy = '_pageName',
  +
}
 
local result = cargo.query( tables, fields, args )
  +
local r = result[1]
  +
local text = {}
 
for k, v in ipairs(result) do
 
for k, v in ipairs(result) do
  +
if v.quantity ~= "" then
text[k] = v.name
 
  +
text[k] = '<li>' .. itemIcon.Main({args={v._pageName,""}}) .. ' (' .. v.quantity .. ')</li>'
end
 
  +
else
return table.concat(text,',')
 
  +
text[k] = '<li>' .. itemIcon.Main({args={v._pageName,""}}) .. '</li>'
 
end
  +
end
 
return '<ul>'..table.concat(text,'\n')..'</ul>'
 
end
 
end
  +
 
return p
 
return p

Версия от 19:35, 28 ноября 2019

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

local itemIcon = require('Модуль:Item_icon')
local p = {}

function p.main( frame )
	local cargo = mw.ext.cargo
	tables = 'Contains'
    fields = '_pageName,name,contains_item,quantity'
    local args = {
    	where='contains_item = "'..frame.args[1]..'"',
    	orderBy = '_pageName',
    }
    local result = cargo.query( tables, fields, args )
    local r = result[1]
    local text = {}
	for k, v in ipairs(result) do
		if v.quantity ~= "" then
			text[k] = '<li>' .. itemIcon.Main({args={v._pageName,""}}) .. ' (' .. v.quantity .. ')</li>'
		else
			text[k] = '<li>' .. itemIcon.Main({args={v._pageName,""}}) .. '</li>'
		end
    end
    return '<ul>'..table.concat(text,'\n')..'</ul>'
end

return p