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

Macros that change who is "talking" in chat

I am in a campaign that has characters running two characters each. It is beginning to get a little confusing, is there a way to have macro that sends script (roll) to chat as the name of token that is being selected. I can use /as or /emas for myself as the GM, but that fails to work for players. I am hoping that this does not require a script, because I have yet to get a script to work at all. I've tried four different simple ones and none of them seem to work.
I wish. My team has 2 each as well. Only GM can use emas. I've seen some scripts, but none of them can pull it off without some wonky errors. +1 though for this to be an optional player feature.
1399399292
Lithl
Pro
Sheet Author
API Scripter
A script could send messages as a specific player or character, but there's no way to change what's selected in the Speaking As dropdown below the chat.
Brian said: A script could send messages as a specific player or character, but there's no way to change what's selected in the Speaking As dropdown below the chat. What script would be required, and how can I get the scripts to work I've tried repeatedly. I've looked on youtube but although there are a ton of videos showcasing scripts none of them show a step by step on how to activate them and use them in a campaign.
1399407029
Gold
Forum Champion
how about just putting the character name in the macro? BORF THE FIGHTER [[1d20]] MY OTHER PC, HANK THE HOBBIT [[1d20]]
Because I want a "New" entry on the chat for each roll, and I also want to create universal macros that I can stick on for everyone for attributes that EVERYONE uses. Therefore what you are suggesting wont work. Also the less text the better in the chat. I am very minimalist, so I only want the name to show up once, on the line that says who is talking. Which forces me to be harda$$ DM.. telling my players that if they don't switch who's talking manually the roll doesn't count. I don't like that either.
1399413110
Lithl
Pro
Sheet Author
API Scripter
Peter R. said: Brian said: A script could send messages as a specific player or character, but there's no way to change what's selected in the Speaking As dropdown below the chat. What script would be required, and how can I get the scripts to work I've tried repeatedly. I've looked on youtube but although there are a ton of videos showcasing scripts none of them show a step by step on how to activate them and use them in a campaign. To get a script into the campaign, copy the script's code and paste it into a tab on the "API Scripts" page. Make sure to give the tab a name, and hit "Save Script". Here's an (untested) sample script that would post to the chat as a given character. To use it, you'd type !as Peter R.|Hello, world! Note that there is currently a bug with the sendChat function, and if you use this with a player's name, their avatar won't show up. If you use a character's name, however, it should work fine. You can also include partial names, and the script will to its best to find who you're talking about. I haven't spent the time to make this script work with inline rolls, but it's absolutely doable. on('chat:message', function(msg) { if (msg.type != 'api') return; var command = msg.content.split(' ').shift().substring(1); if (command == 'as') { var content = msg.content.substring(4); var parts = content.split('|'); if (parts.length < 2) { sendChat('SYSTEM', 'No player or character specified for message sender'); return; } var who = parts.shift(); var message = parts.join('|'); var players = filterObjs(function(obj) { if (obj.get('type') != 'player') return false; return (obj.get('displayname').indexOf(who) >= 0); }); if (players.length > 0) { who = 'player|' + players[0].id; } else { var characters = filterObjs(function(obj) { if (obj.get('type') != 'character') return false; return (obj.get('name').indexOf(who) >= 0); }); if (characters.length > 0) { who = 'character|' + characters[0].id; } else { sendChat('SYSTEM', 'Could not find a player or character matching the name ' + who); return; } } sendChat(who, message); } }); This script also doesn't check that the person sending the command has permission to speak as the given player or character, so watch out! Checking those permissions could be done in the filterObjs callback function. For example, you could allow the GM to talk as anybody, but others can only talk as a player if they are that player, and can only talk as a character if they have control over that character.
Looks good, and I like it. But is there a way to run it as an orange box instead of a grey one?
Also, I'd like to use this feature as a heading for shared attack macros. Normally the orange bar shows up at the top of a chunk of text. But if this is inserted in a multi-line text, it always appears at the bottom, regardless of where it is placed.
1399425200
Lithl
Pro
Sheet Author
API Scripter
Robert R. said: Also, I'd like to use this feature as a heading for shared attack macros. Normally the orange bar shows up at the top of a chunk of text. But if this is inserted in a multi-line text, it always appears at the bottom, regardless of where it is placed. The sendChat function is asynchronous. There is no guarantee on the order of the output of multiple consecutive calls to sendChat, although sendChat will almost assuredly output after regular lines in a macro.
hm. is it possible to make a script that just chooses a different character selection from the dropdown?
1399435456
Lithl
Pro
Sheet Author
API Scripter
No, that is not possible
1399436356

Edited 1399436848
Toby
Pro
How about choosing a character based on what token is selected. (Assuming they have permission to control the token). Also, anything added in the same command gets shoved ABOVE in the chat area, which defeats the whole point of this. I want any further text to displayed below as to be seperated from the previous text.
1399490097
Lithl
Pro
Sheet Author
API Scripter
msg.selected will be an array of the currently selected token objects, which you could then use to find characters via the token's represents property. On the other hand, you could simply use @{selected|character_name} to get the name directly, and not need to modify the script. The only solution to the asynchronous problem is to have all of the messages in the same macro use the !as command. It's not an ideal solution, for obvious reasons, but it's also worth noting that even if every line of the macro uses !as, you're not guaranteed that will be the output order. Usually, if you have several API commands in a single macro which call sendChat, the macro order will be the order they appear in chat, but not always. It is almost guaranteed that regular lines will appear before the output from sendChat calls. This is not something that's really solvable.
Brian said: msg.selected will be an array of the currently selected token objects, which you could then use to find characters via the token's represents property. On the other hand, you could simply use @{selected|character_name} to get the name directly, and not need to modify the script. huh? whut? Are you saying you can stuff the name into a macro based on what token is selected?
1399533804
Lithl
Pro
Sheet Author
API Scripter
Yes, you can. Here's the wiki documentation on the subject . In addition to @{select|...}, you can also use @{target|...}, and you'll be prompted to click on a token after running the command/macro/etc. Target lets you access macro-able information for tokens you don't have control over.
@{selected|character_name} does not change *who* emotes the command, though. We desperately need a /inchar command, see my suggestion thread here . I'm hoping if enough people with "Mentor" after their name post in one thread (instead of a hundred of us one-each in different threads) that the devs will take the time to implement it...
1399573623
Lithl
Pro
Sheet Author
API Scripter
Kikanaide, my earlier comment was about using @{selected|character_name} along with the script I wrote earlier in the thread.