Selected token in Global Macro

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
RuneStar
Kobold
Posts: 2
Joined: Fri Jan 21, 2022 4:14 am

Selected token in Global Macro

Post by RuneStar »

I'm hoping this is a simple thing, but I am very new to writing macros for MapTool, so here goes:
My problem: being able to see which tokens on screen I have made visible or not to the players.
My solution: Add a 'state' called PlayerVis to change the token appearance when invisible to players, and use a macro to change both Visibility and that state at the same time.

Now I thougt this would be straightforward - i.e. click to select a token then run a macro called Set Visible containing:
[h: setVisible(1)]
[h: setState(PlayerVis,0)]
But the error back is:
Error executing "setVisible": there is no impersonated token.
Error trace : Set Visible@campaign

What am I doing wrong? Any advise would be appreciated. Cheers

User avatar
aliasmask
RPTools Team
Posts: 9023
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Selected token in Global Macro

Post by aliasmask »

On a side note, there is a visual indicator for "Visible to Players". When checked the token names are in Blue and when unchecked they are in Gray.

As for macro, make sure "Apply to Selected" is checked.

User avatar
JoeDuncan
Giant
Posts: 118
Joined: Sun Nov 22, 2020 9:02 pm

Re: Selected token in Global Macro

Post by JoeDuncan »

RuneStar wrote:
Fri Jan 21, 2022 4:25 am
Now I thougt this would be straightforward - i.e. click to select a token then run a macro called Set Visible containing:
[h: setVisible(1)]
[h: setState(PlayerVis,0)]
But the error back is:
Error executing "setVisible": there is no impersonated token.
Error trace : Set Visible@campaign
What am I doing wrong? Any advise would be appreciated. Cheers
All the stuff that relies on selected and impersonated tokens can be super finnicky to work with.

I've found it's often easier to just use tokenIds. For example "setVisible" can be used without having a selected OR impersonated token if you pass the id:

https://wiki.rptools.info/index.php/setVisible

What I usually do, is first use "getSelected" to get the token ids, and then pass tokenIds explicitly from there so I know what I'm working with.

It's much easier to figure out what's going wrong when you aren't relying on a bunch of implicit or unknown side-effects.
"Joe's Ugly Hacks - Get 'em while their hot! Guaranteed ugliest hacks around or your money back!"

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Selected token in Global Macro

Post by Full Bleed »

RuneStar wrote:
Fri Jan 21, 2022 4:25 am
My solution: Add a 'state' called PlayerVis to change the token appearance when invisible to players, and use a macro to change both Visibility and that state at the same time.
I do something similar in my primary framework.

Aliasmask's "Apply to Selected" solution will probably fix your issue. And Joe is right about using token ID's for these kind of actions being a practice you should learn sooner rather than later.

That said, macro solutions for indicating visibility aren't the most reliable method... so I've put in a feature request for this issue.

Hopefully someone will take this on at some point.

https://github.com/RPTools/maptool/issues/3347
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

RuneStar
Kobold
Posts: 2
Joined: Fri Jan 21, 2022 4:14 am

Re: Selected token in Global Macro

Post by RuneStar »

aliasmask wrote:
Fri Jan 21, 2022 11:37 am
On a side note, there is a visual indicator for "Visible to Players". When checked the token names are in Blue and when unchecked they are in Gray.

As for macro, make sure "Apply to Selected" is checked.
A belated thank you for this - I had not noticed the difference, so that is good to know. I think however to my eyes the difference is too subtle and it only appears when you however over the token.
Cheers
Dave

Post Reply

Return to “Macros”