Return the Selected Token's Name (not ID) in a 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
User avatar
Bladehawk
Kobold
Posts: 4
Joined: Fri Apr 15, 2016 12:18 pm

Return the Selected Token's Name (not ID) in a Macro?

Post by Bladehawk »

Well, more specifically, an event macro (onTokenMove).

I'm wondering if there's a way to, in simplest terms, have currentToken() print out the selected token's name instead of its ID. getImpersonatedName() is the closest thing I could find, but it doesn't work with onTokenMove (sitting in a lib) even if applyToTokens is true. I don't think the token is ever impersonated by this particular macro. Maybe there's a way using getTokenNames(), returning only the selected token? I'm not sure!

Netsky
Cave Troll
Posts: 25
Joined: Sat Feb 14, 2015 4:35 am

Re: Return the Selected Token's Name (not ID) in a Macro?

Post by Netsky »

depends on your context: token.name would return you that, however maybe you need to do some switchToken(id) first.

User avatar
Bladehawk
Kobold
Posts: 4
Joined: Fri Apr 15, 2016 12:18 pm

Re: Return the Selected Token's Name (not ID) in a Macro?

Post by Bladehawk »

Yep, I'm an idiot. Totally forgot about that one, thanks!

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

Re: Return the Selected Token's Name (not ID) in a Macro?

Post by Full Bleed »

Bladehawk wrote:Maybe there's a way using getTokenNames(), returning only the selected token? I'm not sure!
Not completely sure what your use case is, but there is this, too: Wiki: getSelectedNames()
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

Post Reply

Return to “Macros”