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

[5e OGL] Help with tricky part of spellbook macro

So I have this pretty awesome spellbook macro for my bard player credit to Scott C. and Michael M. in  this thread near the bottom. It pops up a chat window that links to the casting of his spells. This works perfectly for the bard, and would work fine for a sorcerer, or warlock. The problematic part is for the characters who prepare spells. I want to replicate this for the druid and paladin players in my group but add some functionality so that they can see what spells are prepared  through @{repeating_spell-1_$0_spellprepared}  and in the case of the druid, if it is a ritual he can cast through the attribute @{repeating_spell-1_$0_spellritual} So the first problem I have run into is that spellprepared returns a 1 or a 0. Is there a way I can take that input in the macro and output something based on it? I know you can do a roll query for a prompt but as far as I've found there isn't any other kind of conditionals with macros. Is there another way I can "tag" the spells based on the output of this attribute?  I have less of a problem with the ritual variable because it outputs Yes or No. At the worst, I can try and format the output of the spellbook like a table and just let it spit out yes or no for the ritual. Ideally, though, like the spellprepared I would like to output something specific as a result of the value in spellritual.  Here is a snippet of my macro code: @{wtype}&{template:atk} {{desc=**Cantrips** [@{repeating_spell-cantrip_$0_spellname}](~charname|repeating_spell-cantrip_$0_spell)  **First Level** [@{repeating_spell-1_$0_spellname}](~charname|repeating_spell-1_$0_spell) **2nd Level** [@{repeating_spell-2_$0_spellname}](~charname|repeating_spell-2_$0_spell) }}
I think just outputting the 0 or 1 next to the spell name would be helpful enough to determine if it's prepared. Without the use of the API any kind of conditionals are really difficult to parse.
I was afraid that would be the answer. I was trying to avoid getting into the scripting. If I did that I could just write a script that handled all of it. I'll probably just do the output for now.  Thanks!
1480964623

Edited 1480967251
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Glad to see people are finding the discoveries from that thread useful. Here's my idea for your question: Try making a rollable table for what you want output for. It would only have a single value. So for prepared, you'd make the following table: Table Name: Prepared Table Entry: Prepared Weight: 1 (but doesn't matter) The table entry can be whatever you want your preapred/ritual cast tag to be as long as it doesn't contain inline rolls, ability/attribute calls, or roll queries (basically anything other than plain text). Then do [[@{repeating_spell-1_$0_spellprepared}t[Prepared] ]]. If the spell's spellprepared attribute is 0 (unprepared, the rollable table won't roll (because it'll be [[0t[Prepared] ]]). If it is prepared, it'll roll once, and the only value it can return is whatever you put in that single table entry. Adjusting your sample macro code: @{wtype}&{template: npcatk } {{ description =**Cantrips** [@{repeating_spell-cantrip_$0_spellname}](~charname|repeating_spell-cantrip_$0_spell) **First Level** [@{repeating_spell-1_$0_spellname}](~charname|repeating_spell-1_$0_spell)&nbsp;[[@{repeating_spell-1_$0_spellprepared}t[Prepared] ]] [[@{repeating_spell-1_$0_spellritual}t[Ritual] ]] **2nd Level** [@{repeating_spell-2_$0_spellname}](~charname|repeating_spell-2_$0_spell) [[@{repeating_spell-2_$0_spellprepared}t[Prepared] ]] [[@{repeating_spell-2_$0_spellritual}t[Ritual] ]] }} Two notes about the above: The roll template result needs to be outside of the command button as the command buttons don't play nicely with inline rolls I've changed the roll template to the npcatk template because the standard atk template does nasty formatting on inline rolls in the desc field and the npcatk template is the only other template that does the nice formatting on the command buttons. More info on the various OGL roll templates (if you haven't checked it already; there are some minor updates that aren't in that forum post):&nbsp; <a href="https://wiki.roll20.net/5e_OGL_Roll_Templates" rel="nofollow">https://wiki.roll20.net/5e_OGL_Roll_Templates</a> Happy Rolling, Scott
Wow, thanks Scott!&nbsp; I had checked out the Roll Templates and have been learning how to use them. I decided since I have some new-ish players that are a bit overwhelmed with all of their abilities that I would make some macros to make their lives easier. I've been making damage and attack abilities for all of them. This spell book thing was just catching me.&nbsp; Your code works great! One additional question though. Is there anyway to have it ignore the roll on a result of zero? I'd like it to just show nothing rather than the zero hanging around.&nbsp;
1480970990

Edited 1480976507
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ah, good point. You'll need two rollable tables for each attribute (prepared and ritual). You'll name them the same, but they will have a 1 (prepared) or a 0 (unprepared) in them somewhere: That table entry for prepared-0 is just a space " ", but it works if you just leave the table entry field blank as well. Then, instead of doing [[@{repeating_spell-1_$0_spellprepared}t[Prepared] ]], you'll do this: [[1t[Prepared-@{repeating_spell-1_$0_spellprepared}] ]] This takes advantage of the dice engine's&nbsp; order of operations . This may result in an extra space being generated in your macro output, but should be less jarring than a random 0 hanging out. EDIT: You could also upload, or find on the web, an image that you want to use for a prepared, unprepared, ritual, and no ritualtag, and then use <a href="http://www.tinyurl.com" rel="nofollow">www.tinyurl.com</a> to give each of them an alias that would be different from the opposite choice by the number (e.g. <a href="http://tinyurl.com/1-prepared" rel="nofollow">http://tinyurl.com/1-prepared</a> vs.&nbsp; <a href="http://tinyurl.com/0-prepared" rel="nofollow">http://tinyurl.com/0-prepared</a> ) and then use the ability to place images into chat to put them after each spell's command button. @{wtype}&{template:atk} {{desc=**Cantrips** [@{repeating_spell-cantrip_$0_spellname}](~charname|repeating_spell-cantrip_$0_spell)&nbsp; **First Level** [@{repeating_spell-1_$0_spellname}](~charname|repeating_spell-1_$0_spell) [Prepared Tag]( <a href="http://tinyurl.com/@{repeating_spell-1_$0_spellprepared}-prepared" rel="nofollow">http://tinyurl.com/@{repeating_spell-1_$0_spellprepared}-prepared</a> #.png) **2nd Level** [@{repeating_spell-2_$0_spellname}](~charname|repeating_spell-2_$0_spell) [Prepared Tag]( <a href="http://tinyurl.com/@{repeating_spell-2_$0_spellprepared}-prepared" rel="nofollow">http://tinyurl.com/@{repeating_spell-2_$0_spellprepared}-prepared</a> #.png) }} An image size of 8px X 8px should be about right to fit in with the size of the roll20 chat font (not sure about with the template font size). The tinyurl would be the part before the "#.png", which is an html fragment and just tells the chat parser to display the image in chat instead of as a standard hyperlink. This would also let you use the atk template instead of the npcatk template so that the menu looks similar to the rest of the player's macros style wise.
Oh man, thanks so much! Everything worked wonderfully! Here is the final product: Kind of hard to see but the black spellbook is when they have it prepared, and the little black and white symbol, which is supposed to be a man teleporting but I thought it would work, represents when the spell is a ritual. Now I just need to add all the entries for the spells but that's just busy work.&nbsp; Code sample for those interested in repeating what Scott has helped me make:&nbsp; @{wtype}&{template:npcatk} {{description= **@{character_name}'s Spellbook** **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) [@{repeating_spell-cantrip_$2_spellname}](~@{character_name}|repeating_spell-cantrip_$2_spell) | [@{repeating_spell-cantrip_$3_spellname}](~@{character_name}|repeating_spell-cantrip_$3_spell) **First Level** [@{repeating_spell-1_$0_spellname}](~@{character_name}|repeating_spell-1_$0_spell) [Prepared Tag](<a href="http://tinyurl.com/@{repeating_spell-1_$0_spellprepared}-prepared#.png" rel="nofollow">http://tinyurl.com/@{repeating_spell-1_$0_spellprepared}-prepared#.png</a>) [Ritual Tag](<a href="http://tinyurl.com/rritual@{repeating_spell-1_$0_spellritualflag}#.png" rel="nofollow">http://tinyurl.com/rritual@{repeating_spell-1_$0_spellritualflag}#.png</a>) **2nd Level** }} For the other spells, you just have to change the $0 to $1. To go up a level you change the repeating_spell-1 to repeating_spell-2. Upload your icons to the web (I used TinyPic) and then use TinyURL to give them the correct URL. I used 0-prepared, 1-prepared, rritual, rritualYes. I also chose spellritualflag over spell ritual because when the box is checked spellritual returns "{{ritual=1}}" which was messing with the roll template by ending it early.&nbsp;
1480999871

Edited 1481000644
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Very cool Kenneth. I may have to make my next 5e character a caster just so I can play around with this. One question though; where do you set @{repeating_spell-1_$0_spellritualflag}? All I can find in the spell section of the sheet is spellritualflag, which as you noted is not really useful seeing as how it resolves to a template field, although spellritualflag is an existing attribute since it gives me an empty output when I call it. EDIT: hmm, it appears to be something that is edited when you drag and drop a spell from the compendium, but can't be edited either way from the sheet itself...annoying. EDIT the SECOND: Also, didn't mention it earlier, but props to you for making the game accessible for your players.
I'm going to have to save this for later, I like it!
1481006541
Silvyre
Forum Champion
^ +1, very creative!
Yeah, Scott I noticed that too when I went to set up Beast Sense for my Totem Barbarian player. It was a pain having to drag and drop another ritual spell and then change everything to the Beast Sense information.&nbsp; Thanks for the props, man. I've got a party of five people. One is experienced with DnD but the other four are new. I've noticed that they still take a second to find everything when I ask for saves or rolls, and even the more experienced player isn't used to the sheet yet.&nbsp; I'm hoping by making attack and ability macros they can just have the buttons there to press and do their rolls really easily and it will help everything run more smoothly. The whole spellbook was actually relatively easy compared to the nested roll query loops for the rogue's sneak attack and to handle critical hits. That was a pain. :D
1481230217

Edited 1481230797
I have something that I'm sure Scott helped me with, either directly or indirectly, for attack and spell actions that the player can use. /w "@{selected|character_name}" &{template:desc} {{desc= **Attacks** [Glaive](~Selected|{selected|repeating_attack_$0_attack}) [Dagger](~Selected|{selected|repeating_attack_$1_attack}) **Magics** [Fire Bolt](~Selected|{selected|repeating_attack_$2_attack}) [Magic Missile](~Selected|{selected|repeating_attack_$3_attack}) [Sleep](~Selected|{selected|repeating_attack_$4_attack}) [Shatter](~Selected|{selected|repeating_attack_$5_attack}) [Fireball](~Selected|{selected|repeating_attack_$6_attack}) [Faithful Hound](~Selected|{selected|repeating_attack_$7_attack}) [Lightning Bolt](~Selected|{selected|repeating_attack_$8_attack}) }} It has to be edited for each player and if things change then you have to mod it but my players love that I do this for them so it makes me happy to give them that. I also have this.&nbsp; /w "@{selected|character_name}" &{template:atk} {{desc=**Ability Checks** [Strength](~Selected|strength) **|** [Dexterity](~Selected|dexterity) **|** [Constitution](~Selected|constitution) [Intelligence](~Selected|intelligence) **|** [Wisdom](~Selected|wisdom) **|** [Charisma](~Selected|charisma) }} And. /w "@{selected|character_name}" &{template:atk} {{desc=**Physical Skills** [Acrobatics](~Selected|acrobatics) **|** [Athletics](~Selected|athletics) **|** [Steath](~Selected|stealth) **Social Skills** [Persuasion](~Selected|persuasion) **|** [Deception](~Selected|deception) **|** [Insight](~Selected|insight) [Intimidation](~Selected|intimidation) **Senses** [Investigation](~Selected|investigation) **|** [Perception](~Selected|perception) **Knowledge** [Arcana](~Selected|arcana) **|** [History](~Selected|history) **|** [Medicine](~Selected|medicine) [Nature](~Selected|nature) **|** [Religion](~Selected|religion) **Miscellaneous** [Survival](~Selected|survival) **|** [Animal Handling](~Selected|animal_handling) [Performance](~Selected|performance) **|** [Sleight of Hand](~Selected|sleight_of_hand) **-----------------------------------------------** **Tools** [@{Selected|repeating_tool_$0_toolname}](~Selected|repeating_tool_$0_tool) }}
I actually have a "menu" type thing that I copied and pasted from one of the threads that I'm planning on using. I have been making attack abilities for them to cover things like rage, sneak attack, divine smite, etc. I hadn't thought of integrating the two, but it might be EVEN better to add links directly to those abilities in the chat menu thing that way it is a one click thing.&nbsp; Thanks for the idea!! :)
When you finish that share it so I can see what you got going on. I am always looking for new ways to make it easier to play.
It's definitely still a WIP, and of course I'm having to customize it to my players, but if you want I'll make a long post detailing all the moving parts and how to make it. Maybe I'll make that a whole other post though.&nbsp;
OK, awesome but post a link to your amazing works here so I can find it.