Editing Module:WoodcutterPassiveList
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 12: | Line 12: | ||
-- returns only directly needed parameter needed for the row, |
-- returns only directly needed parameter needed for the row, |
||
-- other parameters are determined by subqueries of chained pages |
-- 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 = { |
local query = { |
||
'[[Variant of::~*Tree||~Split Wood for*]]', |
'[[Variant of::~*Tree||~Split Wood for*]]', |
||
'?Profession Level B = lvl', |
|||
'? #- = name', |
'? #- = name', |
||
'?Image #- = Image', |
'?Image #- = Image', |
||
'?Activity JSON = activityJSON', |
'?Activity JSON = activityJSON', |
||
'?Activity coins = coins', |
'?Activity coins = coins', |
||
-- 'sort = Profession Level B', |
|||
'limit = 500' |
'limit = 500' |
||
} |
} |
||
Line 76: | Line 77: | ||
end |
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 |
return resultsScreened |
||