PDA

View Full Version : Party Sheet, Add all to Combat Tracker



celestian
April 4th, 2020, 04:52
Valeriangamer came up with (I thought) a great idea of adding a button to add all the entries in the Party Sheet to the combat tracker. It's a simple thing so I did it for the AD&D ruleset. Diablobob then asked if he could get the same code for his project... so I'm placing it here for him and anyone else that wants to use it. This wouldn't be a bad thing to add to the CoreRPG version tho it'd need some tweaks.

This is the XML entry, for the 2E and 5E ruleset that is in ps_main.xml.
The anchor/position will need to be tweaked depending on your locations. For me this is the lower left corner on the main page of the party sheet.



<buttoncontrol name="addtocombattracker">
<script>
function onButtonPress()
PartyManager2.addPartyToCombatTracker();
end
</script>
<anchored to="leftanchor" height="30" width="35">
<top />
<left anchor="right" relation="relative" offset="15" />
</anchored>
<frame name="fielddark" offset="10,2,10,3" />
<icon normal="button_ct" pressed="button_ct_down" />
<tooltip textres="ps_label_addtocombattracker_tooltip" />
<gmvisibleonly />
</buttoncontrol>


String entry needs to go where you keep them. <string name="ps_label_addtocombattracker_tooltip">Add party to combat tracker.</string>
This is the code that does the work. For 2E and 5E ruleset this goes into manager_ps2.lua (I put it at the bottom).


-- return array of all party sheet member nodes
function getPartySheetMembers()
local aParty = {};
for _,v in pairs(DB.getChildren("partysheet.partyinformation")) do
local sClass, sRecord = DB.getValue(v, "link");
if sClass == "charsheet" and sRecord then
local nodePC = DB.findNode(sRecord);
if nodePC then
table.insert(aParty, nodePC );
end
end
end

return aParty;
end

-- add all party sheet members to combat tracker if they are not there already.
function addPartyToCombatTracker()
local bAdded = false;
for _, nodePS in pairs(getPartySheetMembers()) do
if not CombatManager.getCTFromNode(nodePS) then
CombatManager.addPC(nodePS);
bAdded = true;
end
end
if bAdded then
Interface.openWindow("combattracker_host", "combattracker");
end
end


End result is clicking the button will add all entries in the Party Sheet to the CT if they do not already exist in the CT.

In 2E it looks like this.

https://i.imgur.com/ncXGBu6.png

JohnD
April 4th, 2020, 05:14
A 21 dex?!

damned
April 4th, 2020, 05:28
A 21 dex?!

Hes the GMs pet!

yeknom
April 4th, 2020, 05:31
I think it's an excellent idea.

celestian
April 4th, 2020, 05:40
A 21 dex?!

I was testing ranged attack bonuses ;)