PDA

View Full Version : DB.getValue()... impossible return value...



celestian
April 20th, 2020, 17:54
Okay... I am trying to get a value of a node "hitDice" and the return is "hitDice" not the value of the node.

if this:



local _, nodeNPC = ActorManager.getTypeAndNodeName(rSource);
Debug.console("manager_action_damage","getTable48HitDiceVsImmunity","nodeNPC",nodeNPC);


Runtime Notice: s'manager_action_damage' | s'getTable48HitDiceVsImmunity' | s'nodeNPC' | s'combattracker.list.id-00004'


..
<combattracker>
<public />
<list>
<public />
<id-00004>
...
<hitDice type="string">4+1</hitDice>
...




local sHitDiceString = DB.getValue(nodeNPC, "hitDice");
Debug.console("manager_action_damage","getTable48HitDiceVsImmunity","sHitDiceString",sHitDiceString);


How the heck can I get this:
Runtime Notice: s'manager_action_damage' | s'getTable48HitDiceVsImmunity' | s'sHitDiceString' | s'hitDice'

Trenloe
April 20th, 2020, 18:57
nodeNPC is a string, not a DB node.

Therefore, the second argument to DB.getValue is the default to return if the value from the first argument isn't valid. So, you're getting the default returned = "hitDice".

Info here: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGU/pages/4063529/DB#getValue

The second parameter is an optional subpath which is:

subpath (string) [optional]
If the first parameter has type databasenode, then this parameter specifies the relative data node identifier path from the specified node object.

Trenloe
April 20th, 2020, 19:00
To make it work, you could use:


DB.getValue(DB.getChild(nodeNPC, "hitDice"));

celestian
April 20th, 2020, 19:04
Okay, I figured it out. The value of nodeNPC from the getTypeAndNodeName() is a string, not a node... I actually had meant to use getTypeAndNode anyway...

That said, the second call that I tested DB.getValue(nodeNPC,"frequecy") returned a value... not "frequency". I tested it when I noticed hitDice wasn't working.

Strange happenings but for now im good.