PDA

View Full Version : Party Sheet Calculations



RTFallen
August 15th, 2014, 04:53
Code start: Line 302 in manage_ps2.lua


-- Award XP
for _,v in ipairs(aParty) do
local nAmount;
if k == #aParty then
nAmount = nFinalSplit;
else
nAmount = nAverageSplit;
end

if nAmount > 0 then
local nNewAmount = DB.getValue(v.node, "exp", 0) + nAmount;
DB.setValue(v.node, "exp", "number", nNewAmount);
end

v.given = nAmount;
end


I'm wondering were the k in the above function is coming from. I've looked over the manager_ps2.lua in the 3.5E ruleset, but I'm probably over looking something.

Resire

Trenloe
August 15th, 2014, 06:02
Code start: Line 302 in manage_ps2.lua


-- Award XP
for _,v in ipairs(aParty) do
local nAmount;
if k == #aParty then
nAmount = nFinalSplit;
else
nAmount = nAverageSplit;
end

if nAmount > 0 then
local nNewAmount = DB.getValue(v.node, "exp", 0) + nAmount;
DB.setValue(v.node, "exp", "number", nNewAmount);
end

v.given = nAmount;
end


I'm wondering were the k in the above function is coming from. I've looked over the manager_ps2.lua in the 3.5E ruleset, but I'm probably over looking something.

Resire
Looks like the k (key) is missing from the for _,v in pairs command - if a key is needed it is usually for k,v in pairs.

I think this may be legacy code from previously, where the last party member would sometimes get different XP than the others. Removing the k value will mean that the final split never gets awarded, only the average, so everyone gets the average split and there might be some left over.

RTFallen
August 15th, 2014, 06:30
Looks like the k (key) is missing from the for _,v in pairs command - if a key is needed it is usually for k,v in pairs.

I think this may be legacy code from previously, where the last party member would sometimes get different XP than the others. Removing the k value will mean that the final split never gets awarded, only the average, so everyone gets the average split and there might be some left over.

Thanks Trenloe.

Resire