Module:WoodcutterPassiveList: Difference between revisions

switch to sorting after the SMW query
(all done apart from sorting it properly)
(switch to sorting after the SMW query)
 
Line 12:
-- returns only directly needed parameter needed for the row,
-- other parameters are determined by subqueries of chained pages
-- Woodcutter cannot sort by any parameter, as Branches use Profession B but Split Wood uses profession A
local query = {
'[[Variant of::~*Tree||~Split Wood for*]]',
'?Profession Level B = lvl',
'? #- = name',
'?Image #- = Image',
'?Activity JSON = activityJSON',
'?Activity coins = coins',
-- 'sort = Profession Level B',
'limit = 500'
}
Line 77 ⟶ 76:
end
-- sort the results by recipe level
table.sort(resultsScreened, function(item1, item2)
local lvl1 = item1.lvl
local lvl2 = item2.lvl
if (lvl1 == nil) ~= (lvl2 == nil) then --one of two are empty
return lvl2 == nil -- true if lvl2 is nil but not lvl1, false if lvl1 is nil but not lvl2
end
if lvl1 == nil then
return false -- Both empty, equivalent
end
return lvl1 < lvl2 -- normal comparison
end)
 
return resultsScreened
 
10,026

edits