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] Pulling out a name

1486267476
Andrew C
Marketplace Creator
Basically I am building a simple macro which mimics languages. I'm just not sure how to 'pull out' the name of the person or their Character who activated the macro. So if the controller of "Jim Bob the Destoyer" typed "#Elven I'll smash them all!" then I am looking to be able to drop "Jim Bob the Destroyer" in through something like @{character|character_name}.  I'm just not sure if that will get anything of use.
Try @{selected|character_name} so the character name from the sheet attached to that token will be used. 
1486353349
Andrew C
Marketplace Creator
It's meant to be dropped in Chat, so there may not be a Selected Token.
If the macro is attached to the character sheet you can use @{character_name} otherwise you would need to have some way of designating which character it is pointing too, like a charactger name or have a token selected or targeted. 
1486355971

Edited 1486356000
Silvyre
Forum Champion
^ To give an example, if you choose to supply that macro to every Character as an Ability, you can opt to remove the keyword of Attribute calls, i.e. @{character_name}
1486371719
Andrew C
Marketplace Creator
I think I've found a suitable way around it, as much as I can anyway, but it means that any character mean to use it will need a Character Sheet and you can't load it in through other means it would seem. Actually, Silvyre... Can an API Button remember the 'name' of its source? As in, if a Token on the map has an API Button code loaded into it, can the API Button remember the name of the Token that spawned it?
1486375448

Edited 1486375484
Silvyre
Forum Champion
If by 'loaded into it' you mean saved as a value of a Token Bar, then yes: remove all HTML entities from all Attribute calls that are intended to correspond to the 'source' Token (e.g. @{target|token_name}).
1486377063
Andrew C
Marketplace Creator
I feel like I'm becoming something of a Macro Ninja then.
1486377354
Silvyre
Forum Champion
Haha, you bet!
1486411452

Edited 1486411714
Lithl
Pro
Sheet Author
API Scripter
Andrew (Halfling Gypsy) said: I think I've found a suitable way around it, as much as I can anyway, but it means that any character mean to use it will need a Character Sheet and you can't load it in through other means it would seem. Actually, Silvyre... Can an API Button remember the 'name' of its source? As in, if a Token on the map has an API Button code loaded into it, can the API Button remember the name of the Token that spawned it? If you're going with an API solution, you can grab the ID of the player who sent the message as well as the name they've selected in the "As" dropdown. on('chat:message', function(msg) { log(msg.playerid); // id of the player who sent the message log(getObj('player', msg.playerid)); // the player who sent the message log(msg.who); // the text of the player's selection in the "As" dropdown // if the GM sends the message and their "As" dropdown is OOC, their name will have " (GM)" added });
1486441340
Andrew C
Marketplace Creator
Brian, API Buttons and API aren't quite the same. &nbsp;Silvyre's met a little of my lo-fi solution planning before. <a href="https://wiki.roll20.net/API:Chat#API_Command_Buttons" rel="nofollow">https://wiki.roll20.net/API:Chat#API_Command_Buttons</a>