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 .
×
Our team is currently investigating rolling service outages. For more information, visit our most recent Forum Announcements post.
Create a free account

Spellbook Macro Migraine

Hi Everyone.  I'm trying to create a Spellbook Macro.  As a test, I copied the text string after casting AbsorbElements, %{-M38iaeJBoxmxZSJGFh8|repeating_attack_-M8qbjmhumwe2jIhbMgU_attack}, and then created a macro called AbsorbElements by placing that text in the macro. Works great!  Then I created a macro called Spells with this text &{template:default} {{name=Spells}} {{Spells= [AbsorbElements](!
#AbsorbElements)}} which I hoped would call that spell when I click on the button that shows up, but what I get after clicking the pink button is simply #AbsorbElements I was hoping to create a spellbook this way so players could call up their spells as one block of choices, rather than creating individual macro buttons that are sprawled across their screens.  I'm not completely savvy on macros (obviously) so any help greatly appreciated. It's ok, imagine you're talking to a 5 year old....or a 55 year old. Both are accurate.
1593136660
GiGs
Pro
Sheet Author
API Scripter
When you get the text in the button like that, it means the macro isnt being detected properly. Have you saved it and made sure the name is accurate?
1593137615

Edited 1593137766
I am new to macro's, so I am sure there is a better way.  But this is how I did it. (need to select token first) Also need to ensure the first spells listed in the spell book are the ones that are prepared. (I couldnt work out how to select the prepared bit in sheet.) &{template:default}{{name=@{selected|character_name} Spellcasting }}{{ Spell DC @{selected|spell_save_dc} = +@{selected|spell_attack_bonus} to hit with spell attacks }}{{ 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) }}{{ 1st (Slots) @{selected|lvl1_slots_expended}|@{selected|lvl1_slots_total} = [@{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) }}{{ 2nd (Slots) @{selected|lvl2_slots_expended}|@{selected|lvl2_slots_total}= [@{selected|repeating_spell-2_$0_spellname}](~selected|repeating_spell-2_$0_spell) [@{selected|repeating_spell-2_$1_spellname}](~selected|repeating_spell-2_$1_spell) }}
Hi GiGs, I've deleted and re-input both, but still getting just text.  Really baffling, but thanks for the advice!
Thanks, Marcel!  If I can't crack this nut (now it's personal :), I'm adopting your kind offer!  
1593144575
GiGs
Pro
Sheet Author
API Scripter
Dave R. said: Hi GiGs, I've deleted and re-input both, but still getting just text.  Really baffling, but thanks for the advice! Is the case identical? AbsorbElements, not absorbelements, for example? Can you take a screenshot of your macros tab?
Here you go...
1593146441
GiGs
Pro
Sheet Author
API Scripter
Have you closed the AbsorbElements macro yet? If you have the edit window open, and havent explicitly saved it (clicking the tick arrow, or closing the macro), it wont be detectable by the the button when you click it.
Yes, I just opened them to take the screenshot.  Crazy, right?
1593147409
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Are those macros (journal tab) or Abilities (character sheet)?
1593147795
GiGs
Pro
Sheet Author
API Scripter
In other words, are they saved here:
I have them saved in the Attributes & Abilities section of the specific character sheet I'm doing the spellbook for.
1593152793
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
If the calling ability is on another sheet try this: [Absorb Elements](~ NAME-OR-ID-OF-SHEET |AbsorbElements) If it is on the same sheet, you can use this: [Absorb Elements](~AbsorbElements) Personally, I'd recommend Marcel's solution. It's much simpler and only requires one global token macro for the entire campaign. You can find more info in this thread , and specifically, this post .
1593153762
GiGs
Pro
Sheet Author
API Scripter
Just to clarify: Abilities on a character are different from Macros. They work the same way, but you need to use different syntax (as shown above) to access them.
Thanks, Everybody!
Marcel, I notice that in your image, the spell slots have been ticked off.  How is that happening?  And a more global question (that I'm sure is a bridge too far), Is there a way to code it so that when I click on the spell, it brings up the spell description, and has a cast button within or at the bottom of that?
and one more snag.  When I create this, which I think should just be calling the PC's cantrips, and click Eldritch Blast, it instead calls Witch Bolt (image below) &{template:default}{{name=@{selected|character_name} Spellcasting}}{{ Spell DC @{selected|spell_save_dc} = +@{selected|spell_attack_bonus} to hit with spell attacks}}{{ 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)}}
1593212865
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Have you switched which character/token is selected in between running the Spells macro and clicking the Eldritch Blast button?
Yes. The character has Witchbolt as a first level spell, but I only have the cantrips specified in the macro so I'm confused why it's pulling that spell
1593221228
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Given the phrasing of the question and answer, you have two characters? A macro character and the PC? If so, the definition of selected changes when the button is pushed. It takes the definition of selected from the currently selected token, not the token from the time the macro was last run. More likely, I'm not understanding your setup, nor the reason for doing it this way.
1593229619
Oosh
Sheet Author
API Scripter
You can change your code a little to this format: {{ Cantrips = [@{selected|repeating_spell-cantrip_$0_spellname}](~ @{selected|character_name} |repeating_spell-cantrip_$0_spell) [@{selected|repeating_spell-cantrip_$1_spellname}](~ @{selected|character_name} |repeating_spell-cantrip_$1_spell)}} Which will ensure that the spellbook buttons thrown into the template will continue to link to the same character even if you select another token. This avoids the situation Keith has outlined - it's good for spellbook macros since they are 100% character specific. There's certainly nothing in the code that should be linking to any other spell, and it runs fine for me.
Sorry, let me try with a little more definition, and thanks for bearing with me. I’m the DM. I have 2 Player characters in the game; a wizard and a warlock. I placed the macro you see in the most recent image into the warlock’s abilities and attributes area of their character sheet, saved the macro, also saved it as a token action, clicked on that character’s token, tried to execute the  Eldritch Blast, and instead of an eldritch blast Result coming up, I get A result for witch bolt, which is a level 1 spell on the character’s sheet, but not in the macro, so it’s really confusing me as I’m still wrapping my head around macros. The wizard character has a much more robust list of spells from cantrips through 2nd level, also saved as a token action, and when I click on its token and execute the macro it works fine. 
Thanks, Oosh and Keith!  This is likely too complicated for me, but is  there a way to code it so that when I click on the spell, it brings up the spell description, and has a cast button within or at the bottom of that?
1593246935

Edited 1593246957
Oosh
Sheet Author
API Scripter
If you're setting these macros up for individual players, and saving them as Ability macros, you can get rid of the @{selected} calls. This makes it easier for the player to use, as they don't need to have their token selected when they run it. So: &{template:default}{{name=@{character_name} Spellcasting}}{{Spell DC @{spell_save_dc} = +@{spell_attack_bonus} to hit with spell attacks}}{{ Cantrips = [@{repeating_spell-cantrip_$0_spellname}](~@{character_name}|repeating_spell-cantrip_$0_spell) [@{repeating_spell-cantrip_$1_spellname}](~@{character_name}|repeating_spell-cantrip_$1_spell)}} will be a much better player macro, but will only work when saved as an Ability macro in their sheet. Dave R. said: Thanks, Oosh and Keith!  This is likely too complicated for me, but is  there a way to code it so that when I click on the spell, it brings up the spell description, and has a cast button within or at the bottom of that? Do you mean a DM version of the macro which brings up a list of the PC's spells, and automatic links to the compendium entries? So you can look up their spell list, and when you click on the link it will bring up the spell info instead of trying to cast it? I have a macro which does exactly this which I'm happy to share if that's what you're after.
Oosh, I’d love to see that! I’m being so myopic about the PC side, I never even considered that for the DM! What I was thinking though was a PC macro so they could bring up their Respective spell lists as a /w to themselves, and when they click on the spell name, it brings up the spell’s description, as you’ve described, but also contains a button that would allow them to cast the spell if they chose to. 
I've just gone in and exited & restarted the game, deleted the macro in the character sheet, exited and restarted the game again, created a new macro in the player sheet by typing it out and saving it, clicking on the appropriate character token, and yet still, whenever I click the Eldritch Blast button, I instead get results for his 1st level spell Witchbolt.  I think this is a game glitch at this point, perhaps something with my account specifically. I dunno. It's maddening haha, and I'm bitter, but not bitter enough to forget to thank you for all your efforts!
The below image is again, what's happening. I have the macro box open to show you the code, i have clicked the Eldritch Blast button, but it calls for me to choose a level, which is tied to Witch Bolt, and then kicks out a Witch Bolt result. AHHHGGGGGG!
1593278174

Edited 1593278316
GiGs
Pro
Sheet Author
API Scripter
There's an error in your code, though I dont know if its related. Each instance of: @{Gulmar Horadin} should be @{Gulmar Horadin|character_name} You can see in the screenshot, on the name row your name has come out wrong.
Thanks GiGs!
1593278454
GiGs
Pro
Sheet Author
API Scripter
Though honestly, if you're typing the character name, that's redundant, you should just do  Gulmar Horadin instead of @{Gulmar Horadin} What happens if you paste this directly into chat? %{Gulmar Horadin| repeating_spell-cantrip_$1_spell}
Made the change, but that didn't solve the issue, but thanks again!
pasting  %{Gulmar Horadin| repeating_spell-cantrip_$1_spell} into the chat gives me a result for Witchbolt
1593278666
GiGs
Pro
Sheet Author
API Scripter
Okay, so the problem is not with the chat menu, the problem is your character sheet. the witchbolt entry is in the  repeating_spell-cantrip_$1_spell attribute. Check over your spells.
1593281505
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Another potential point of confusion might be that repeating fields, like JavaScript start counting their lists with 0. 1 is actually the second spell in a series.
Here's his character sheet.
1593285351
GiGs
Pro
Sheet Author
API Scripter
That does look weird. It looks like the contents of the Eldritch Blast are the same as the Witch Bolt spell. Can you edit the spell and check it out? If you're the GM, feel free to send a PM to me to invite the game. Once I've joined, set me to GM, and I'll check it out first chance I get.
I just deleted the cantrips and spells, and re-added them by dragging from the compendium.  Now I get this result: Alas, I'm not well versed enough to see what the problem is.  Thanks for the suggestion!  I'll invite you shortly!
OK I went back to Marcel's macro as a token action, after replacing both spells, and now it seems to work fine!  To round out my understanding, Witch Bolt allows you to choose the level (which potentially changes the max damage), but Toll the Dead doesn't offer the option to ask if the target is damaged, which also potentially raises the damage.  Where can I see the actual coding for the spells being drawn from, and can I add lines to offer that option to Toll the Dead?
1593315215

Edited 1593315278
Oosh
Sheet Author
API Scripter
That one is actually a problem with Toll the Dead, they appear to have been pushed for time entering the drag & drop data and ignored a bunch of spells & items where they'd have to do custom entries. If you switch the output from SPELLCARD -> ATTACK Turn the description OFF (up to you... don't see why you'd want it spammed every time though) Make sure CANTRIP PROGRESSION is set to CANTRIP DICE. Set the DAMAGE field to: 1?{Is target damaged?|Yes,d12|No,d8} Assuming you generally use it on already-injured creatures, otherwise maybe switch the No,d8 to the first (default) option in the Query. And you should be good.
Thanks, Oosh.  We are all relatively new players so the big noob brainstorm was: a spellbook that players could access as a macro button on their screen that would whisper their spellbook only to them and, by clicking a spell's name, would allow them to whisper up the spell's description so they could make choices, but include a "cast" button at the bottom of each description, which if pressed would display the result in the general chat, if that was the spell they wanted to cast.  I had no idea how complicated it would be though. I'm getting quite the education, albeit slowly, and with no small difficulty heh.  I have to say though it's a great community of people willing to lend their expertise and experience.
1593329793

Edited 1593409634
GiGs
Pro
Sheet Author
API Scripter
Have you checked out universal Chat Menus ? it will let you autogenerate a menu for casting all spells pretty quickly, that is individually created for each character. If you're using DnD 5e, here's Keith's very comprehensive menus for it , by way of example. Edit:  fixed the above link, because roll20's autoformatting broke it.
Ok thats amazing(!), but a bit beyond me at this point.  It’s like reading a Stephen Hawking book: I read a paragraph over 5 or 6 times, it all becomes apparent for the briefest of moments, and then it’s gone again haha. Not being a technically inclined person in this way, while I find it super interesting, I swim further and further out after it, and then realize I’m WAY too far from shore!  But I’m gonna keep at it  thanks!  
1593410986

Edited 1593412371
GiGs
Pro
Sheet Author
API Scripter
The link I had to Keith's menus was broken. Try that again. You just need to install the script, and install those 2 macros of Keith's, and make the PC macro a token action visible to players, and you dont need to do any fiddling. But as a demonstration, here's a macro to show a character's spells. make you have the script installed first, then create this as a macro. Select a character who has spells and run the macro: !chatmenu @{selected|character_id} @{selected|character_name}'s Spells --title:Cantrips --repeating_spell-cantrip|spellname|spell --title:Lvl-1 --repeating_spell-1|spellname|spell|spellprepared --title:Lvl 2 --repeating_spell-2|spellname|spell|spellprepared --title:Lvl 3 --repeating_spell-3|spellname|spell|spellprepared --title:Lvl 4 --repeating_spell-4|spellname|spell|spellprepared --title:Lvl 5 --repeating_spell-5|spellname|spell|spellprepared --title:Lvl 6 --repeating_spell-6|spellname|spell|spellprepared --title:Lvl 7 --repeating_spell-7|spellname|spell|spellprepared --title:Lvl 8 --repeating_spell-8|spellname|spell|spellprepared --title:Lvl 9 --repeating_spell-9|spellname|spell|spellprepared 
Thanks GiGs!  So this is an API Script available in the Roll20 API Library (what's it called?)?  I add that, and then create the macros per character sheet?
reading this over I wonder if you guys can help me get only prepared spells to work for this ability "spells" /w @{character_name} &{template:atk} {{desc=**Cantrips:** [Acid Splash](~repeating_spell-cantrip_-M99Yx5HYzpGbLUzWdsL_spell) | [Fire Bolt](~repeating_spell-cantrip_-M6gWoGVkk1CnNHUWiUX_spell)| [Mending](~repeating_spell-cantrip_-M6gXoixyCZI9fjlobnj_spell) | [Message](~repeating_spell-cantrip_-M6gYgO2Qysqm6oetKej_spell) **1st:** [Burning Hands](~repeating_spell-1_-M6ggxWqsD0U5Slg-Wsb_spell) | [Chromatic Orb](~repeating_spell-1_-M6ga7RbmG92XISlToqB_spell) | [Detect Magic](~repeating_spell-1_-M6gcBKW2eoq92DKfr7-_spell) | [Expeditious Retreat](~repeating_spell-1_-M6gi2AHTpCcnDpuHpdU_spell) | [Ice Knife](~repeating_spell-1_-M6gihngsNKGubGjKKTZ_spell) | [Identify](~repeating_spell-1_-M6gcj2Rg7-UyAy7pl0r_spell) | [Magic Missile](~repeating_spell-1_-M6geTh6jBRz73RWuI9P_spell) | [Shield](~repeating_spell-1_-M6gkpY0BN4rDzc-DvGC_spell) | [Sleep](~repeating_spell-1_-M6glWgROSJiiOgSpJ1A_spell) | [Thunderwave](~repeating_spell-1_-M6gn1FHlXpgGK753r4J_spell) | [Witch Bolt](~repeating_spell-1_-M6gpgmqWcnnnKn0Z8km_spell) **2nd:** [Earthbind](~repeating_spell-2_-M6grblWLu0RNgNePZvb_spell) | [Hold Person](~repeating_spell-2_-M99dIIiiLACtbTyhZA1_spell) | [Misty Step ](~repeating_spell-2_-M9jqBN9OmusZrPjZvBQ_spell) | [Scorching Ray](~repeating_spell-2_-M6gsCJuia6b0dlrzsup_spell) | [Snilloc's Snowball Swarm](~repeating_spell-2_-M99c1BRetjGfKmgdzCO_spell) **3rd:** [Counterspell](~repeating_spell-3_-M99Yx5QyjX47bXSwVs-_spell) | [Fireball](~repeating_spell-3_-M99Yx5R7-bS2wzxXAVf_spell) | [Fly](~repeating_spell-3_-M99Yx5R7-bS2wzxXAVg_spell) | [Tiny Hut](~repeating_spell-3_-M99Yx5SecEZZ-iaXfZF_spell) }}
1593469366
GiGs
Pro
Sheet Author
API Scripter
Dave R. said: Thanks GiGs!&nbsp; So this is an API Script available in the Roll20 API Library (what's it called?)?&nbsp; I add that, and then create the macros per character sheet? Its not in the One-Click Library yet. That thread I posted above, the code is in the second post of that thread. Just copy it into your comapaigns API section as a new script. The link again:&nbsp;<a href="https://app.roll20.net/forum/permalink/7474530/" rel="nofollow">https://app.roll20.net/forum/permalink/7474530/</a>
GiGs said: The link I had to Keith's menus was broken. Try that again. You just need to install the script, and install those 2 macros of Keith's, and make the PC macro a token action visible to players, and you dont need to do any fiddling. But as a demonstration, here's a macro to show a character's spells. make you have the script installed first, then create this as a macro. Select a character who has spells and run the macro: !chatmenu @{selected|character_id} @{selected|character_name}'s Spells --title:Cantrips --repeating_spell-cantrip|spellname|spell --title:Lvl-1 --repeating_spell-1|spellname|spell|spellprepared --title:Lvl 2 --repeating_spell-2|spellname|spell|spellprepared --title:Lvl 3 --repeating_spell-3|spellname|spell|spellprepared --title:Lvl 4 --repeating_spell-4|spellname|spell|spellprepared --title:Lvl 5 --repeating_spell-5|spellname|spell|spellprepared --title:Lvl 6 --repeating_spell-6|spellname|spell|spellprepared --title:Lvl 7 --repeating_spell-7|spellname|spell|spellprepared --title:Lvl 8 --repeating_spell-8|spellname|spell|spellprepared --title:Lvl 9 --repeating_spell-9|spellname|spell|spellprepared&nbsp; When I install the 2 macros (Probability Control &amp; NPC) where am I installing the NPC code?&nbsp; I assume the Probability Control macro goes into each character's sheet under abilities?&nbsp; Thanks GiGs!
1593482176
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
It's much simpler to implement than that. Just to clarify, here are the steps: 1. Install the API script code for Universal Chat Menu on your campaign's API page. Here is a video that demonstrates how to do this manually if you have never installed a script before. Documentation (Can skip this for now, since you are installing premade macros) Post containing Script Code 2. Install the two macros . You do not have to do this on each character . Get the macro code from this post . Each macro has a link. Install them as macros on the Collections tab, not as character abilities. Make sure that the macros can be used by "All Players". There is a permissions box on the macro edit page that you may have to scroll down to see. Once each macro is saved, click the box for each to use them as Token Actions. This will ensure that whenever you select a token that represents a character the buttons for these macros will appear in the Token Action bar at the top of the VTT. Click the PC button when you have a PC token selected, or the NPC button when you have an NPC selected. The rest is magic.
Dave R. said: Marcel, I notice that in your image, the spell slots have been ticked off.&nbsp; How is that happening?&nbsp; And a more global question (that I'm sure is a bridge too far), Is there a way to code it so that when I click on the spell, it brings up the spell description, and has a cast button within or at the bottom of that? Hi Dave,&nbsp; The spell slots have to be manually ticked off in the spell sheet.&nbsp; There may be an API that does it, but I am only Plus, so i havnt looked into it.
1593488546
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The companion script for the&nbsp;D&amp;D 5th Edition by Roll20 Sheet will track spell slots.