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.`);
}
}
}
});
});