PDA

View Full Version : Working with token onDrop calls



Moon Wizard
January 9th, 2009, 03:26
OK, I've been working on implementing the ability to drop dice rolls onto tokens in order to add some more capabilities to the rulesets I support. There are a couple challenges that I came across that I wanted to provide feedback, or get some help with.

* Tokens will not allow drops if the Modifiable flag has been set to false. The only way to allow clients to drop onto a token is to make it modifiable, which means that players can now rotate, move and delete NPC tokens. Not a good thing for my game, since my players like to occasionally torment me. Drops should be enabled even if a token is marked non-modifiable.

* The other challenge that I've come across is with the onDrop handler on the client side. By default, there is no access to the tokens that I could find from the client side. In my rulesets, I have a client combat tracker which uses the token ID and refnode values to call the populateFromImageNode function to generate a reference. However, I ran into 2 problems with this approach. First, if the combat tracker is opened before the map is shared or even before it is fully loaded, then the references are not correct and the onDrop handler does not fire. Second, when a new entry is added to the combat tracker by the GM, the onInit handler on the client side is not called for the combat tracker entry window, so the reference does not get generated.

Anybody have any ideas on getting the combat tracker and map tokens to reference consistently?

Thanks,
JPG

Moon Wizard
January 10th, 2009, 00:15
Is there perhaps a way to assign a general onDrop handler for all tokens?

Then, I could use the token reference passed into the onDrop handler to perform the functions I want.

Thanks,
JPG

Fenloh
January 10th, 2009, 07:41
Or you just switch the Tokens to modifyable during the OnDrop Handler activity and turn it back of afterwards. It is only an entry in the Database, isnīt it?

Fenloh

Moon Wizard
January 12th, 2009, 20:51
The problem is that the onDrop handler never triggers because the tokens are set to unmodifiable in the first place.

Still haven't found a solution to the bigger issue, which is that the token references are not synched with tokens on the map.
* If the GM creates a new CT entry and places the token on the map, only the GM side has the reference correct and accept drops.
* If the CT window is opened prior to the map window being shared or before it finishes loading, any tokens that were not visible when the CT was opened are not reference-able.

Cheers,
JPG

Moon Wizard
January 13th, 2009, 02:39
Tried adding a handler in the imagewindow to rebuild all the token references in the combat tracker using the acquireReference function in combattracker_token.lua. Based on how this seems like it should work, it should force the token references to be re-generated so that the drop handler is added by the acquireReference function.

The code is executing on the client, but I still can't drop attacks on the NPC tokens. The drop handler is not being called, and I've disabled the setModifiable call.

Any ideas out there?

Thanks,
JPG

Goblin-King
January 13th, 2009, 08:41
The modifiability issue isn't exactly a bug, however the fact that clients can't do the script based drops is. I've located the issue, but at this time there is no workaround. The fix will be in the next update, and will address both issues. Thanks for pointing these out.