PDA

View Full Version : Got a weird CT one...



mixologee
October 7th, 2021, 22:51
So I'm having a weird thing going on with my CT in the ruleset I'm working on. The CT entry is getting created correctly for chars and npcs. When applying damage, the CT is being updated correctly. However the charsheet is not reflecting the update to the damage field (the NPC is being updated properly). On the flip side, when I edit that same field on the charsheet, the CT is being updated as expected. Essentially its working in one direction but not the other. Anyone seen this behavior before or have an idea on where I should dig deeper? Willing to upload any additional data/code needed. Below is my data for the ct_entry object:



<?xml version="1.0" encoding="ISO-8859-1"?>

<root>
<windowclass merge="join" name="ct_entry">
<placement>
<size width="450" height="45"/>
</placement>
<script> function onInit()
super.onInit();
linkNewPCFields();
end
function linkNewPCFields()
local nodeChar = link.getTargetDatabaseNode();
if nodeChar then
hp.setLink(nodeChar.createChild("hp", "number"), true);
dmg.setLink(nodeChar.createChild("dmg", "number"), true);
stamina.setLink(nodeChar.createChild("stamina", "number"), true);
end
end </script>
<sheetdata>
<genericcontrol name="leftcontrol" insertbefore="targetingicon">
<bounds>5,5,20,20</bounds>
</genericcontrol>
<link_ctentry merge="join" name="link" insertbefore="activeeffects">
<bounds>425,5,20,20</bounds>
</link_ctentry>
<genericcontrol name="rightanchor">
<bounds>400,5,20,20</bounds>
</genericcontrol>

<string_ctname_nonid merge="join" name="nonid_name" insertbefore="targetingicon">
<bounds>55,10,100,20</bounds>
<lineoffset default="on">2</lineoffset>
</string_ctname_nonid>

<number_ctentry_initresult merge="join" name="initresult">
<frame>
<name>buttonup</name>
<offset>5,2,5,1</offset>
</frame>
<bounds>175,7,15,22</bounds>
<color>#FF000000</color>
<description textres="ct_entry_initresult_DescriptionText"/>
</number_ctentry_initresult>
<number_ct_crosslink name="hp">
<frame>
<name>border</name>
</frame>
<bounds>200,5,25,25</bounds>
<color>#FFFF0000</color>
<description textres="ct_entry_hp_DescriptionText"/>
</number_ct_crosslink>
<number_ct_crosslink name="dmg">
<frame>
<name>ct_wound</name>
<offset>5,2,5,1</offset>
</frame>
<bounds>235,7,15,22</bounds>
<description textres="ct_entry_dmg_DescriptionText"/>
</number_ct_crosslink>
<number_ct_crosslink name="stamina">
<frame>
<name>bonus</name>
<offset>5,2,5,1</offset>
</frame>
<bounds>265,7,15,22</bounds>
<color>#FFFFFFFF</color>
<description textres="ct_entry_stamina_DescriptionText"/>
<script> </script>
</number_ct_crosslink>
</sheetdata>
</windowclass>
</root>



Thanks in advance.

Moon Wizard
October 7th, 2021, 23:06
You should look at ct_entry.lua in 3.5E and 5E as well as the CT customizations.

Remember that when the CT database node is very first created, the window will be created and the onInit function will be called. However, if the CT entry is being created dynamically (for example, via drop on CT), the link value has not been set yet. So, you also need handle when the link changes.

Regards,
JPG

mixologee
October 8th, 2021, 00:40
Thanks, will look at that.

damned
October 8th, 2021, 01:11
<script> function onInit()
super.onInit();
linkNewPCFields();
end
function linkNewPCFields()
local nodeChar = link.getTargetDatabaseNode();
if nodeChar then
hp.setLink(nodeChar.createChild("hp", "number"), true);
dmg.setLink(nodeChar.createChild("dmg", "number"), true);
stamina.setLink(nodeChar.createChild("stamina", "number"), true);
end
end </script>

this is normally done in ct_entry.lua
id put it back there and retest

mixologee
October 8th, 2021, 12:53
Still having some issues so I'll go back through your RSW videos on the CT and see what I missed.

bmos
October 10th, 2021, 19:14
is setLink covered in the documentation somewhere?
I had no idea it existed.

Moon Wizard
October 10th, 2021, 23:57
No, it's just a specialized template function in a CT template for attempting to link a field to another database location. It's used in many rulesets to link CT fields to the PC sheet fields. It only works when the CT is open.

Regards,
JPG

mixologee
October 11th, 2021, 12:10
is setLink covered in the documentation somewhere?
I had no idea it existed.

In CoreRPG there is a template_ct.xml file in the ct folder. The template looks like this:



<template name="number_ct_crosslink">
<basicnumber>
<script file="common/scripts/number_crosslink.lua" />
</basicnumber>
</template>