PDA

View Full Version : Locking tokens into a "tokenfield"



Visvalor
December 16th, 2009, 03:06
OK! I emailed someone about this earlier but call me impatient I'm eager to learn ;P

Anyways I was looking through the combat tracker trying to figure out how they locked the token in place as I want to do something like that on my sheet with tokens + variables attached. First thing first to prepare for said code I'd imagine would be make a spot for it and make a control to lock the tokens in place.

I found <tokenfield> but I can't find where it is defined in either charsheet_templates or common_templates and when I just copy a tokenfield into my sheet it doesn't do anything with tokens.

Where do I look (or what is) the script to take a token that is dragged to a control and then lock it in place so it doesn't move.

Also instead of making a copy I need to make sure this token is removed when it is removed =P

Also need variables to go with it!

But first. How do I get it to stay in place?

Thanks!

Moon Wizard
December 16th, 2009, 17:32
Can you explain what you mean by "locked in place"?

The tokencontrol and tokenfield controls are places where a token can be dropped onto, and dragged from. If it's a tokenfield control, then the token information will also be saved in the database. They are merely data fields, just like stringfields or numberfields, just for tokens.

Regards,
JPG

Visvalor
December 16th, 2009, 18:47
Tokencontrol I didn't try I didn't find "token" inside either template files so I didn't know I had it :P

Tokenfield when I tried to drag a token into it wouldn't grab the token it just disappears.

I'll try Token conrol later today when I get back from the doctor XD

What I need is a control to put in something that will grab a token, hold it's data and then release it (not let it be copied and dragged somewhere else) when someone grabs it :P

Visvalor
December 16th, 2009, 23:21
Ok!

<tokenfield name="token">
<bounds>35,35,23,23</bounds>
<empty>indicator_emptytoken</empty>
</tokenfield>


<tokencontrol name="token">
<bounds>35,35,23,23</bounds>
</tokencontrol>

I've put both of them in the window I want it in and seem to work together, they grab a token, now when I grab the token to take it out how do I get it to delete :P?

So far it just stays in there and copies >_<!

Moon Wizard
December 17th, 2009, 07:44
The documentation is not clear on how to erase a tokencontrol or tokenfield.
https://fantasygrounds.com/refdoc/tokencontrol.xcp

I would try using setPrototype(""). If not, the only other way that I can think of trying is getDatabaseNode().delete(), which would only work for tokenfield.

Cheers,
JPG

phantomwhale
February 1st, 2011, 03:37
Raising this thread from the dead...


The documentation is not clear on how to erase a tokencontrol or tokenfield.
https://fantasygrounds.com/refdoc/tokencontrol.xcp

It sure isn't, which is what brings me here today !


I would try using setPrototype(""). If not, the only other way that I can think of trying is getDatabaseNode().delete(), which would only work for tokenfield.


Tried deleting the database node - it got mad. It didn't respond immediately or reliably, and within a few seconds I kept getting a fatal application error about dbgeng.dll being missing - which is a debugging DLL, to the best of my "I don't really develop windows stuff" knowledge.

setPrototype("") seems to work though.

Moon Wizard
February 1st, 2011, 20:25
From a quick review of the code (now that I have access), it looks like SetPrototype("") is the correct way to clear a tokencontrol/tokenfield.

Cheers,
JPG