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 .
×
Advertisement Create a free account

[Script] Token Action Maker v.0.2.7

1586740844

Edited 1617089466
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I love this script. I am not the original author, but I don't think Kevin has been active on the forums in about two years. I have updated it to give it more flexibility. If you have been using version 0.2.6 of the script, the base command !ta, will create a few more buttons. but you can now fine-tune which buttons are produced. GiGs also contributed logic to assign actions by name rather than character_id if this is more useful. This script creates token actions on selected tokens for the D&D 5e by Roll20 sheet. Tokens must represent character sheets, either PC or NPC. !ta  This command will create a full suite of token action buttons for a selected character. Actions for NPCs and Attacks for PCs. !sortta This command functions identically to !ta, but will prepend "a-" to NPC actions, and "al-" to NPC Legendary Actions. It is not intended for PCs, whose Token Action Buttons are already created in sort order. (So are NPCs, but this makes the difference clear between Actions and Legendary Actions, for instance.. It is "al-" instead of "la-" to do better grouping for players who prefer to display token actions in alphabetical order. !deleteta  will delete ALL token actions for the selected character, whether they were created by this script or not. Use with caution. You can create specific classes of abilities by using the following arguments separated by spaces. Arguments can be given in any order: attacks  Creates a button for each attack. In the case of NPCs, this includes all Actions. traits Creates a button for each trait. PCs can have quite a number of these, so it is not recommended to run this command on PCs. reactions  Creates a button for each reaction. This will be ignored on PCs since only NPC sheets have a repeating attribute for reactions. spells  Creates a button that calls up a chat menu of all spells the character can cast. checks  Creates a drop down menu of all Ability and Skill (Ability) checks saves  Creates a dropdown menu of all saving throws init  Creates a button that rolls initiative for the selected token pc  creates full suite of buttons for everything but traits. Although this will also work on npcs, the intent is to not include trait buttons for pcs, which can get rather numerous. name  Normally, Token Actions are created using the character_id. They will still function even if the character is renamed. However this is not always desireable. If a character is moved to a new game via the Character Vault, it will receive a new character_id, and the token actions will not function. If you intend to move the character, use the "name" argument in the string and it will call the token actions by name. help  Calls up this help documentation Examples: !ta  will create all token ability buttons for the selected character. !ta saves checks  will create token ability buttons for Ability Checks and Saving Throws. !ta spells  will create a token ability buttons that calls up a chat menu for the character's spells. !ta name will create all token ability buttons and identify them by name, rather than character_id. !ta name pc  will create all token ability buttons and identify them by name, rather than character_id, but not for traits. !ta help  will give you all of the accepted arguments Here is a chat menu that you can fit into whatever setup chat menu you might use: /w @{selected|character_name} &{template:npcaction} {{rname=Create Token Actions}} {{description=[All](!ta) | [Attacks](!ta attacks)) | [Spells](!ta spells) [Checks](!ta checks) | [Saves](!ta saves) | [Initiative](!ta init) [Delete ALL Token Actions](!deleteta)--Caution!}} Output looks like this. If you like the nice neat buttons instead of the Big Pink Buttons Roll20 uses by default, check here:  Inline Links on OGL Roll Templates This is available in One Click.
1586747910
The Aaron
Forum Champion
API Scripter
Nice!
1586798233
Dumbhuman
Pro
Marketplace Creator
I used to love this script too (especially with the added sortta options found here to group attacks together), but there was always a modification I wanted made to it so it would be more flexible for my needs: the option to use character name instead of character_id.  Right now, it writes the abilities with the character_id embedded in there like so: %{-M2qQVNY1vYOv5anPz23|repeating_npcaction_-M2qQVcc7duNZcvXkp65_npc_action} I can understand that a very good reason to use the id rather than the name is because it will persist even if the name on the character sheet is changed later.  Unfortunately though, if you export the character via the Character Vault, those token actions will all error out when you import that character into a new game, because your character has a different character_id than in the original game. Of course, if your new game has the TokenActions script installed, you could run it there to overwrite the abilities to the new character_id, but I'm typically using the Character vault to transport characters into games that don't have API access.  So I'd love to be able to enter a command like: !sortta --name That way you'd be able to export the character to any game without the abilities breaking. 
1586799549

Edited 1586799564
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I'll check into that. It might not be too difficult to do. I'd probably just add "byname" to the list of arguments. I'll look deeper into the guts (remembering I didn't write this originally, and only superstitiously poke at stuff.
1586803405

Edited 1586803492
GiGs
Pro
Sheet Author
API Scripter
You can get the character name from the id within the script, you dont have to make any change to the arguments. If you want to make a quick-and-dirty permanent change, there are two lines to change: 42 and 153. This is the bit that inserts the character id. So you just need to change that to grab the character name instead. " + id + " to something like " + getObj('character',id).get('name') + " If you want to offer the object to use id or name, that's a bigger change.&nbsp; Here's a first pass at a tweaked version that does that - untested, since I dont have any D&amp;D5e campaigns:&nbsp; <a href="https://gist.github.com/G-G-G/95280c9f284618fbde7f799a2723ae24" rel="nofollow">https://gist.github.com/G-G-G/95280c9f284618fbde7f799a2723ae24</a> Keith feel free to take that code, since I won't be maintaining it (as long as it works). To use it, just add "byname" in the inputs, like !sortta byname !ta byname saves checks The order doesnt matter, it can be anywhere. Try it out and see if it works.
1586803553
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thank You! I'll try it out tonight. Today, I'm making lots of tiny buildings.
1586803681
Dumbhuman
Pro
Marketplace Creator
Hey, GiGs... it's currently throwing an error into my console when restarting the sandbox after adding that version of the script. SyntaxError: Unexpected token const
1586803720
GiGs
Pro
Sheet Author
API Scripter
I've probably used that somewhere i should have used let or var, let me check.
1586803791

Edited 1586803844
GiGs
Pro
Sheet Author
API Scripter
ah its line 6 - that needs to be deleted (i updated the gist). I was creating the usename variable one way, then changed it later and forgot to delete the first version.
1586804136
Dumbhuman
Pro
Marketplace Creator
I'm still getting it unfortunately.&nbsp; I threw the code into jshint.com and it's warning about line 11.
1586804312

Edited 1586804363
GiGs
Pro
Sheet Author
API Scripter
Change the semi-colon on line 14 to a comma. I've updated the gist. edit: AND remove const from line 11.
1586807050
GiGs
Pro
Sheet Author
API Scripter
After a bunch of false starts, it appears to be working now. I made a campaign and got it working with some NPCs dragged in from the compendium. I dont have any fully designed PCs to test with, but if it works for npcs it should (probably) work for pcs.
1586807826
GiGs
Pro
Sheet Author
API Scripter
Looks like I was premature. I'm taking down the gist till I have a proper chance to test it.
1586810624
GiGs
Pro
Sheet Author
API Scripter
Wow, I treally shouldnt code when sleep deprived. A few silly typos fixed, and now it is working properly. The gist again&nbsp; <a href="https://gist.github.com/G-G-G/95280c9f284618fbde7f799a2723ae24" rel="nofollow">https://gist.github.com/G-G-G/95280c9f284618fbde7f799a2723ae24</a>
1586814877
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Sweet! Thank you! I'll give it a spin tonight and then updated the github copy.
1586822246
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Looks great, thanks again. I only made one further change. !ta name will produce all possible token actions, but by name, rather than character_id. Top post has been updated, as well as the code, and GiGs' name added to the list of contributors.
1586851671
GiGs
Pro
Sheet Author
API Scripter
Yay, I'm famous!
This is a great API. Are there any plans on adding Traits, Reactions, and/or Legendary Actions?
1587345084

Edited 1587345359
Uhhhh ... where has this script been all my (relatively brief) Roll20 life? :D&nbsp; This. Is. Amazing. I'm frustrated at the amount of time I currently spend clicking monster sheets and minimizing them after a monster attack. This just takes care of almost every issue I have, and ensures that I won't need to look at the monster sheet except for traits and reactions. My players will also greatly appreciate being able to access their checks, saves, and spells so easily. I am adding my voice to Jaimie's to ask for traits, reactions, and legendary actions in a future version of the script, but for now, thank you Keith and Gigs!
1587407095

Edited 1587407131
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I have added traits and reactions to the script: traits Creates a button for each trait. PCs can have quite a number of these, so it is not recommended to run this command on PCs. reactions &nbsp;Creates a button for each reaction. This will be ignored on PCs since only NPC sheets have a repeating attribute for reactions. I have done only quick testing on this, but if anyone discovers any issues, report here. The code is in the top post, along with a changelog. Thanks.
keithcurtis said: I have added traits and reactions to the script: traits Creates a button for each trait. PCs can have quite a number of these, so it is not recommended to run this command on PCs. reactions &nbsp;Creates a button for each reaction. This will be ignored on PCs since only NPC sheets have a repeating attribute for reactions. I have done only quick testing on this, but if anyone discovers any issues, report here. The code is in the top post, along with a changelog. Thanks. Whoa. Thank you, Keith. I'll take a look tonight and let you know if I find any issues.&nbsp;
1587441923
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Added a " pc " argument. When you include this, it will create buttons for everything but traits.. It's the equivalent of sending !ta attacks spells checks saves reactions init This is just a shortcut to avoid traits, which could add 10-20 buttons on even a moderately leveled PC. Command is: !ta pc or !ta name pc
It seems to be working for me. I'll continue to test it. Thanks Keith!
1587450451

Edited 1587450712
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Oh, you had asked about Legendary Actions. Apparently the script already did that even before I started messing with it. They are included with regular actions if there are any available.
I'm really glad that someone picked this one up and is moving forward with it!&nbsp; I had always intended to get it into the repo as well, but never found the time to really invest in it.
1587479797
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
It's amazingly useful! Thank you for the script. I can't believe something like this isn't baked into the companion script for the sheet. Would you mind if I submitted to the repo, once everything looks settled? Or would you rather?
Tested 0.2.9 last night and it worked fine, no issues. I cannot overstate what a great quality-of-life script this is for me. Yes, I could manually create token actions for players and monsters, but that would be a time-consuming slog. This gets me everything I want with a few clicks. Combat is going to go a lot faster from now on!
1587486271
Dumbhuman
Pro
Marketplace Creator
One thing that's currently missing from this version of the script is the ability to group actions together so they're more easily distinguished from traits.&nbsp; Kevin had added a command, !sortta, which prepended "a-" to action names and "al-" to legendary action names so that they'd all appear on the left if Sort Token Actions Alphabetically is enabled (as it is by default).&nbsp; I can see that the function sortrepeating as well as the call !sortta are present in the code, but the command doesn't currently work for me.&nbsp; I get the message that token actions have been created, but no abilities are written to the character sheet. One suggestion that I always thought could be helpful to GMs is for all traits to default to being whispered.&nbsp; That way, you could quickly read up on what a monster's Multiattack or Regeneration does without opening the character sheet or advertising those traits to the players.&nbsp; If you needed to display traits in chat, you could always open the character sheet and send them from there.&nbsp; Just a thought.&nbsp; I currently use a /talktomyself toggle macro to achieve that effect so it might not be worth the effort to figure out how to bake it into TokenActions.
1587488103
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Yeah, Talktomyself has the drawback of ignoring API calls, though. I'll look at !sortta, but sorting token actions only works if you have the option to sort alphabetically turned on. I don't. I have a Stylus style that colors all global token actions (those from the sidebar) one color, and local token actions (those from the sheet) another. If I turn on alphabetic sorting, I get this:
KC . said: One thing that's currently missing from this version of the script is the ability to group actions together so they're more easily distinguished from traits. Yes, I'm curious about this in general because I don't think that's possible with the Shaped Companion script either. It would be nice to have a generic script for sorting abilities.Maybe I've overlooked it. One suggestion that I always thought could be helpful to GMs is for all traits to default to being whispered.&nbsp; That way, you could quickly read up on what a monster's Multiattack or Regeneration does without opening the character sheet or advertising those traits to the players. +1 Having a button that just whispered all traits to myself would be very helpful. I had manually set that up before moving to API scripts recently, so trying to reproduce what I had done manually. Perhaps I need to get into the code one day too...
1587495481
GiGs
Pro
Sheet Author
API Scripter
Dont take this as gospel - but I seem to remember that roll20 made a change on how token actions were handled, and that broke the ability to&nbsp; sort them.
1587496351
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
You can sort Sheet Abilities alphabetically, or by order on the list, according to your settings on the settings tab. If you choose alphabetically, and abilities that are actually token action macros on the Collections tab will be alphabetically mixed in. If you de-select alphabetically, all sheet ability token actions will sort first, according to their order on the sheet, and then all token action macros on the Collections tab will appear after them, but still sorted alphabetically. You cannot manually re-order the Collections tab.
keithcurtis said: If you de-select alphabetically, all sheet ability token actions will sort first, according to their order on the sheet, and then all token action macros on the Collections tab will appear after them, but still sorted alphabetically. You cannot manually re-order the Collections tab. Thanks - I wondered if there was a prefered method to reorder the token actions on the sheet. For me, perhaps this will involve digging into how the Shaped Companion populates these abilities and manually changing the order. I didn't see any way to do this from the existing config menu(s). Sorry, this is slightly offtopic from the current thread but I share similar interests.
keithcurtis said: It's amazingly useful! Thank you for the script. I can't believe something like this isn't baked into the companion script for the sheet. Would you mind if I submitted to the repo, once everything looks settled? Or would you rather? Please feel free.&nbsp; I'm currently not active on Roll20, but pop in when I get PMs, and I stopped by when I received several requests around this script.
North said: KC . said: One thing that's currently missing from this version of the script is the ability to group actions together so they're more easily distinguished from traits. Yes, I'm curious about this in general because I don't think that's possible with the Shaped Companion script either. It would be nice to have a generic script for sorting abilities.Maybe I've overlooked it. One suggestion that I always thought could be helpful to GMs is for all traits to default to being whispered.&nbsp; That way, you could quickly read up on what a monster's Multiattack or Regeneration does without opening the character sheet or advertising those traits to the players. +1 Having a button that just whispered all traits to myself would be very helpful. I had manually set that up before moving to API scripts recently, so trying to reproduce what I had done manually. Perhaps I need to get into the code one day too... I agree with the above. When I manage my token actions, I prepend "Action:" or "Trait:" to help group them. I also whisper traits. Not difficult to do manually, but it would be a nice enhancement. Another recommendation is to approach PC traits similar to spells or ability checks to prevent clutter.
1587855452
I love this, thank you Keith.
Keith, this is so handy. However, it doesn't look like the Save action is including global_save_mod correctly&nbsp;&nbsp;(even though global_save_mod is in the calculation). For example, enable the Bless example. You get the first roll is from the sheet and includes the Bless roll. The second one is from the action and does not.&nbsp; Hovering over the first set of numbers shows base set of rolls and default mod plus the bless roll (tricky to take a screen shot). The second set just shows the single roll and the default mod. I tried to modify the action but couldn't get the right incantation inside or outside the Roll Query. I'll keep looking at it but was curious if you'd already seen this. Thanks.
1588101355
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
That part of the code goes way back to the beginning. I'll look into re-writing it using built in sheet rolls instead of the code it uses now.
1588102485

Edited 1613261455
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Code update to 0.3.0. Added the following features: !sortta &nbsp;This command functions identically to !ta, but will prepend "a-" to NPC actions, and "al-" to NPC Legendary Actions. It is not intended for PCs, whose Token Action Buttons are already created in sort order. (So are NPCs, but this makes the difference clear between Actions and Legendary Actions, for instance.) Long button-phrases are now abbreviated. Examples: "Longsword (One Handed)" becomes "Longsword-1H" "Recharge (5-6)" becomes "-(R5-6)" "(Costs 2 Actions)" becomes "-(2a)"
1588104364
GiGs
Pro
Sheet Author
API Scripter
Those look like great optimizations.
keithcurtis said: Code update to 0.3.0. Added the following features: !sortta &nbsp;This command functions identically to !ta, but will prepend "a-" to NPC actions, and "la-" to NPC Legendary Actions. It is not intended for PCs, whose Token Action Buttons are already created in sort order. (So are NPCs, but this makes the difference clear between Actions and Legendary Actions, for instance.) Long button-phrases are now abbreviated. Examples: "Longsword (One Handed)" becomes "Longsword-1H" "Recharge (5-6)" becomes "-(R5-6)" "(Costs 2 Actions)" becomes "-(2a)" *wild clapping* Can't wait to try this out.
Really glad I found the API community forums, and I found this article. I was worried I would have to write this up myself, and its a shame that the online books don't implement Abilities for the npc's action list. I'm also glad its being maintained, and it has a git. Much appreciated.&nbsp;
1588618796

Edited 1588623386
I'm getting a similar error from both TokenAction and TokenFate as reported in the post:&nbsp; Token Fate on click broken .&nbsp; I've tried to go back to an older version of TokenFate with no success.&nbsp; I've tried two different versions of TokenAction.&nbsp; I reported the exact errors I'm getting in:&nbsp; Problems with Script .&nbsp; &nbsp;TokenAction simply doesn't work and crashes the API every time.&nbsp; Btw, the old version of TokenAction broke if the Token had a space in its name. I don't know yet if this version does since I've not been able to use it at all.&nbsp;&nbsp; Edit/update: after some experimentation, it looks like TokenFate is the real culprit and causing all other scripts to break.&nbsp; I tried all the available versions of TokenFate and version 1.1.1 and version 1.1.0 both caused crashes.&nbsp; Version 1.0.0 of TokenFate allowed other scripts to work once &nbsp;and then any further usages caused the same error messages to appear.&nbsp; This is for anyone else experiencing the same kind of problems.
1588623744

Edited 1588627413
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Things to check: 1) You have installed the latest version from the top of this thread. Here's the link . As of this post, the latest version is 0.3.0 2) You are using the D&amp;D 5th Edition by Roll20 sheet. 3) You have tried the script alone on its own test game to ensure it is not an error with a different script (this is quicker than turning off all other scripts one by one.) 4) You are copying the Raw text from the link to ensure you are not gathering up any garbage characters. As for the name issue, Token Action Maker will not only recognize names with spaces in them, but thanks to a code addition by GiGs, it has the option of creating the token action macros using name instead of character ID, which fixes some issues with transporting the characetr from game to game via Vault or Transmogrifier.
1588628530
keithcurtis said: Things to check: 1) You have installed the latest version from the top of this thread. Here's the link . As of this post, the latest version is 0.3.0 2) You are using the D&amp;D 5th Edition by Roll20 sheet. 3) You have tried the script alone on its own test game to ensure it is not an error with a different script (this is quicker than turning off all other scripts one by one.) 4) You are copying the Raw text from the link to ensure you are not gathering up any garbage characters. As for the name issue, Token Action Maker will not only recognize names with spaces in them, thanks to a code addition by GiGs, it has the option of creating the token action macros using name instead of character ID, which fixes some issues with transporting the characetr from game to game via Vault or Transmogrifier. Thanks.&nbsp; As I reported in my edited post, and in my post in another thread, the culprit appears to be TokenFate.&nbsp; I've deleted that script for now. As for the name issue, I haven't tested it yet but if you fixed that problem I'm soooo happy. :-)&nbsp; It took me a few hours with the older version of the script to figure out the problem.&nbsp; It's only because I remembered from my script writing days as a professional programmer that spaces can sometimes cause issues that I found and fixed the problem in my game.&nbsp; I was working on learning enough of the API to fix it on the older version of the code but you beat me to it. ;-)&nbsp; Again, thanks.
1590955064
Awesome API! Super helpful!
Just an issue I've encountered. The !sortta command doesn't work for me at all. When I try it on an NPC/monster using arguments (like attacks reactions, etc.), nothing happens. No buttons are created.&nbsp;
1591642860

Edited 1591643370
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
EDIT: If I run&nbsp; !sortta attacks traits On a black bear, pulled from the compendium, I get this: Which should be the expected result. Two questions: A) can you give me repo steps to recreate a condition where it is not working? and&nbsp; B) are you using the very latest version of the script? I have just submitted it for One Click installation as of yesterday, so it might be available tomorrow mid-morningish.
Hi Keith. I'm using version 0.3.0. This is my use case, which involves calling the script from a chat button. The regular !ta command works fine. The !sortta command does nothing when I select a monster token and run it on the monster. /w @{selected|character_name} &amp;{template:npcaction} {{rname=Create Token Actions}} {{description=[PC](!ta checks saves spells) | [Monster/NPC](!sortta attacks reactions spells traits checks saves)) | [Delete ALL Token Actions](!deleteta)--Caution!}}
1591648563
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I have installed freshly from the git version, just to make sure that I am running the same code. deleted all actions on the bear I was using as a test, run your chat menu as provided and clicked the Monster/NPC button. Here is the result, which looks correct. Can you A) run the script on a stock black bear, and b) If it works there, give me a test monster to try which doesn't &nbsp;work?
1591648745
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
One more possibility. Sortta specifically is ignored when using on a PC-formatted character. It only works on NPC statblocks. Could that be the issue?