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

Spell Book Macro - Help automating

I have cobbled together this macro from various places on the forums and it basically does everything I want it to. It whispers a list of my current spells to me in chat so I can use them. That being said I have to manually added lines for the number of spell for each spell slot. If it attempts to pull a spell that isn't there it will simply list the line of code. Is there a way to get it to ignore lines of code that pull an empty slot. /w "@{selected|character_name}" &{template:default}{{name=@{selected|character_name} Spellcasting }}{{ Spell DC: @{selected|spell_save_dc} = **Spell Attack Bonus:**  **@{selected|spell_attack_bonus}** }}{{ Cantrips: = [@{selected|repeating_spell-cantrip_$0_spellname}](~selected|repeating_spell-cantrip_$0_spell) [@{selected|repeating_spell-cantrip_$1_spellname}](~selected|repeating_spell-cantrip_$1_spell) [@{selected|repeating_spell-cantrip_$2_spellname}](~selected|repeating_spell-cantrip_$2_spell) [@{selected|repeating_spell-cantrip_$3_spellname}](~selected|repeating_spell-cantrip_$3_spell) [@{selected|repeating_spell-cantrip_$4_spellname}](~selected|repeating_spell-cantrip_$4_spell) [@{selected|repeating_spell-cantrip_$5_spellname}](~selected|repeating_spell-cantrip_$5_spell) [@{selected|repeating_spell-cantrip_$6_spellname}](~selected|repeating_spell-cantrip_$6_spell) [@{selected|repeating_spell-cantrip_$7_spellname}](~selected|repeating_spell-cantrip_$7_spell) }}{{ 1st (SLOTS) = [@{selected|repeating_spell-1_$0_spellname}](~selected|repeating_spell-1_$0_spell) [@{selected|repeating_spell-1_$1_spellname}](~selected|repeating_spell-1_$1_spell) [@{selected|repeating_spell-1_$2_spellname}](~selected|repeating_spell-1_$2_spell) [@{selected|repeating_spell-1_$3_spellname}](~selected|repeating_spell-1_$3_spell) [@{selected|repeating_spell-1_$4_spellname}](~selected|repeating_spell-1_$4_spell) [@{selected|repeating_spell-1_$5_spellname}](~selected|repeating_spell-1_$5_spell) [@{selected|repeating_spell-1_$6_spellname}](~selected|repeating_spell-1_$6_spell) [@{selected|repeating_spell-1_$7_spellname}](~selected|repeating_spell-1_$7_spell) [@{selected|repeating_spell-1_$8_spellname}](~selected|repeating_spell-1_$8_spell) [@{selected|repeating_spell-1_$9_spellname}](~selected|repeating_spell-1_$9_spell) [@{selected|repeating_spell-1_$10_spellname}](~selected|repeating_spell-1_$10_spell) [@{selected|repeating_spell-1_$11_spellname}](~selected|repeating_spell-1_$11_spell) [@{selected|repeating_spell-1_$12_spellname}](~selected|repeating_spell-1_$12_spell) }}{{ 2nd (SLOTS) = [@{selected|repeating_spell-2_$0_spellname}](~selected|repeating_spell-2_$0_spell) [@{selected|repeating_spell-2_$1_spellname}](~selected|repeating_spell-2_$1_spell) [@{selected|repeating_spell-2_$2_spellname}](~selected|repeating_spell-2_$2_spell) [@{selected|repeating_spell-2_$3_spellname}](~selected|repeating_spell-2_$3_spell) [@{selected|repeating_spell-2_$4_spellname}](~selected|repeating_spell-2_$4_spell) [@{selected|repeating_spell-2_$5_spellname}](~selected|repeating_spell-2_$5_spell) }} Looks Like:
I do this with a Character manager macro that doesn't handle spells.  I don't know if this will work for sure, but put in an empty spell named the same thing over and over again with the exact same data fields.  The Default Template for me takes all of those duplicates and puts them together as a singular entry.  Name the spell "End of list" or something like that, though it will be a functional spell button I suppose.  You could maybe use a naughty apichat button syntax on the button so it doesn't actually do anything when the player presses the key.  Heres what it looks like for me in my macro: Just make sure they never delete the empty spell entry with the name "End of List repeating X times in the spell level area but move them to the bottom constantly.  
1648573718
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Take a look at this thread . It should give you some pointers on hiding empty repeating items, or even just simply use the code as-is. Jarren did some superhuman work here.
Is there a version of that for PC's repeating actions section?
1648579695

Edited 1648579758
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
In the second post of that thread, but it looks to be part of an all-in-one, so it might require some teasing apart to get to the meat of choice. EDIT: Oh, PCs, not NPCs. Teasing and then flavoring, then. I.e. you can probably do ti with some search and replace of attribute names.
DM Eddie said: Is there a version of that for PC's repeating actions section? I've been working on a comprehensive version that will work for both PCs and NPCs, but I've had to put that project on hold for a bit recently with some IRL stuff. Part of the difficulty lies in how the 5E sheet is laid out when setup for NPC versus PC; some of the attributes are the same, and some are different, as well as configuration options.  An example: prepared spells and spells slots are definitely necessary to display for PCs, but perhaps not necessary for NPCs, as those are tracked on a character sheet basis, and not a token basis, so it wouldn't work to track spell slots for a 'mook' spellcaster NPC, but a named NPC it could make sense to do that.   So for spells, the NPC and PC spells section is identical, and it's just whether or not you want to display prepared spells or not.   For repeating sections, the NPC and PC sections are completely different.  A lot of the attributes are clearly based on how it was historically set up when character sheets were first introduced on Roll20, and I'm sure it would be done differently today if it were set up from scratch.   Unfortunately I don't have the repeating attacks portion set up yet. But the format is the same to call them (@{selected|repeating_attack_$0_atkname} and %{selected|repeating_attack_$0_attack}).
Does anyone know if there is a chatsetattr command or something to setup a one click button that just immediately "prepares" all of an npc's spells so that they work with the spells macro Jarren made?  I can't figure out what the attribute would be.  
1648598990
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I brute forced a macro a million years ago. It's just repeated CSA commands, so it's possible some might be skipped, but you can always just click it twice. Prepare All Spells Change all the 1s to 0s with a text editor to unprepare everything. There might be a way to use a meta script on this for better performance.
That will do thanks Keith
Jarren said: DM Eddie said: Is there a version of that for PC's repeating actions section? I've been working on a comprehensive version that will work for both PCs and NPCs, but I've had to put that project on hold for a bit recently with some IRL stuff. Part of the difficulty lies in how the 5E sheet is laid out when setup for NPC versus PC; some of the attributes are the same, and some are different, as well as configuration options.  An example: prepared spells and spells slots are definitely necessary to display for PCs, but perhaps not necessary for NPCs, as those are tracked on a character sheet basis, and not a token basis, so it wouldn't work to track spell slots for a 'mook' spellcaster NPC, but a named NPC it could make sense to do that.   So for spells, the NPC and PC spells section is identical, and it's just whether or not you want to display prepared spells or not.   For repeating sections, the NPC and PC sections are completely different.  A lot of the attributes are clearly based on how it was historically set up when character sheets were first introduced on Roll20, and I'm sure it would be done differently today if it were set up from scratch.   Unfortunately I don't have the repeating attacks portion set up yet. But the format is the same to call them (@{selected|repeating_attack_$0_atkname} and %{selected|repeating_attack_$0_attack}). I had a look at the linked post and I am just trying to wrap my brain around it. Currently the macro I have doesn't care about prepared vs unprepared spells and just pulls the spells from the sheet in numeric order. If I am reading the examples given shouldn't I be able to call my "SpellsMacro" from another macro "Spells" using the below and have it do what I want?  #SpellsMacro &{noerror} Currently it just outputs #SpellsMacro into chat not calling the actual macro.
1648646943

Edited 1648646966
Dustin T. said: Jarren said: DM Eddie said: Is there a version of that for PC's repeating actions section? I've been working on a comprehensive version that will work for both PCs and NPCs, but I've had to put that project on hold for a bit recently with some IRL stuff. Part of the difficulty lies in how the 5E sheet is laid out when setup for NPC versus PC; some of the attributes are the same, and some are different, as well as configuration options.  An example: prepared spells and spells slots are definitely necessary to display for PCs, but perhaps not necessary for NPCs, as those are tracked on a character sheet basis, and not a token basis, so it wouldn't work to track spell slots for a 'mook' spellcaster NPC, but a named NPC it could make sense to do that.   So for spells, the NPC and PC spells section is identical, and it's just whether or not you want to display prepared spells or not.   For repeating sections, the NPC and PC sections are completely different.  A lot of the attributes are clearly based on how it was historically set up when character sheets were first introduced on Roll20, and I'm sure it would be done differently today if it were set up from scratch.   Unfortunately I don't have the repeating attacks portion set up yet. But the format is the same to call them (@{selected|repeating_attack_$0_atkname} and %{selected|repeating_attack_$0_attack}). I had a look at the linked post and I am just trying to wrap my brain around it. Currently the macro I have doesn't care about prepared vs unprepared spells and just pulls the spells from the sheet in numeric order. If I am reading the examples given shouldn't I be able to call my "SpellsMacro" from another macro "Spells" using the below and have it do what I want?  #SpellsMacro &{noerror} Currently it just outputs #SpellsMacro into chat not calling the actual macro. Well first of all I was using abilities and not macros, so I fixed that. I'll keep plucking away at it, but currently it is still displaying the code for empty spells lines.
keithcurtis said: Take a look at this thread . It should give you some pointers on hiding empty repeating items, or even just simply use the code as-is. Jarren did some superhuman work here. Your were 100% on point the Spell and Spell Macros work pretty much exactly how I want them to. I just need need to figure out how to get it to display my spell dc and spell attack bonus now.
1648650508

Edited 1648650606
Jarren said: DM Eddie said: Is there a version of that for PC's repeating actions section? I've been working on a comprehensive version that will work for both PCs and NPCs, but I've had to put that project on hold for a bit recently with some IRL stuff. Part of the difficulty lies in how the 5E sheet is laid out when setup for NPC versus PC; some of the attributes are the same, and some are different, as well as configuration options.  An example: prepared spells and spells slots are definitely necessary to display for PCs, but perhaps not necessary for NPCs, as those are tracked on a character sheet basis, and not a token basis, so it wouldn't work to track spell slots for a 'mook' spellcaster NPC, but a named NPC it could make sense to do that.   So for spells, the NPC and PC spells section is identical, and it's just whether or not you want to display prepared spells or not.   For repeating sections, the NPC and PC sections are completely different.  A lot of the attributes are clearly based on how it was historically set up when character sheets were first introduced on Roll20, and I'm sure it would be done differently today if it were set up from scratch.   Unfortunately I don't have the repeating attacks portion set up yet. But the format is the same to call them (@{selected|repeating_attack_$0_atkname} and %{selected|repeating_attack_$0_attack}). Is it possible to display more than 10 spells per slot level if you add additional lines into you "Universal macro for all NPC Spells" code?
Dustin T. said: Your were 100% on point the Spell and Spell Macros work pretty much exactly how I want them to. I just need need to figure out how to get it to display my spell dc and spell attack bonus now. The 'macro mule' version had code to show the Spell DC and Spell Attack bonus: SpellDCAtk Save **DC [[@{selected|spell_save_dc}]]** | Attack **+[[@{selected|spell_attack_bonus}]]** You'd just need to add that into the collections macro if you're going that route. Dustin T. said: Is it possible to display more than 10 spells per slot level if you add additional lines into you "Universal macro for all NPC Spells" code? Yep.  You just need to continue repeating the 'formula' past #9 for each spell level (the numbering starts with #0). Example for an 11th cantrip: [@{selected|repeating_spell-cantrip_$10_spellname} ](~@{selected|character_name}|repeating_spell-cantrip_$10_spell" style="display:none; display: block@{selected|repeating_spell-cantrip_$10_spellname|max};) Example for an 11th Level-1 spell: [@{selected|repeating_spell-1_$10_spellname} ](~@{selected|character_name}|repeating_spell-1_$10_spell" style="display:none; display: block@{selected|repeating_spell-1_$10_spellname|max};)