-
June 21st, 2022, 20:01 #1
Adding to a tokens radial menu (5e)
I may be asking something that's been asked before, but my furious googling has come up with very little in the way of answers, so....
How and where would I inject new scripting to add a new icon and function to the right click menu on a token that has been placed on a map from the combat tracker?
Cheers, Steve.
-
June 21st, 2022, 20:14 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,654
See this API reference wiki page:
https://fantasygroundsunity.atlassia.../tokeninstance
Specifically, the registerMenuItem function and onMenuSelection handler registration. It works differently than window controls and window instances, because each token does not have it's own script space.
Regards,
JPG
-
June 21st, 2022, 21:21 #3
Thanks for the reply Moon Wizard.
Although I'm having a bad day, (not my 1st )
Those 2 functions I have no problem with in the general scope of things.. I can add a new right click function to a combat tracker entity. I'm just struggling to see how I can do the same to a token on a map.
Any chance you have an actual code example ?
If not I'll sleep on it and have another look tomorrow
Cheers, Steve.
-
June 21st, 2022, 22:50 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,654
In order to get a copy of a token instance, you'll have to get access to the tokeninstance first. You can do that by using imagecontrol.onTokenAdded event or via a Token.onTokenAdd handler registration.
There is no code in CoreRPG that currently does this sort of behavior. In general, I've tried to move to having controls/functions more explicitly on screen when possible.
Regards,
JPG
-
June 22nd, 2022, 19:59 #5
Thanks Moon Wizard, that helped loads
Cheers, Steve.
-
June 23rd, 2022, 07:14 #6Code:
oldonTokenAdd=ImageManager.onTokenAdd ImageManager.onTokenAdd=newonTokenAdd end function newonTokenAdd(tokenMap) Debug.chat("Token added to map",tokenMap) oldonTokenAdd(tokenMap) tokenMap.registerMenuItem(Interface.getString("ct_ searchtip"), "stv", 4) end
The above code works for adding a new icon to a tokens radial menu but I can't figure out how to apply the corresponding handler.
I'm thinking it can't be done this way.
A yes or no will suffice here so I can stop chasing a 'will never work' solution
Cheers, Steve.
-
June 23rd, 2022, 18:33 #7
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,654
No, anything listed as a "handler" can only be registered; they do not work like functions.
All handlers registered for a particular event will all fire. You don't get to control the ordering.
It's one of the reasons why I'm trying to move all the handler registrations into the onDesktopInit stage of initialization in the beta Test channel; so handler functions can be overriden in the onInit stage of initialization before they are registered as handlers.
Regards,
JPG
-
June 23rd, 2022, 19:30 #8
Good to know, albeit a bit of a shame
I'll take a step back from where I was going with this one and maybe come up with a different angle of attack.
Thanks again Moon Wizard.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks