PDA

View Full Version : CopyNode Issue Help



Houndy
May 20th, 2020, 11:18
Hello,

I have been struggling with this for a while now and it has been driving me nuts!

FGU
5E
My extension is loaded.

My code works so that a user can reset their actions form a saved copy in the database. In this scenario a player is resetting the actions for a spell.

I have a copy of an Actions node in my DB:



<original_actions>
<holder name="Houndy" owner="true" />
<id-00001>
<holder name="Houndy" owner="true" />
<onmissdamage type="string">half</onmissdamage>
<order type="number">1</order>
<savemagic type="number">1</savemagic>
<savetype type="string">dexterity</savetype>
<type type="string">cast</type>
</id-00001>
<id-00002>
<holder name="Houndy" owner="true" />
<damagelist>
<holder name="Houndy" owner="true" />
<id-00001>
<holder name="Houndy" owner="true" />
<dice type="dice">3d6</dice>
</id-00001>
</damagelist>
<order type="number">2</order>
<type type="string">damage</type>
</id-00002>
</original_actions>


I want to delete the actions childrens node and replace it with these.

so I do:


local nodeActions = powerNode.createChild("actions");
for _,v in pairs(nodeActions.getChildren()) do
v.delete();
end

DB.copyNode(originalActionsList, nodeActions);

The result in the database is as I would expect:


<actions>
<holder name="Houndy" owner="true" />
<id-00001>
<holder name="Houndy" owner="true" />
<onmissdamage type="string">half</onmissdamage>
<order type="number">1</order>
<savemagic type="number">1</savemagic>
<savetype type="string">dexterity</savetype>
<type type="string">cast</type>
</id-00001>
<id-00002>
<holder name="Houndy" owner="true" />
<damagelist>
<holder name="Houndy" owner="true" />
<id-00001>
<holder name="Houndy" owner="true" />
<dice type="dice">3d6</dice>
</id-00001>
</damagelist>
<order type="number">2</order>
<type type="string">damage</type>
</id-00002>
</actions>


For the DM the power appears as it should:

https://www.fantasygrounds.com/forums/attachment.php?attachmentid=35781&stc=1&d=1589969590

However, for the player it does not update the actions properly:

https://www.fantasygrounds.com/forums/attachment.php?attachmentid=35782&stc=1&d=1589969674

If I quit as the player and rejoin, it then shows as expected.

If I debug the node, it points to the correct path in the DB, but it seems the values of some of the children are not there.

It seems to me that for the player, the reference to the DB is not being updated. This particular causes an issue if the player then tried to change or manipulate the broken references, as it will then break for the DM also.

Edit: Everything works fine if it is the DM who is doing the restoring.
Edit: I also manually added a method so I could update the display of the actions, to see if it that was the issue, but that did not work. I think it must be to do with lists and the node reference or, communications between the player and DM.

Any help would be gratefully appreciated!

Thanks,

Houndy