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

[Script, Snippet] Switch - swap your speaking as (and avatar) easily.

1561681533
The Aaron
Roll20 Production Team
API Scripter
Here's a quick script that switches the player's speaking as (and now their avatar!).  Takes a character id as an argument: !switch @{selected|character_id} or switch back to player: !switch Here's the code: on('ready',()=>{ on('chat:message',(msg)=>{ if('api' === msg.type && /^!switch/i.test(msg.content)){ let p = getObj('player',msg.playerid); if(p){ let a = msg.content.split(/\s+/); if(a.length>1) { let c = findObjs({ type: 'character', id: a[1] })[0]; if(c){ p.set({ speakingas:`character|${a[1]}` }); sendChat('',`/w "${p.get('displayname')}" Switching to <b>${c.get('name')}</b>.`); } else { sendChat('',`/w "${p.get('displayname')}" No character found for ID <b>${a[1]}</b>!`); } } else { p.set({ speakingas: '' }); sendChat('',`/w "${p.get('displayname')}" Switching to self.`); } } } }); });
This changes my avatar but doesn't switch the "Speaking As" in chat.  Is that how it's intended?
1561757683
The Aaron
Roll20 Production Team
API Scripter
Really?  That sounds like a bug. It was working on Dev, I'll verify and submit to Roll20 Devs.
It is an awesome idea.  I'm not going to change my "speaking as" for every NPC from a drop down menu, but I actually would with this script!  Unfortunately I think most of my players don't display the avatars, so I hope I can get this script to work for chat.
1561836453
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Feature suggestion. Add an additional option of: !switch auto With this command, if a token is selected, it will use the character portrait, otherwise it will default to self. This way a single command (or macro bar button, or chat menu item) can switch as available.
Is it only me that this doesn't switch the "As" for?  It will switch the avatar, but doesn't affect speaking as.  
1561837921
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
That is a known and reported bug.
1561841103
The Aaron
Roll20 Production Team
API Scripter
Yeah, sorry, I started to post a reply last night after testing, but fell asleep.  Good idea, Keith.  Any reason not to just set the speaking as to the selected character (if there is only one) and remove the speaking as if you're already speaking as them?  That might be a more natural behavior.
1561841807

Edited 1561841867
A doppleganger with a rollable token.  Or wait, this uses an avatar, not a token...
1561842329
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The Aaron said: Good idea, Keith.  Any reason not to just set the speaking as to the selected character (if there is only one) and remove the speaking as if you're already speaking as them?  That might be a more natural behavior. I think that works. I'm sure some folks would still like the ability to call out character ids anyway: Druids and other shapeshifters, people playing multiple characters, a character with a sidekick or familiar...
1561847960
The Aaron
Roll20 Production Team
API Scripter
Well, they'd still have that option. =D
1561886058
Ziechael
Forum Champion
Sheet Author
API Scripter
Potential feature creep but  have you considered rolling this functionality into turnMarker for tokens that aren't controlled by anyone? Would help a GM automatically keep their 'speaking as' relevant as they progress through the turn order...
Ziechael said: Potential feature creep but  have you considered rolling this functionality into turnMarker for tokens that aren't controlled by anyone? Would help a GM automatically keep their 'speaking as' relevant as they progress through the turn order... That would be cool!
1561917024
The Aaron
Roll20 Production Team
API Scripter
I can get that functionality set up. =D
Has there been any update on getting this working with the "As" for chat?