Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
Create a free account

Macro detecting who's calling it.

So is there a way for a Macro to find out who the person calling the macro is? Like, say I have a token that everyone controls, with a token action on it. I want it to be able to know who's clicking on it so it can maybe whisper to JUST that person, or sometimes scripts sometimes want to know who's calling them too?  It would make sense for this not to be a thing, but incase it is, it would be mucho helpful. Otherwise i'll just have the player select via a query who they are.
Forum Champion
Marketplace Creator
API Scripter
I think so, but the API script would need to be written in such a way as to report the user at the run time.
I think it is. I'm using the MapChange Script, and the call for it can use a query as the player argument. Is this only doable via script? Or is there a way to do it in the usual macro language?
Forum Champion
Marketplace Creator
API Scripter
I don't think that would work out of the box (that you as GM would know who had called the macro), but I haven't really examined it, either.
Well, I don't really care finding out myself. It's just it'd be nice to have the Macro know. IE, They can Whisper that person directly, instead of everyone who controls the token connected to the macro, or for the move script. The basics is that the script moves a player to a different map, but it does that via a query box, asking who to move to the new map. I just want to see if i can have it so it always moves the person calling the macro that issues the script command. I want avoid mucking about in someone else's script because I'm not super familiar with JS, and if there's a Macro-Level solution to it, I want use that.
Ultimately, what I just want is a token on screen the players can click on, revealing a Token Action Macro that will detect who the person pressing the macro is, so it can input that into one of the arguments of the script.. Failing that, i'll just have 4 tokens all stacked up ontop of each other, one for each player, named after that player. The only issue with that is if they change their names ingame ofc. So that the only person who can select "Player X" the token is Player X the player, so when it calls, referencing the name of the selected token, it'll input that as an argument.  Not the most elegant solution but.... *shrug*
Doesn't chat report who said something in chat? Could just put a message in the macro. Example of macro body: !mapThingWhateverAPIScript Using Map thing That second line of text should go to chat, with the user's name above it?
It's not so much I wanna know, I want an argument to reference who called the macro, because the script will make the change to the player. The command to run the script looks like so by default: !mc move --target Player Area --player ?{Player|hyde|player|Pizza} I just want to see if i can change that query so it references who calls the macro to write the command.
Oh. Hmm, I should've read more clearly. Yeah, I think it would come down to either modifying the mc script, or adding your own listener script to execute a call of the mc function, with inputs based on msg.who.
A macro would not be able to whisper to the controlling player - you can reference the character name or the token name in a macro, but not the controlling player or the current player using the macro. However, API Scripts do have access to controlling player or current player who is activating the macro, but the script would need to be written in a way to generate a whisper to just that person.   You can see it in the API code, listed as something like:     var getPlayerIdFromDisplayName = function(name) { Then the script would need to be adjusted to whisper to the player instead of the GM. The current code has something like:                     chat("/w", "gm", msg.who.replace("(GM)", "") + " has moved " + playerAddition + "to " + target); There's more that needs to be done, and it's beyond my coding skills, but that's the general idea.  
Got it. As long as I ahve confirmation one way or the other about the macro-level, that's fine. Cheers.
The Aaron
Roll20 Production Team
API Scripter
If you're going the multiple token route, you could make each token represent a different character, then give control of the character to the player and whisper to the character in the macro. That way, if the player changes his name, your macro is still fine. 
That's how i've done it yeah. 
I'm using the Script MapLock to enforce all the tokens are stacked on top of each other, so even if players muck about with them, it shouldn't be an issue.