PDA

View Full Version : Get Value from PC Skill List in CT



Mephisto
November 9th, 2021, 18:41
Hi there,
I didn‘t find any post directly explaining how to achieve this: I‘m working on a ruleset based on the 5E rules. On the PC sheet I have the 5E standard skill list. In the CT I want to add a control which needs to catch the skill ranks for a die roll.

I understand how I can get an attribute value via crosslink and setLink, but I‘m wondering how to do this if I don‘t know the DB location beforehand (like I do for attributes).

Any help or examples are highly welcome. :-)

Trenloe
November 9th, 2021, 18:58
Get the charsheet database entry for the PC record in the combat tracker. Then go to the skilllist node and iterate through each child checking the value of the child name field until you get to the skill you want to reference.

Something like this:

for _,v in pairs(DB.getChildren(nodePCCharsheet, "skilllist")) do
if DB.getValue(v, "name", "") == sSkill then
-- Do your coding here - v is the skill node
end
end


Where nodePCCharsheet is the charsheet node for the PC and sSkill is the name of the skill you want to match. v will be a database node that points to skill child data, for example:


<name type="string">Perception</name>
<prof type="number">1</prof>
<stat type="string">wisdom</stat>

Mephisto
November 9th, 2021, 19:07
You know that you are awesome, don‘t you? :-).