PDA

View Full Version : A Question about combat tracker



bawsr
April 18th, 2017, 00:41
Is there a way to start with the lowest number in combat tracker first.

Count up rather than count down.


1 goes first, then 2, then 3 and so on. Just reverse the standard order in the combat tracker.

Moon Wizard
April 18th, 2017, 01:28
You would need to customize the combat tracker within the ruleset to sort ascending, instead of descending. (Unless the ruleset already works that way) It would require an extension to modify the tracker code for sorting.

Regards,
JPG

Trenloe
April 18th, 2017, 01:30
You'll have to define a custom sort function for the combat tracker - which uses the CombatManager package.

Look in CoreRPG -> Scripts -> manager_combat.lua The onSortCompare function is executed to order the entries in the combat tracker. There is the ability to define a custom sort function called fCustomSort to override the default sorting.

The custom sort function is set in the scripts\manager_combat2.lua script - with the CombatManager.setCustomSort(CombatManager.sortfunc Standard); command.

You could so something similar, by creating a custom sort function in manager_combat2.lua that reverses the init comparison. Something like this:


--
-- Please see the license.html file included with this distribution for
-- attribution and copyright information.
--

function onInit()
-- Changed custom sort function to use ascending function listed below.
CombatManager.setCustomSort(CombatManager.sortfunc Ascending);
CombatManager.setCustomCombatReset(resetInit);
end

--
-- ACTIONS
--

function resetInit()
for _, vChild in pairs(DB.getChildren(CombatManager.CT_LIST)) do
DB.setValue(vChild, "initresult", "number", 0);
end
end

-- New ascending function.
function sortfuncAscending(node1, node2)
local bHost = User.isHost();
local sOptCTSI = OptionsManager.getOption("CTSI");

local sFaction1 = DB.getValue(node1, "friendfoe", "");
local sFaction2 = DB.getValue(node2, "friendfoe", "");

local bShowInit1 = bHost or ((sOptCTSI == "friend") and (sFaction1 == "friend")) or (sOptCTSI == "on");
local bShowInit2 = bHost or ((sOptCTSI == "friend") and (sFaction2 == "friend")) or (sOptCTSI == "on");

if bShowInit1 ~= bShowInit2 then
if bShowInit1 then
return true;
elseif bShowInit2 then
return false;
end
else
if bShowInit1 then
local nValue1 = DB.getValue(node1, "initresult", 0);
local nValue2 = DB.getValue(node2, "initresult", 0);
if nValue1 ~= nValue2 then
-- This is the only change - reversed this comparison.
return nValue1 < nValue2;
end
else
if sFaction1 ~= sFaction2 then
if sFaction1 == "friend" then
return true;
elseif sFaction2 == "friend" then
return false;
end
end
end
end

local sValue1 = DB.getValue(node1, "name", "");
local sValue2 = DB.getValue(node2, "name", "");
if sValue1 ~= sValue2 then
return sValue1 < sValue2;
end

return node1.getNodeName() < node2.getNodeName();
end

bawsr
April 18th, 2017, 02:11
great thanks. I hadn't seen any rulesets that went ascending instead of descending. That looks doable.