PDA

View Full Version : [Bug Report] DB.getChildCount() documentation and implementation do different things



chillhelm
July 21st, 2023, 11:55
Hi,

I'm not sure if this is the right place to put this, but here at least other people running into it might see.

Let's say you have the following db.xml


<root>
<node>
<child>
<grandchild1 />
<grandchild2 />
</child>
</node>
</root>
According to https://www.fantasygrounds.com/refdoc/DB.xcp#getChildCount

local nodeNode = DB.findNode("node")
Debug.chat(DB.getChildCount(nodeNode,"child"))
should print "2" in the chat. It prints "1". It discords the 2nd parameter entirely (it counts the children of nodeNode). The confluence doc (https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644582/DB#getChildCount) is completely different, that one talks about deleting nodes for some reason.
Workaround is trivial:


local nodeNode = DB.findNode("node")
local nodeChild = DB.getChild(nodeNode,"child")
Debug.chat(DB.getChildCount(nodeChild))
Also the docs list the first parameter as optional? I'm not sure how that would work.

Moon Wizard
July 21st, 2023, 17:17
That example works for me. I've attached a simple example that builds a database node-child-grandchild hierarchy like yours on startup.


Regards,
JPG