12,808
edits
Falterfire (talk | contribs) (Changed sorting for modifier tables) |
(getModifierTable: Add option to force modifier magnitude sorting) |
||
Line 197: | Line 197: | ||
end | end | ||
function p._getModifierTable(modifiers, skill, columnName, getOpposites, displayOtherMods, maxOtherMods) | function p._getModifierTable(modifiers, skill, columnName, getOpposites, displayOtherMods, maxOtherMods, forceMagnitudeSort) | ||
local modifierNames = {} | local modifierNames = {} | ||
if type(modifiers) == 'string' then | if type(modifiers) == 'string' then | ||
Line 449: | Line 449: | ||
--Otherwise sort alphabetically by type, then name | --Otherwise sort alphabetically by type, then name | ||
table.sort(tableArray, function(a, b) | table.sort(tableArray, function(a, b) | ||
if modifierCount == 1 and a.val ~= b.val then | if (modifierCount == 1 or forceMagnitudeSort) and a.val ~= b.val then | ||
return a.val > b.val | return a.val > b.val | ||
elseif a.typeText ~= b.typeText then | elseif a.typeText ~= b.typeText then | ||
Line 477: | Line 477: | ||
local displayOtherMods = frame.args ~= nil and frame.args.displayOtherMods or frame.displayOtherMods | local displayOtherMods = frame.args ~= nil and frame.args.displayOtherMods or frame.displayOtherMods | ||
local maxOtherMods = frame.args ~= nil and tonumber(frame.args.maxOtherMods) or 5 | local maxOtherMods = frame.args ~= nil and tonumber(frame.args.maxOtherMods) or 5 | ||
local forceMagnitudeSort = frame.args ~= nil and string.upper(tostring(frame.args.forceMagnitudeSort)) == 'TRUE' or false | |||
if Shared.contains(modifier, ',') then | if Shared.contains(modifier, ',') then | ||
Line 494: | Line 495: | ||
end | end | ||
return p._getModifierTable(modifier, skill, columnName, getOpposites, displayOtherMods, maxOtherMods) | return p._getModifierTable(modifier, skill, columnName, getOpposites, displayOtherMods, maxOtherMods, forceMagnitudeSort) | ||
end | end | ||