PDA

View Full Version : CT - trying to understand how to link fields



Varsuuk
January 31st, 2021, 18:01
When I added a couple extra fields to my CT, I looked at other MoreCore extensions like the OSE (which has some similarities) and added a field using "number_ctlink" since so many fields did so in MoreCore.



<!-- Used in record_char_more.xml for Combat Tracker Linked items -->
<template name="number_ctlink">
<!-- basicnumber seems to be another template but I cant find it anywhere - maybe in CoreRPG? -->
<basicnumber>
<frame mergerule="replace" name="statbox" offset="3,3,3,2" />
<!-- Tooltip - for HoloGnome -->
<tooltip><text>Click to Edit. Double Click to Spend/Use.</text></tooltip>
<anchored position="belowleft" offset="0,12" width="28" height="16" />
</basicnumber>
</template>


I did this some time ago last year and I always have to refresh my memory (I've taken now to keeping a OneNote of info I've gathered) and was trying to see what I did to add it. So I did some prepping and noticed that there is a "number_ct_crosslink" supported by a script:



<template name="number_ct_crosslink">
<basicnumber>
<script file="common/scripts/number_crosslink.lua" />
</basicnumber>
</template>
<template name="number_ct">
<basicnumber>
<anchored width="25" height="20" />
<script file="common/scripts/number_crosslink.lua" />
</basicnumber>
</template>



Are these interchangeable?? Or did MC base itself maybe on an older CoreRPG and it was later changed to using this crosslink version?

Without reading code (mainly because it is about to be 1PM and wife is going to call us all for lunch and a show afterwards and we may need to head out to Toyota dealer as well - so it will be weighing on me in meanwhile ;) ) and going by names, I'd ASSUME... that ct_link goes from entity to CT and it is one way (I KNOW it is not from testing - and I guess this is because in the ct_entry for morecore it does things like: health.setLink(nodeChar.createChild("health", "number"), false) to link them up) and CoreRPG's number_ct_crosslink is 2-way linking.


So the basic question is:
1. Any good threads like Trenloe's link on Roll-handling for CT handling?
2. When I want a new field from a character sheet to be "linked" to the CT, what is best practice? Use the CoreRPG page "number_ct_crosslink" or do something else?
3. If no good answer for #1, any particular pieces of CoreRPG code I should read to understand or other ruleset to trace example use of them from to understand?


Off to eat and watch Wandavision ;)

Thanks all

Varsuuk
January 31st, 2021, 20:42
Welp, I found where I did my prior work starting with my own CombatManager helper class and continuing with the set links - I'll see if that work out properly.

Then after, I will look around for how number_ct_crosslink is used in other places.

damned
February 1st, 2021, 01:19
You need to use the crosslink templates.

Varsuuk
February 1st, 2021, 04:11
I think I got things all confused ;)

the "number_ctlink" uses are in "record_char_more" - I somehow thought that file had both that and crosslink versions.
It's ct_client.xml etc that uses "number_ct_crosslink" templates.

damned
February 1st, 2021, 04:14
There are 2 parts to this -
You have your _crosslink templates and you need the script in ct_entry.lua


function linkPCFields()
local nodeChar = link.getTargetDatabaseNode();
if nodeChar then
name.setLink(nodeChar.createChild("name", "string"), true);
health.setLink(nodeChar.createChild("health", "number"), false);
defence.setLink(nodeChar.createChild("defence", "number"), false);
fieldthree.setLink(nodeChar.createChild("wounds", "number"), false);
initresult.setLink(nodeChar.createChild("initresult", "number"));
atk.setLink(nodeChar.createChild("attacks", "string"), true);
four.setLink(nodeChar.createChild("four", "number"), false);
five.setLink(nodeChar.createChild("five", "number"), false);
end
end