PDA

View Full Version : Undocumented Feature



Foen
April 18th, 2008, 07:31
I am trying to manipulate token controls, and load their contents from a database node. The documentation mentions a method populateFromImageNode but there isn't much information to understand how this works.

In the default ruleset, this method is used in the combat tracker, along with an undocumented property of tokens:



entry.tokenrefnode = token.ref.getContainerNode().getNodeName();
entry.tokenrefid = token.ref.getId();


Does anyone know what token.ref is? Has anyone used populateFromImageNode?

Help!

Stuart

Goblin-King
April 18th, 2008, 08:32
The variable token.ref is used to keep track of the token instance corresponding to the combat tracker entry on a map it is used on. E.g. if you change the name field on the tracker, the method token.ref.setName is called in response.

The populateFromImageNode function is there to allow you to get a tokeninstance value from an image containing tokens. Tokens placed on an image are contained in the image node, and you can't directly access them simply using databasenode.getChild, for example. This function exists because you can't store tokeninstance references between sessions. However, you can store the name of the image node (string) and the tokeninstance identifier (number), that you get using getId.

I'm not sure if all this relevant for what you're doing, however. You describe your need as moving data between the data base and a token control. Using tokencontrol.setPrototype and databasenode.getValue should suffice for this (provided the node is of type "token").

Foen
April 18th, 2008, 13:17
Thanks Tero, I see what the code is doing now, and I also see that I'm barking up the wrong tree!

A token in the campaign database (for example in an NPC record) points to a physical image path and I have been able to point tokens at paths in the images directory by editing the db.xml. What I was trying to do was to allow the user to drag an image shortcut (say, to a handsome portrait of their NPC) and drop it onto a token control, and to point the token control to the image file path.

Token controls have a facility to set their file paths directly (using setPrototype) but I haven't been able to find how to retrieve the path name from an image control or an image-type database node. I thought populateFromImageNode might do this, but I was wrong.

There is little documentation about image-type database nodes (although the underlying db.xml has a bitmap element, which holds exactly the information I'm after), is there a way to for me to access this or achieve the same effect?

Many thanks for your help

Stuart

Foen
April 22nd, 2008, 06:18
Hi Tero, any update on this please? I'm trying to retrieve an image-node file path from the database (it is in there, I can see it as a <bitmap> element in the xml).

Cheers

Stuart