Here's the code that I am talking about:
on('change:ability',(obj,prev)=>{
log(obj.get('name'))
//if(!/^repeating_attack/.test(obj.get('name'))){
// return;
//} --- code replaced so it cannot run wildly
// only abilities with an manually added "a-" in front shall pass here
if(!/^a-/.test(obj.get('name'))){
return;
}
let description = findObjs({
type:'ability',
characterid:obj.get('characterid'),
name:obj.get('name').replace(/(repeating_attack_[^_]+_).+/,"$1atk_desc")
//name:obj.get('name').replace(/(repeating_npcaction_[^_]+_).+/,"$1atk_desc") -- did get funny results, e.g. "ui_flags"
})[0];
log('desc: ' + description);
// example from Aaron, mainly the same as above except for that replacement and it's looking at attributes
let attr = findObjs({ type: "attribute", characterid: obj.get('characterid'), name: obj.get('name')})[0];
log('attr: ' + attr)
if(description){
log('checkpoint 1')
if(!/attacking @{target|token_id}/.test(description.get('current'))){
log('checkpoint 2')
description.set({current:`${description.get('current')}\nattacking @{target|token_id}`});
log(description)
//log(obj.get('description')); //),description));
}
}else{
log('checkpoint 3')
createObj('ability',{
characterid:obj.get('characterid'),
name:obj.get('name').replace(/(repeating_attack_[^_]+_).+/,"$1atk_desc"),
current:'attacking @{target|token_id}'
})
}
});