Shaleych (обсуждение | вклад) мНет описания правки |
Shaleych (обсуждение | вклад) мНет описания правки |
||
(не показано 6 промежуточных версий этого же участника) | |||
Строка 13: | Строка 13: | ||
local result = cargo.query( tables, fields, args ) |
local result = cargo.query( tables, fields, args ) |
||
local r = result[1] |
local r = result[1] |
||
⚫ | |||
− | local text = {} |
||
+ | local tbl = mw.html.create('table') |
||
⚫ | |||
+ | tbl:addClass('wikitable sortable filter-table-mount jquery-tablesorter') |
||
⚫ | |||
+ | --:attr('style', 'width: 15%') |
||
− | text[k] = '<li>' .. Drops._pageName .. NPCs.zone .. ' (' .. v["Drops.quantity"] .. ')</li>' |
||
+ | tbl:tag("th"):wikitext("Монстр"):done() |
||
− | else |
||
+ | tbl:tag("th"):wikitext("Область"):done() |
||
− | text[k] = '<li>' .. Drops._pageName .. NPCs.zone .. '</li>' |
||
⚫ | |||
+ | tbl:tag("th"):wikitext("Количество"):done() |
||
+ | end |
||
+ | tbl:done() |
||
+ | --Construct the rows in the table |
||
⚫ | |||
+ | tr = tbl:tag("tr") |
||
+ | tr:tag("td"):wikitext('[[' .. row["Drops._pageName"] .. ']]'):done() |
||
+ | tr:tag("td"):wikitext('[[' .. row["NPCs.zone"] .. ']]'):done() |
||
+ | if row["Drops.quantity"] then |
||
+ | tr:tag("td"):wikitext(Mount.Main({args={row["Drops.quantity"],""}})):done() |
||
+ | end |
||
end |
end |
||
+ | tr = tbl:tag("tr") |
||
⚫ | |||
+ | return tbl |
||
− | return '<ul>'..table.concat(text,'\n')..'</ul>' |
||
end |
end |
||
Текущая версия от 15:28, 7 мая 2023
Для документации этого модуля может быть создана страница Модуль:Dropped by/doc
local itemIcon = require('Модуль:Item_icon')
local p = {}
function p.main( frame )
local cargo = mw.ext.cargo
tables = 'Drops, NPCs'
fields = 'Drops._pageName,Drops.name,Drops.drops_item,Drops.quantity,NPCs.zone'
local args = {
join = 'Drops._pageName = NPCs._pageName',
where = 'Drops.drops_item = "'..frame.args[1]..'"',
orderBy = 'Drops._pageName',
}
local result = cargo.query( tables, fields, args )
local r = result[1]
local tbl = mw.html.create('table')
tbl:addClass('wikitable sortable filter-table-mount jquery-tablesorter')
--:attr('style', 'width: 15%')
tbl:tag("th"):wikitext("Монстр"):done()
tbl:tag("th"):wikitext("Область"):done()
if r["Drops.quantity"] ~= "" then
tbl:tag("th"):wikitext("Количество"):done()
end
tbl:done()
--Construct the rows in the table
for _,row in ipairs(result) do
tr = tbl:tag("tr")
tr:tag("td"):wikitext('[[' .. row["Drops._pageName"] .. ']]'):done()
tr:tag("td"):wikitext('[[' .. row["NPCs.zone"] .. ']]'):done()
if row["Drops.quantity"] then
tr:tag("td"):wikitext(Mount.Main({args={row["Drops.quantity"],""}})):done()
end
end
tr = tbl:tag("tr")
return tbl
end
return p