PDA

View Full Version : [Programming]Rigging PC stats to Combat Tracker?



pr6i6e6st
August 28th, 2019, 00:26
I feel quite stumped here. I've got the NPC's health working fine on the combat tracker of my AlienRPG ruleset I've been working on here Link (https://www.fantasygrounds.com/forums/showthread.php?50544-WIP-Alien-RPG-extension&p=449557#post449557), but I can't seem to get it to do the same for the PC's. I looked at the D&D 5e ruleset, and the number on the combat tracker calls a function on the character sheet. For some reason, I fail to achieve a similar result.

I looked for extensions for CoreRPG that I might be able to use as an example or template, but supposedly the one which existed has been merged with CoreRPG? I can't seem to find that option either.

Where are the best places to look for examples to program this? which is the most simple method which still links the combat tracker number to the PC number?

thanks again for any advice and such, you guys have been awesome helping me thus far.

damned
August 28th, 2019, 01:49
You can look at MoreCore and see how that is done.
There are several places that you need to add code for keeping CT and PCs in Sync.
NPCs are different because they are actually LIVING in the CT so changes there are the only place the data is stored.
PCs need to sync from charsheet to CT and from CT to charsheet.

celestian
August 28th, 2019, 01:59
I think it's built into CoreRPG but look for crosslink.



<number_ct_crosslink name="hptotal" />


Something like that.

damned
August 28th, 2019, 02:20
number_ct_crosslink is definitely the main piece of the puzzle.

pr6i6e6st
August 28th, 2019, 04:55
number_ct_crosslink is definitely the main piece of the puzzle.

man! i went rooting around your code, compared it to the CoreRPG code, and eventually worked it out based on what you and celestian suggested. it now displays the amount properly! whoo! i've just uploaded it as this will be the last i do to it for at least a day or so. next thing i need to do is make it so i can do on the combat tracker to their health as i can do to their character sheet.

thank you both!

GEONE
July 31st, 2021, 20:54
Sorry about reviving an old thread, but could someone be more specific about this?
I've figured out that I need to use a number_ct_crosslink in the xml, and then in the ct_entry.lua add [value].setLink(...) to the value. But that's as far as I could figure out.

I assume I'm still missing a step because it's not syncing the value between the ct and the player sheet. Could someone help?

Here's what I have:

record_char_main.xml


...
<number_dropadd name="testvalue" source="test.value">
<anchored to="temphp" position="righthigh" offset="15,0" width="40" height="30" />
<font>reference-b-large</font>
</number_dropadd>
...


ct_host.xml


...
<number_ct_crosslink name="testctvalue" merge="replace">
<anchored to="initresult" width="24" height="20">
<top />
<right anchor="left" relation="relative" offset="-10" />
</anchored>
</number_ct_crosslink>
...


ct_entry.lua


...
function linkPCFields()
local nodeChar = link.getTargetDatabaseNode();
if nodeChar then
...
testctvalue.setLink(nodeChar.createChild("test.value", "number"));
end
end
...

superteddy57
July 31st, 2021, 21:06
Just helpful advice all around, throw debugs into the scripts and see if it's pulling the right information. This helps in hunting down where the breakdown is in the code. Also, check the campaign db.xml and see the values in the ct and the character sheet. As for the code presented it looks right at first glance. Try the above and see if shines a light on the breakdown.

GEONE
July 31st, 2021, 21:39
I've checked the campaign db.xml on a brand new campaign.

The character has the following stats tracked on them

<test>
<value type="number">7</value>
</test>

and the same character in the ct has the following stats tracked on them

<testctvalue type="number">0</testctvalue>

They don't act as linked in any way unfortunately. Is there something I've done wrong or some missing step? As far as I can see, this matches up exactly with how hp.wounds and wounds appear in the db.xml

superteddy57
July 31st, 2021, 21:47
What other values are you linking to the CT in that function? Are they linking correctly?

GEONE
July 31st, 2021, 21:53
the default 5E values as they appear in 5E.pak, and yes they appear to be linking just fine.

Here's the full function as it appears in ct_entry.lua. It's just the bottom one that isn't linking


function linkPCFields()
local nodeChar = link.getTargetDatabaseNode();
if nodeChar then
name.setLink(nodeChar.createChild("name", "string"), true);
senses.setLink(nodeChar.createChild("senses", "string"), true);

hptotal.setLink(nodeChar.createChild("hp.total", "number"));
hptemp.setLink(nodeChar.createChild("hp.temporary", "number"));
wounds.setLink(nodeChar.createChild("hp.wounds", "number"));
deathsavesuccess.setLink(nodeChar.createChild("hp.deathsavesuccess", "number"));
deathsavefail.setLink(nodeChar.createChild("hp.deathsavefail", "number"));

type.setLink(nodeChar.createChild("race", "string"));
size.setLink(nodeChar.createChild("size", "string"));
alignment.setLink(nodeChar.createChild("alignment", "string"));

strength.setLink(nodeChar.createChild("abilities.strength.score", "number"), true);
dexterity.setLink(nodeChar.createChild("abilities.dexterity.score", "number"), true);
constitution.setLink(nodeChar.createChild("abilities.constitution.score", "number"), true);
intelligence.setLink(nodeChar.createChild("abilities.intelligence.score", "number"), true);
wisdom.setLink(nodeChar.createChild("abilities.wisdom.score", "number"), true);
charisma.setLink(nodeChar.createChild("abilities.charisma.score", "number"), true);

init.setLink(nodeChar.createChild("initiative.total", "number"), true);
ac.setLink(nodeChar.createChild("defenses.ac.total", "number"), true);
speed.setLink(nodeChar.createChild("speed.total", "number"), true);

testctvalue.setLink(nodeChar.createChild("test.value", "number"));
end
end


The number box in the combat tracker does not have the chain icon in the corner like wounds, max hp, and temp hp do

superteddy57
August 1st, 2021, 06:54
If there is no chain link, then it's not being linked. May I ask why you have a merge="replace" for the testctvalue? I would try setting up a new template with the things you wish to change and then see if it links after that.

GEONE
August 1st, 2021, 19:49
Ah I figured it out. I wasn't referencing the new ct_entry.lua script in the xml file(s). I didn't realize ct_entry.lua wasn't global, derp.



<windowclass name="ct_entry" merge="join">
<script file="ct/scripts/ct_entry.lua" />
</windowclass>


Thanks for your help everyone!

Now the next question is how do I go about shrinking the string_ctname field in the combat tracker? It's now overlapping with my new number box and I can't seem to find where its size (or ending anchor? It has unique behaviour when the ct is scaled) is defined anywhere in the files.
48525

superteddy57
August 1st, 2021, 20:05
You could have it build the name last and have the right anchor parent be that last control

GEONE
August 1st, 2021, 21:14
I'm still not entirely sure how I'd go about that, could you give a code example?

superteddy57
August 1st, 2021, 22:27
Searching CoreRPG I found this anchoring for a template that should help you get started

<anchored width="20" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>

The key take away is the right tag and how it sets the border to the right anchor and has a left offset of -5 off the rightanchor