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] TokenAction creator v0.3.5 for the 5th Edition Shaped sheet v2.1.13+

1456884950

Edited 1458500734
Version 0.3.8: Fixed a script crash when running !ta with no options while a token linked to a journal is selected. (Thanks Thorsten!) Version 0.3.7: Fix for "prepared" spells option to prevent newly created, but unprepared spells from showing up as prepared. Added the "spellbook" option. This will whisper the character a list of "spell buttons" sorted by level. Clicking on the spell button will cast the spell from the characters sheet. Example: Version 0.3.6: Updated to support the Class Features section of the Shaped-Sheet 2.2.8+ (!ta --features) Removed "resources" as an option as this section was replaced by the Class Features section noted above Version 0.3.5: This script will automatically create ability macros that can be selected as a token actions from the Abilities & Attributes tab of the character journal. The following token actions can be created: Attacks Actions DELETE Class Features Initiative Lair Actions Legendary Actions Prepared Spells Reactions Saves Both chat buttons and query macros are an option for Saves Skills Both chat buttons and query macros are an option for Skills Spells Traits Syntax: !ta --option1, option2, ... Where the options can be any combination of actions, attacks, DELETE, initiative, lair, legendary, prepared, reactions, resources, saves, savequery, spells, skillquery, or traits. For example if I wanted to setup an NPC with token actions for initiative, saves (using the save query macro), actions and reactions, I would use the following command: !ta --initiative, savequery, actions, reactions There is one configuration option in the script (line 5): var showAsTokenAction = true; Setting true will automatically enable any newly created token actions. Setting false leaves newly created token actions disabled. NOTE: Please note, the saves, savequery, skills, skillquery are now using the Shaped built in rolls. &nbsp;Please note that there are limitations to the save query macros as detailed by Kryx in his Shaped Sheet thread. IMPORTANT: The DELETE option must be executed in all capitals as a small safeguard because it will remove ALL Abilities on the Attributes & Abilities tab of the selected token. Syntax example: !ta --DELETE Script: <a href="https://raw.githubusercontent.com/beeke01/TokenAct" rel="nofollow">https://raw.githubusercontent.com/beeke01/TokenAct</a>... Thank you to The Aaron and Kryx for their assistance and feedback! Thank you Filip Č for adding skills to the script! Thank you Saevar L. "Liquid-Sonic" for the suggestions!
1457910374

Edited 1458049619
Version 0.3.6: Updated to support the Class Features section of the Shaped-Sheet 2.2.8+ &nbsp;(!ta --features) Removed "resources" as an option as this section was replaced by the Class Features section noted above
Prepared spells doesnt seem to do anything, just chugs out that it was an error :&lt;
Can you please provide more details? I tried to reproduce the problem with a quick test, but couldn't. &nbsp;Also, see if you can toggle prepared on and off... I wonder if newly created spells simply don't set the "is prepared" flag by default.
When adding a new spell via the compendium the prepared flag is not enabled by default, therefore it is undefined and ignored when trying to enable it, so this is expected behavior. I even tried to add a Lich (which will only add the spell names and toggle the prepared spells to on, but not fill in any other details) and this works as expected.
I'll try fiddling with some stuff to see whats going on here then.
1458342817

Edited 1458343178
Thorsten
KS Backer
With 0.3.6, I've encountered a few oddities. I'm not sure what's needed exactly to reproduce. I'm happy to make a copy of the campaign and invite you to it for testing. This is with shaped 2.2.14 and was present with earlier versions as well. Edit: I think I figured out prepared. This must have been because of imported spells. Toggling prepared on and then off on the spell fixed it. On one of the characters, using !ta --prepared creates token actions for spells, marks the prepared spells as active, but then also marks some spells as active that are not prepared. Note some, not all. I have no clue right now as to what the cause might be. On that same character, token actions for spells do work, but they output this error to chat first: No attribute was found for @{Thalu Ixaghath|extas_var} I can't find a reference to extas_var in the script, which makes this puzzling. The spells cast directly from the sheet don't show that error.
Thorsten, yes please invite me to the campaign copy. &nbsp;I have a game tonight, so won't get the chance to look at it until tomorrow.
@Thorsten - The extas_var seems to be an artifact of the sheet itself see the notes from Kryx on his sheet: 2.2.6 ... ... "extras_toggle" previously had a typo and was named "extas_toggle". I have renamed it and I go through every attack, action, and spell to ensure it stays toggled as before. Try toggling the "Extras" toggle for the spells to see if that clears it up. &nbsp;I don't think this is a script issue though.&nbsp; I will see what I can do with the "prepared" spells option, but this is likely very limited because again if the toggle hasn't been flipped to the proper position, it won't enable the token action macro and by default I believe all imported spells start out as not prepared.
Kevin, you are one smart cookie. I made a debug copy but no need for you to check it. So yes, that's exactly what it was. This player had created emotes for most of his spells, which are in extras. The extras toggled off during one of the sheet upgrades. Toggling them back on again resolved the "extas_var" errors. So with the prepared spells option, it seemed like spells that are NOT prepared (and likely have never been toggled to be prepared) are in the list of prepared spells as far as ta is concerned. I'll play with that on the debug copy and see whether that's true. If that is true, then it might just be a case of your script treating "can't find the prepared value" as "is prepared" instead of "is not prepared". If that doesn't hold and I can't reproduce, then I'll just chalk it up to another artifact of going through shaped versions over a few weeks and the spells ending up a bit odd as a result. I can live with toggling enabled to fix it, as long as I don't have to do that again going forward.
1458419593

Edited 1458419644
Thorsten B. said: So with the prepared spells option, it seemed like spells that are NOT prepared (and likely have never been toggled to be prepared) are in the list of prepared spells as far as ta is concerned. I would like to clarify one thing, the "prepared" option does two things, first it creates ALL spells in the spellbook as token actions, however it only enables the token action for the spells that are marked as prepared. I think I figured out what the problem was here, definitely a case where spells are added to the sheet for the first time, the "is_prepared" flag is undefined, so I would take not reset the token action flag and if showAsTokenAction = true the new spells would appear as enabled. &nbsp;I added an additional check that I think should prevent this issue. &nbsp;Note though it will not prevent the API console log from generating errors as those messages are coming from Roll20 when attempting to call getAttrByName on a field that is using a default sheet value. I will push this fix along with another enhancement shortly.
1458420227

Edited 1458420241
Version 0.3.7 Fix for "prepared" spells option to prevent newly created, but unprepared spells from showing up as prepared. Added the "spellbook" option. &nbsp;This will whisper the character a list of "spell buttons" sorted by level. &nbsp;Clicking on the spell button will cast the spell from the characters sheet. &nbsp;Example:
Yeah, I understand how --prepared works, and that's as desired: All created, but only prepared checked as token actions. Thank you for pushing out a fix so quickly! That spell book looks sweet! I'm assuming that will only output prepared spells to chat, as well. Looking forward to the code being on github.
Code is up there now. &nbsp;Yes the spell buttons are the same as casting the spell on the sheet.
1458441276

Edited 1458441721
So for casters that don't technically need to have spells prepared, do the spells need to be marked as prepared for the !ta --spellbook to work? &nbsp;I tried this with a sorcerer (PC) and mage (NPC-wizard) in my game and I got this:&nbsp; (GM)Either an incorrect option was specified or there are no token actions to create for the specified option(s)
The spellbook option is not dependent on prepared spells. &nbsp;This specific message only comes up in one place in the script, not certain how you could have gotten there with the spellbook option, because basically the array updateMsg would have to be blank... &nbsp;Can you send me an invite or provide a way to reproduce?
I tried to reproduce this by creating an NPC Mage via the compendium, then dragging all of the spells in that I could (Counterspell and Firebolt were essentially blank, which is why Counterspell shows where it does in the screenshot). &nbsp;I linked it to a token, selected the token and ran only !ta --spellbook: This seemed to work well for me, so I must be missing something.
I don't think the code is up there. All I see is the 0.3.6, which would explain why Kaelev got an error.
That spellbook... My god... Sorry, you are my new god. ALL HAIL ALL-MIGHTY KEVIN!
Thorsten B. said: I don't think the code is up there. All I see is the 0.3.6, which would explain why Kaelev got an error. D'oh... I am very sorry, it does seem I forgot to push the latest, will try to get that done early this morning.
Ok, changes should be there now, sorry for the troubles! &nbsp;Let be know how it works for everyone.
That spellbook is sweet! Is it possible for it to be reactive to the filters that are active on the spell tab, or the currently prepared spells, even if optional to its function? Calling !ta without arguments crashes the API sandbox. I think it's meant to print out usage instead. Spinning up new sandbox... "vision 0.002 ready" "TokenAction v0.3.7 is ready! Designed for use with the 5th Edition Shaped v2.2.14+ character sheet!" /home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1 orts, require, module, __filename, __dirname) { function g(a){throw a;}var j=v ^ TypeError: Cannot call method 'split' of undefined at handleInput (evalmachine.&lt;anonymous&gt;:910:32) at eval (
I will look at the crash, that definitely shouldn't happen, so sorry for the trouble. I can look at making a "prepared spellbook" option. &nbsp;There is no way to make it dynamic like the sheet, so I don't think it is a good idea to break it down by the filters.
Version 0.3.8: Fixed a script crash when running !ta with no options while a token linked to a journal is selected. &nbsp;(Thanks Thorsten!)
Kevin said: There is one configuration option in the script (line 5): var showAsTokenAction = true; Setting true will automatically enable any newly created token actions. Setting false leaves newly created token actions disabled. I'm not understanding the use of this feature. I have tested it, it truly does not show any token actions I create while enabled, I just can't figure out why I would want to enable that. Am I missing somethig here?
@Brunhine - can you please provide a bit more detail about how you are using the script? &nbsp;One important fact is that after you run the command you need to click off the token then back on the token to see the created token actions. &nbsp;Also if the character sheet is already open, you need to close it and reopen it to see the abilities appear on the character journal. Basic operation is to select the token, run the command to create the token actions, then click off and on the token. &nbsp;If showAsTokenAction = true; is set then all of the token actions you created will be enabled by default (on the character journal, attributes & abilities tab).
Thanks for the rapid fix! With the spellbook being static - I can see why it is - I don't think having it show just prepared spells is all that useful, actually. I can see both sides I guess. What I'm saying is, don't put effort into that on my behalf. If others feel strongly about it and it becomes a thing, that'd be different.
Kevin said: Basic operation is to select the token, run the command to create the token actions, then click off and on the token. &nbsp;If showAsTokenAction = true; is set then all of the token actions you created will be enabled by default (on the character journal, attributes & abilities tab). Yep, this is exactly how I was using it. and when I set it to false, the token actions didn't show up. I was wondering why you would want that. Then you responded... I had no idea it worked by adding to the abilities that way. Now it makes sense. If you want to create the abilities on that tab, but not necessarily make them into token actions. So, please disregard. I just didn't fully understand what was going on. now I do!
Ok, glad it is clear now. &nbsp;If you have any trouble or suggestions on improving it, please let me know.
Kevin said: Ok, glad it is clear now. &nbsp;If you have any trouble or suggestions on improving it, please let me know. I would maybe just add to the instructions in the OP on how to re-enable/disable the token actions through the character sheet for future dullards like me.&nbsp;
1458614773
Falcon
Pro
Sheet Author
Kevin, This may be a stupid question but can't you just drag the items you put in the attribute section down into the macro bar? &nbsp;What advantage would this give you? &nbsp;Am I not seeing it? &nbsp;It works great, just trying to understand the value.
1458614867

Edited 1458615111
Falcon
Pro
Sheet Author
Ok - the spellbook alone is worth it!! &nbsp;Especially for NPCs. &nbsp;Awesome!!!!!!! is there a possibility of adding NPC attacks?
Npc attacks are already there, simply use the --actions option. As far as value, token actions are associated with the specific token, where as the macro bar is limited. &nbsp;Could everything here be done manually, sure, but it's meant to quickly make token actions, so it's much more of a GM tool than anything.
1458617824

Edited 1458617875
Falcon
Pro
Sheet Author
Ahh - it's --actions not --attacks. &nbsp;Makes sense - sorry kevin. &nbsp;Ok - I see the value. &nbsp;The spellbook is probably the most awesome thing ever though.
1459742850
Tim
Pro
Sheet Author
Compendium Curator
Hey thanks for this script, it's a life-saver. I'd add a +1 to a "spellbook-prepared" option or similar. The cleric's spellbook is extremely unwieldy by level 5, and being able to create a condensed version would be awesome. I don't mind having to delete his token actions and recreate them every time he changes his prepared spells (it only happens every 2-3 sessions for us anyway).&nbsp;
Tim, I will look into it, but the next couple of weeks are a bit tough for me (lots of work cutting into my fun time), so not sure when I will be able to get to it.
1459810867
Tim
Pro
Sheet Author
Compendium Curator
Hey thanks Kevin, that's awesome - no pressure though.
Kevin, I'm using your script, absolutely love it. I experience significant lag with the new shaped sheet (as GM) but I like all the features so my work around is to have as few sheets open as possible for the encounters and this script lets me do just that. However, Kryx's updates with merging the Class Features with Traits has broken that part of your script. I use traits in the command now but you might want to look at updating the script.
1460474361

Edited 1460474394
Kryx
Pro
Sheet Author
API Scripter
Kevin's script is being incorporated into the shaped companion script so the work will be handled there. You can access traits already (see the button on the settings page). Other PC features are soon to come. Can you make a post on my thread about the lag? I'd like to know what situations you encounter it - what processes you're doing. Is the window popped out? Is it during a peak roll20 time? Overall using the sheet should be cause next to zero lag. Editing requires some processes to run, but for the most part they are smooth for me.
OK. In the meantime, I'll be sticking with what works for me. The whole point is to have token action macros for my critters so I can run them without opening sheets.
1460480394
Kryx
Pro
Sheet Author
API Scripter
He's not going to update this script to match the new sheet because this script is being depreciated. You can access NPC traits and actions via the buttons on the sheet via chat macros. Otherwise you'll have to use this script&nbsp;as is or upgrade the script. I think token actions are there for NPCs on the new script as well - they are definitely there for PCs.
1460485719
Falcon
Pro
Sheet Author
Ok - let me just confirm. &nbsp;The script that creates token actions is being moved to the companion API and therefore I can get rid of that one and only have one API for your character sheet?
1460486065
Kryx
Pro
Sheet Author
API Scripter
The new companion script can already make token actions. So yes, you can only have that one script.
1460499340
Falcon
Pro
Sheet Author
Kryx said: The new companion script can already make token actions. So yes, you can only have that one script. So it includes the spellbook and other capabilities that this script offers. - so this entire script is being depreciated? Same commands?
Sorry, back after a business trip. &nbsp;Lucian and Brunhine are looking to include all of the options. &nbsp;The commands will change (see the shaped-support script thread for details). &nbsp;I am not certain that the spellbook option is complete yet, but Lucian had plans to make handling spells/spellbook even better. The intention is to deprecate this script once all options are in the shaped-support script.
1460743871
Kryx
Pro
Sheet Author
API Scripter
Spellbook is something I plan to add to the sheet soon. Though I, like you and Lucian, have been very busy lately.
1460744458
Falcon
Pro
Sheet Author
Having it both places would be good. &nbsp;But the fact that I don't have to go into the sheet and pick spells is absolutely awesome and extremely useful.
1460744507
Kryx
Pro
Sheet Author
API Scripter
The script would reference the sheet like it does for saving throws, ability checks,&nbsp;traits, npc actions, etc.