5E Product Walkthrough Playlist
  1. #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.

  2. #2
    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

  3. #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.

  4. #4
    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

  5. #5
    Thanks Moon Wizard, that helped loads

    Cheers, Steve.

  6. #6
    Code:
    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
    Just realised I posted this in a different thread last night, so apologies for the thread resurrection.

    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.

  7. #7
    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

  8. #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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Character Create Playlist

Log in

Log in