PDA

View Full Version : Document or tutorial explaining how Map interacts with <token> tags in DB?



SilentRuin
September 9th, 2020, 22:20
I need to see if I can create a token tied to a DB entry of my own but am not sure on the rules of interacting with the map based on current things that do this. PC and NPC tokens are only ones that come to mind currently.

Is there some sort of directions or rules on how this is done or do you just have to trial and error through the code?

Hoping for some sage advice here. Need to know how (or examples) of dropping a DB entry with a <token> definition onto the map and how it can be tied back to the DB entry. If I know that pretty sure I can do the rest of what I want to do.

Moon Wizard
September 10th, 2020, 00:33
The token information stored on a map in FG is only the graphic asset used, an ID value, and some other attributes (active, selected, etc.) There is no implicit connection to other database entries.

In the CoreRPG provided combat tracker (and the various ruleset implementations); when a token is dragged from CT to a map, the resulting token ID and map database node are saved into the CT record node. Then, whenever an action is performed against a token, the TokenManager code checks to see if there is a CT entry which has a matching image database path and token ID, and performs actions appropriately.

So, the result is that you need to do your "linking" of tokens and database records within your own scripts.

Regards,
JPG

SilentRuin
September 10th, 2020, 01:37
The token information stored on a map in FG is only the graphic asset used, an ID value, and some other attributes (active, selected, etc.) There is no implicit connection to other database entries.

In the CoreRPG provided combat tracker (and the various ruleset implementations); when a token is dragged from CT to a map, the resulting token ID and map database node are saved into the CT record node. Then, whenever an action is performed against a token, the TokenManager code checks to see if there is a CT entry which has a matching image database path and token ID, and performs actions appropriately.

So, the result is that you need to do your "linking" of tokens and database records within your own scripts.

Regards,
JPG

Thanks, I know what to do now.

SilentRuin
September 10th, 2020, 22:14
The token information stored on a map in FG is only the graphic asset used, an ID value, and some other attributes (active, selected, etc.) There is no implicit connection to other database entries.

In the CoreRPG provided combat tracker (and the various ruleset implementations); when a token is dragged from CT to a map, the resulting token ID and map database node are saved into the CT record node. Then, whenever an action is performed against a token, the TokenManager code checks to see if there is a CT entry which has a matching image database path and token ID, and performs actions appropriately.

So, the result is that you need to do your "linking" of tokens and database records within your own scripts.

Regards,
JPG

A new question has come up while I'm implementing this:

While doing the OnInit in the script for my xml I link the token using similarly named fields in my xml as shown below:



..
<hs name="tokenrefid" />
<hs name="tokenrefnode" />
<tokenfield name="token" >
...


Which is all good and fine. But when I look into supporting the Token.OnDoubleClick and other overrides I need, I now notice that TokenManager (which is pretty much solely hardcoded to deal with combat tracker stuff - which this is not) has overriden the global Token callbacks in a non register/unregister multiple item way. So my question is - as my token field will need its own version of these things - is Token something that applies toward everything and is locked up by the current hardcoded TokenManager? Am I going to have to overwrite Token Manager to allow for a more generic implementation or am I missing something and we all have our own version of the "Token" callbacks?

SilentRuin
September 11th, 2020, 18:10
A new question has come up while I'm implementing this:

While doing the OnInit in the script for my xml I link the token using similarly named fields in my xml as shown below:



..
<hs name="tokenrefid" />
<hs name="tokenrefnode" />
<tokenfield name="token" >
...


Which is all good and fine. But when I look into supporting the Token.OnDoubleClick and other overrides I need, I now notice that TokenManager (which is pretty much solely hardcoded to deal with combat tracker stuff - which this is not) has overriden the global Token callbacks in a non register/unregister multiple item way. So my question is - as my token field will need its own version of these things - is Token something that applies toward everything and is locked up by the current hardcoded TokenManager? Am I going to have to overwrite Token Manager to allow for a more generic implementation or am I missing something and we all have our own version of the "Token" callbacks?

Never mind - I assumed I had to save the original function before I overloaded it then call it after I established it was not one of my tokens - but that was always coming up nil for the original functions and even with my new stuff - the old stuff was still working. So I guess it just knows that the global "Token" is your personal scripts version. Anyway, figured it out.

SilentRuin
September 11th, 2020, 20:12
WOOT! Wile-E-Coyote... The core base of what I wanted to do all works!