Neverwinter Wiki
мНет описания правки
мНет описания правки
(не показано 7 промежуточных версий этого же участника)
Строка 1: Строка 1:
 
local itemIcon = require('Модуль:Item_icon')
 
local itemIcon = require('Модуль:Item_icon')
 
 
local p = {}
 
local p = {}
   
function p.Main( frame )
+
function p.main( frame )
local args = frame.args
+
local cargo = mw.ext.cargo
  +
tables = 'Contains'
local fieldstable = {
 
"_pageName",
+
fields = '_pageName,name,contains_item,quantity'
"name",
+
local args = {
 
where='contains_item = "'..frame.args[1]..'"',
"contains_item",
 
  +
orderBy = '_pageName',
"quantity",
 
}
+
}
local tables = 'Contains'
+
local result = cargo.query( tables, fields, args )
local fields = table.concat(fieldstable,",")
+
local r = result[1]
 
local text = {}
local cargoquery = { where='contains_item = "'..frame.args[1]..'"', groupBy = "_pageName" , orderBy = args.orderby}
 
 
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
   
local result = mw.ext.cargo.query( tables, fields, cargoquery )
 
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
 
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