I have a script that fires an ability from a given character sheet if certain conditions are met. It works fine unless the ability is whispered, in which case nothing happens. My first thought was that it probably has something to do with the forward slash (/w), so was messing around with escape characters, html replacements, template literals, standing on one leg, etc. but not having any luck. I set up a generic case for testing. Character=CharName with ability=Ability 1. With and without the whisper, Ability1 is defined as: &{template:default} {{label=some text}} /w CharName &{template:default} {{label=some text}} Simplified code I'm using is: on('ready',()=>{
on('chat:message',msg=>{
if(msg.type=="api" && msg.content.indexOf("!AbilityTest")==0) {
var who = getObj('player',msg.playerid).get('_displayname');
//hardcoded for testing
var charName = 'CharName';
var abilityName = 'Ability1';
//get character obj from Name in order to get charID
var charObj = findObjs({_type: 'character',name: charName})[0];;
var charID = charObj.get("id");
//Get the ability object from character sheet & ability name
var abilityObj = findObjs({_type: 'ability',_characterid: charID,name: abilityName})[0];
//Get the text of the ability and send to chat
var action = abilityObj.get("action");
log('action = ' + action);
sendChat(who, action);
}
});
}); Works fine for non-whispered Ability1 but does nothing when changed to the whispered version. I confirmed that the ability's action property contains the string "/w CharName". It's just not sending to chat properly. Seems like there would be a simple way to handle this, but I haven't been able to figure it out. Thoughts?