Module:Uses skill list: Difference between revisions

no edit summary
(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 24:
 
function p._main(args)
local materialsskills = {}
local materials_loweredskills_lowered = {}
if (args == nil) then
table.insert(materialsskills, mw.title.getCurrentTitle().text)
else
local i = 1
Line 35:
local arg = trim(args[i])
table.insert(materialsskills, arg)
materials_loweredskills_lowered[arg:lower()] = true
i = i + 1
Line 44:
-- Fetch data
local query = {
'[[Uses skill::'..table.concat(materialsskills, '||')..']]',
'[[Production JSON::+]]',
'?=#-',
Line 110:
-- Render rows
for _, item in ipairs(data) do
local _foundskill_match = false
for _, matskill_info in ipairs(materials_lowereditem.skills) do
 
for _, mat_info in ipairs(itemif skills_lowered[skill_info.materialsname:lower()] dothen
_foundskill_match = true
if materials_lowered[mat_info.name:lower()] then
_found = true
break
end
end
 
if _foundskill_match then
local name_str
 
Line 184 ⟶ 183:
local qty = mat_info.quantity:gsub('%-', '–')
local mat_name = mat_info.name
 
for _, mat in ipairs(materials_lowered) do
if mat_name:lower() == mat then
mat_li:addClass('production-selected')
end
end
 
if materials_lowered[mat_name:lower()] then
mat_li:addClass('production-selected')
end
if mat_sort_val == nil then
Line 223 ⟶ 212:
 
if rows == 0 then
return 'Failed to find products with those materialsskills - ensure they are spelled correctly. (ERR: no matsskills found in results)[[Category:Empty drop lists]]'
end