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
Selected token in Global Macro
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
Re: Selected token in Global Macro
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.
As for macro, make sure "Apply to Selected" is checked.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Selected token in Global Macro
All the stuff that relies on selected and impersonated tokens can be super finnicky to work with.RuneStar wrote: ↑Fri Jan 21, 2022 4:25 amNow 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
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!"
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: Selected token in Global Macro
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."
Re: Selected token in Global Macro
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