Shaleych (обсуждение | вклад) мНет описания правки |
Shaleych (обсуждение | вклад) мНет описания правки |
||
Строка 21: | Строка 21: | ||
local itemORcost = {} |
local itemORcost = {} |
||
+ | |||
− | if frame.args['предмет'] ~= "" then |
||
− | itemORcost = 'Cost.item="' .. frame.args['предмет'] |
||
− | elseif frame.args['валюта'] ~= "" then |
||
− | itemORcost = 'cost HOLDS LIKE "%' .. frame.args['валюта'] .. '%"' |
||
− | end |
||
local cargoquery = { |
local cargoquery = { |
||
join = 'Cost.merchant = NPCs._pageName', |
join = 'Cost.merchant = NPCs._pageName', |
||
− | where= |
+ | where='Cost.item="' .. frame.args['предмет'], |
groupBy = "Cost._pageID" , |
groupBy = "Cost._pageID" , |
||
orderBy = args.orderby} |
orderBy = args.orderby} |
Версия от 13:30, 22 октября 2019
Для документации этого модуля может быть создана страница Модуль:Vendor list/doc
local itemIcon = require('Модуль:Item_icon')
local p = {}
local cargo = mw.ext.cargo
function p.Main( frame )
local args = frame.args
local fieldstable = {
"Cost.merchant",
"Cost.item",
"Cost.quality",
"Cost.quantity",
"Cost.cost__full",
"Cost._pageID",
"NPCs._pageName",
"NPCs.zone",
}
local tables = 'Cost, NPCs'
local fields = table.concat(fieldstable,",")
local itemORcost = {}
local cargoquery = {
join = 'Cost.merchant = NPCs._pageName',
where='Cost.item="' .. frame.args['предмет'],
groupBy = "Cost._pageID" ,
orderBy = args.orderby}
local result = mw.ext.cargo.query( tables, fields, cargoquery )
local r = result[1]
--Start the table
local tbl = mw.html.create('table')
tbl:addClass('wikitable')
if frame.args['валюта'] ~= "" then
tbl:tag("th"):wikitext("Предмет"):done()
end
tbl:tag("th"):wikitext("Торговец"):done()
tbl:tag("th"):wikitext("Область"):done()
tbl:tag("th"):wikitext("Стоимость"):done()
tbl:done()
for _,row in ipairs(result) do
tr = tbl:tag("tr")
if frame.args['валюта'] ~= "" then
tr:tag("td"):wikitext(itemIcon.Main({args={row["Cost.item"],""}})):done()
end
tr:tag("td"):wikitext('[[' .. row["Cost.merchant"] .. ']]'):done()
tr:tag("td"):wikitext('[[' .. row["NPCs.zone"] .. ']]'):done()
tr:tag("td"):wikitext(frame:expandTemplate{title = 'Валюта',args = {row["Cost.cost__full"]}}):done()
end
return tbl
end
return p