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 Request] Create Custom Token Abilities

I know there is the TokenActionMaker script , but I'm hoping for a simple script that could create Token Abilities with a basic macro, such as: !create-token-ability --name|'Action Name' --ability|'Script Here' --istokenaction|true/false I've tried to look at the basic script that Kevin wrote as the basis for what became TokenActionMaker and a separate  scriptlet from The Aaron, but I don't have enough javascript skills to figure out how to modify it to simply create an ability on a character sheet based on an input from the chat.
1607039985
The Aaron
Roll20 Production Team
API Scripter
The hardest part about that is going to be what is in 'Script Here'.  For  example, inline rolls and ability references will get expanded before the API sees them.  API commands will be hard to deal with as they will likely break the syntax of the !create-token-ability command. What is your use case, perhaps there's another solution?
1607040722
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I'd probably recommend looking at either my menu maker script or the universal chat menu script by GiGs.
1607043146

Edited 1607043430
The Aaron said: The hardest part about that is going to be what is in 'Script Here'.  For  example, inline rolls and ability references will get expanded before the API sees them.  API commands will be hard to deal with as they will likely break the syntax of the !create-token-ability command. What is your use case, perhaps there's another solution? The primary use case at the moment is that I've created a 'universal' token action macro mule character, so for each NPC I can simply add the same 5 token actions and 4 attributes to create a chat menu for that NPC. It was a stupid amount of manual work to set up on the 'NPCAbilitiesMacros' character, but it means I get an output exactly the way I like it. The 5 macros are: Abilities %{NPCAbilitiesMacros|Template}%{NPCAbilitiesMacros|AbilitiesList}}} {{name=Abilities}} Actions %{NPCAbilitiesMacros|Template}%{NPCAbilitiesMacros|ActionsList}}} {{name=Actions}} Legendary Actions %{NPCAbilitiesMacros|Template}%{NPCAbilitiesMacros|LegendaryActionsList}}} {{name=Legendary Actions} Reactions %{NPCAbilitiesMacros|Template}%{NPCAbilitiesMacros|ReactionsList}}} {{name=Reactions} Traits %{NPCAbilitiesMacros|Template}%{NPCAbilitiesMacros|TraitsList}}} {{name=Traits} And a ChatSetAttr macro to set 4 attributes that are referenced (this doesn't need to be done in the script): !setattr {{ --silent --sel --replace --actions|'?{How many Actions?}' --legendaryactions|'?{How many Legendary Actions?}' --reactions|'?{How many Reactions?}' --traits|'?{How many Traits?}' }} Honestly if the 'Script Here' was just hard coded into the script that would work fine for me too! It seems like it would go into something like the createObj portion of the first script I linked. createObj("ability", {name: repeatingName, action: repeatingAction, characterid: character.id}); I've done the first few NPCs manually, but I'd rather have a script to set up the rest. I also have a similar setup for spells, but I haven't finished all the recursive macros on the NPCSpellsMacros character yet because I'm still deciding how I want that to look, which will probably be a little different than the Abilities.
1607043898
The Aaron
Roll20 Production Team
API Scripter
Hmm... Maybe this will help?&nbsp;&nbsp;<a href="https://app.roll20.net/forum/post/1067109/script-charutils-a-collection-of-utilities-for-manipulating-character-data" rel="nofollow">https://app.roll20.net/forum/post/1067109/script-charutils-a-collection-of-utilities-for-manipulating-character-data</a>
I think so! I haven’t seen this script before, so I’ll have to check it out tonight or tomorrow morning and I’ll let you know. I’m glad you already had something for this use case haha. Thanks!
1607051417

Edited 1607051425
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
There are also these approaches: Universal Chat Menus &nbsp;&nbsp; 5e Menu Macros &nbsp; Menu Maker &nbsp;&nbsp; 5e Menu Macros NPC Statblock Chat Menu for D&amp;D 5e sheet — No API required! Token Action Maker
1607056880
timmaugh
Pro
API Scripter
In messing around with InsertArg tonight, I found you can copy abilities from a Mule character to a destination character fairly easily, as long as you have access to both. The command line, by IA standards is quite short: !ia --load#SourceCharacter|SourceAbility --store#DestinationAbility I explain more in this post .
The Aaron said: Hmm... Maybe this will help?&nbsp;&nbsp; <a href="https://app.roll20.net/forum/post/1067109/script-charutils-a-collection-of-utilities-for-manipulating-character-data" rel="nofollow">https://app.roll20.net/forum/post/1067109/script-charutils-a-collection-of-utilities-for-manipulating-character-data</a> keithcurtis said: There are also these approaches: Universal Chat Menus &nbsp;&nbsp; 5e Menu Macros &nbsp; Menu Maker &nbsp;&nbsp; 5e Menu Macros NPC Statblock Chat Menu for D&amp;D 5e sheet — No API required! Token Action Maker timmaugh said: In messing around with InsertArg tonight, I found you can copy abilities from a Mule character to a destination character fairly easily, as long as you have access to both. The command line, by IA standards is quite short: !ia --load#SourceCharacter|SourceAbility --store#DestinationAbility I explain more in this post . It looks like I have several approaches!&nbsp; CharUtils is working, so I'll use that to prep for my next session tomorrow, then I'll play around with InsertArg to see if it ends up working better. I've used Universal Chat Menus and Token Action Maker before (great scripts), but the output just wasn't exactly what I wanted for either one.&nbsp; Eventually I'd like to figure out how to merge the two scripts so that ability chat menu buttons are created for a character grouped by type (Actions, Legendary Actions, Reactions, Traits), instead of having individual buttons for each repeating item.&nbsp; My approach gives me a non-API way to create Universal Chat Menus that create 'info' links for each item, and also has custom styles added without using Stylus, so it'll always display correctly if I use it for my players who aren't using Stylus. Thank you to all three of you!&nbsp;