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 |
'[[Variant of::~*Tree]]', |
||
'?Profession Level B = lvl', |
|||
'? #- = name', |
'? #- = name', |
||
'?Image #- = Image', |
'?Image #- = Image', |
||
⚫ | |||
'?Activity duration = duration', |
|||
'?Skill node name = product', |
|||
'?Activity JSON = activityJSON', |
'?Activity JSON = activityJSON', |
||
'sort = Profession Level B', |
|||
⚫ | |||
'limit = 500' |
'limit = 500' |
||
} |
} |
||
Line 54: | Line 57: | ||
-- iterate through products |
-- iterate through products |
||
for _, item in ipairs(results) do |
for _, item in ipairs(results) do |
||
-- if theres only one activity, wrap in table |
|||
if type(item.activityJSON)=='string' then |
|||
item.activityJSON = { item.activityJSON } |
|||
end |
|||
for j,json in ipairs(item.activityJSON) do |
for j,json in ipairs(item.activityJSON) do |
||
if string.find(json,'Branches') |
if string.find(json,'Branches') then |
||
local activityJSON = mw.text.jsonDecode(json) |
local activityJSON = mw.text.jsonDecode(json) |
||
item.XP = activityJSON.xp |
item.XP = activityJSON.xp |
||
item.lvl = activityJSON.level |
|||
item.duration = activityJSON.duration and tonumber(activityJSON.duration) |
item.duration = activityJSON.duration and tonumber(activityJSON.duration) |
||
item.product = activityJSON.output[1].name |
item.product = activityJSON.output[1].name |
||
Line 76: | Line 72: | ||
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 |
||
Line 98: | Line 81: | ||
-- iterate through products |
-- iterate through products |
||
for _, item in ipairs(results) do |
for _, item in ipairs(results) do |
||
item.givesCoins = string.find(item.product,'Split') |
|||
-- profit from selling the items |
-- profit from selling the items |
||
Line 140: | Line 121: | ||
:tag('th') |
:tag('th') |
||
:attr{ colspan = '2' } |
:attr{ colspan = '2' } |
||
:wikitext(' |
:wikitext('Tree') |
||
:done() |
:done() |
||
:tag('th') |
:tag('th') |
||
Line 192: | Line 173: | ||
-- products (coins or items) |
-- products (coins or items) |
||
: |
:tag('td') |
||
⚫ | |||
:IF(item.coins) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
:css{ ['border-right'] = '0', ['text-align'] = 'right' } |
|||
⚫ | |||
⚫ | |||
⚫ | |||
:attr{ ['data-sort-value'] = item.product } |
|||
⚫ | |||
:wikitext(item.coins) |
|||
⚫ | |||
:done() |
|||
⚫ | |||
:ELSE() |
|||
⚫ | |||
:node(unknown_value_cell) |
|||
:tag('td') |
|||
: |
:addClass('plinkt-link no-border') |
||
⚫ | |||
⚫ | |||
⚫ | |||
:addClass('plinkt-link no-border') |
|||
:wikitext('[[File:Copper coin.png|20x20px]]') |
|||
⚫ | |||
:tag('td') |
|||
:addClass('plinkt-link no-border') |
|||
:wikitext('Coins') |
|||
⚫ | |||
:ELSE() |
|||
:tag('td') |
|||
⚫ | |||
:addClass('plinkt-link no-border') |
|||
⚫ | |||
⚫ | |||
⚫ | |||
:tag('td') |
|||
⚫ | |||
:addClass('plinkt-link no-border') |
|||
⚫ | |||
:done() |
|||
:tag('td') |
|||
:addClass('plinkt-link no-border') |
|||
⚫ | |||
:done() |
|||
:END() |
|||
-- products per hour (items) |
-- products per hour (items) |
||
: |
:tag('td') |
||
⚫ | |||
:tag('td') |
|||
⚫ | |||
:addClass('table-na') |
|||
:done() |
|||
:done() |
|||
:ELSE() |
|||
:tag('td') |
|||
:css{ ['text-align'] = 'right' } |
|||
⚫ | |||
:done() |
|||
:END() |
|||
-- profit per hour (coins) |
-- profit per hour (coins) |