Bureaucrats, editor, Interface administrators, Administrators (Semantic MediaWiki), Curators (Semantic MediaWiki), Editors (Semantic MediaWiki), Administrators
47,327
edits
(Created page with "local p = {} local geprice = require('Module:Exchange')._price local commas = require('Module:Addcommas') local skillpic = require('Module:SCP')._main local yesno = require('Module:Yesno') local lang = mw.getContentLanguage() local trim = mw.text.trim -- Sorting function for two item objects, first by name, then by sub-text function sortItemsByNameSubtext(item1, item2) if (item1.output.name < item2.output.name) then return true elseif (item1.output.name > item2.out...") |
No edit summary |
||
Line 7:
local lang = mw.getContentLanguage()
local trim = mw.text.trim
local split = mw.text.split
function p.main(frame)
Line 25 ⟶ 15:
function p._main(args)
local materials = {}
if (args == nil) then
table.insert(materials, mw.title.getCurrentTitle().text)
else
local
for type in string.gmatch(args[1], '([^,]+)') do
table.insert(splitMultiple, type)
end
for _, v in ipairs(splitMultiple) do
mw.log(v)
table.insert(materials, trim(v))
end
end
local materialsLowered = {}
for index, material in pairs(materials) do
materialsLowered[material:lower()] = true
end
Line 50 ⟶ 42:
limit = args.limit or 500,
}
local t1 = os.clock()
local
local t2 = os.clock()
if not
return 'Failed to find products with those materials - ensure they are spelled correctly. (ERR: no results from SMW)[[Category:Empty drop lists]]'
end
mw.log(string.format('SMW: entries %d, time elapsed: %.3f ms.', #smwdata, (t2 - t1) * 1000))
-- Post-process
data = {}
for _, e in ipairs(smwdata) do
if type(e['json']) == 'string' then
local j = mw.text.jsonDecode(e['json'])
elseif type(e['json']) ==
end
end
end
smwdata = nil
-- Render page
local t = mw.html.create('table')
t:addClass('wikitable sortable products-list align-center-1 align-right-3 align-right-4')
local ttlrow = t:tag('tr')
:tag('th')
:attr('colspan', '2')
:wikitext('Item')
:done()
:tag('th')
:wikitext('Members')
:done()
:tag('th')
:attr('data-sort-type', 'number')
:wikitext('Skills')
:done()
:tag('th')
:attr('data-sort-type', 'number')
:wikitext('XP')
:done()
:tag('th')
:wikitext('Materials')
:done()
local rows = 0
Line 111 ⟶ 94:
for _, item in ipairs(data) do
local _found = false
for _,mat_info in ipairs(item.materials) do
if materialsLowered[mat_info.name:lower()] == true then
_found = true
break
end
end
if _found then
local
if (tonumber(item.output.quantity) or 1) > 1 then
else
end
if item.output.subtxt then
end
local
members = item.members
if
elseif
end
local experience_cell = mw.html.create('td')
local experience_ul = experience_cell:tag('ul')
experience_ul:addClass('skills-list')
:css({
['list-style-type'] = 'none',
['list-style-image'] = 'none',
margin = 0
})
local skills_cell = mw.html.create('td')
local skills_ul = skills_cell:tag('ul')
skills_ul:addClass('skills-list')
:css({
['list-style-type'] = 'none',
['list-style-image'] = 'none',
margin = 0
})
if #item.skills == 0 then
local skill_li = skills_ul:tag('li')
local experience_li = experience_ul:tag('li')
experience_cell:addClass('table-na')
experience_li:wikitext(string.format('None'))
skills_cell:addClass('table-na
skill_li:wikitext(string.format('None'))
else
Line 164 ⟶ 147:
local skill_li = skills_ul:tag('li')
local experience_li = experience_ul:tag('li')
local stripped_experience =
skill_li:attr('data-sort-value', index == 1 and v.level or ''):wikitext(skillpic(lang:ucfirst(v.name), v.level))
experience_li:attr('data-sort-value', index == 1 and v.experience or ''):wikitext(tonumber(stripped_experience) ~= nil and skillpic(lang:ucfirst(v.name), v.experience) or v.experience)
end
end
local mats_ul = mw.html.create('ul')
mats_ul:addClass('products-materials')
:css({
['list-style-image'] = 'none',
margin = 0
})
local materialsortvalue = nil
for _, mat_info in ipairs(item.materials) do
local mat_li = mats_ul:tag('li')
local qty =
local
for _,mat in ipairs(materialsLowered) do
mat_li:addClass('production-selected')
end
end
if materialsLowered[mat_info.name:lower()] == true then
mat_li:addClass('production-selected')
end
if
end
mat_li:wikitext(string.format('%s × [[%s]]', commas._add(qty),
end
Line 207 ⟶ 185:
:tag('td')
:attr('data-sort-value', item.product)
:wikitext(
:done()
:tag('td')
:wikitext(
:node(skills_cell)
:node(experience_cell)
:tag('td')
:attr('data-sort-value',
:node(mats_ul)
:done()
|