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

[Request] remove all abilities of selected tokens (except token action

Hello,&nbsp; I've found an API to remove all abilities of selected token in this post: <a href="https://app.roll20.net/forum/post/4154959/request-remove-all-abilities-of-selected-token-s" rel="nofollow">https://app.roll20.net/forum/post/4154959/request-remove-all-abilities-of-selected-token-s</a> I need one capable of removing all the abilities from a selected token EXCEPT those marked as Token Action. Can you help me?&nbsp; Even one using "exception" will work. That's the original code: on('chat:message', function(msg) { if (msg.content !== '!removeall' || !msg.selected) return; _.each(msg.selected, function(sel) { var token = getObj(sel._type, sel._id), abilities = findObjs({ type: 'ability', characterid: token.get('represents') }); _.each(abilities, function(abil) { abil.remove(); }); }); });
1698695257

Edited 1698695342
timmaugh
Forum Champion
API Scripter
Try this version: on('ready', () =&gt; { &nbsp; on('chat:message', msg =&gt; { &nbsp; &nbsp; if (msg.content !== '!removeall' || !msg.selected) return; &nbsp; &nbsp; if (!msg.selected || msg.selected.count === 0) return; &nbsp; &nbsp; msg.selected.forEach(sel =&gt; { &nbsp; &nbsp; &nbsp; let token = getObj(sel._type, sel._id); &nbsp; &nbsp; &nbsp;&nbsp;findObjs({ type: 'ability', characterid: token.get('represents') }) &nbsp; &nbsp; &nbsp; &nbsp; .filter (a =&gt; a.get('istokenaction') === false) &nbsp; &nbsp; &nbsp; &nbsp; .forEach(abil =&gt; { abil.remove(); }); &nbsp; &nbsp; }); &nbsp; }); });
Perfect. Thank You!
1698713825
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The Token Action Maker mod can remove all Abilities. It can be set to skip any abilities that end with a period in the name. If that helps any.