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] Macro/API question: any way to get a list of prepared spells?

I'm experimenting with macro development and I'm at a bit of a loss for how to accomplish my goal. I'm using the 5th edition OGL charactersheet. What I'd like is a token action button for each spell level that does the following: returns a list of all spells known by the sheet represented by that token that looks like this: "Select [[spellname]] from SelectedToken where SpellLevel=3 and SpellPrepared="yes" That list is put into a dropdown and/or a list of clickable links so the player can select what spell to cast Once the spell is selected, it interrogates a list of spell macros in a rollable table (possibly using  this script for the list of macros) to see if it can find a match on the spell name If it finds a match, it executes the macro at the appropriate spell level ideally, once it's done, it deducts one from spell slots available for the spell level. The goal here would be to create a single master list of spell macros that everyone could use, both PCs and NPCs. Once the macro is created once, everyone gets it without having to retype things. I'm pretty sure this would involve API work which I haven't done before, but I do have a software development background, so I could probably pick it up.  Any thoughts would be appreciated.
1512077040
Silvyre
Forum Champion
Using the PowerCards API Script, Craven wrote a macro for the 5e OGL sheet that only displays prepared spells. You can check it out here.
Now this looks promising! If I combine this with macro stacking, I might be able to pull most of this out of the character sheet and into separate macros that I can write once and run from any number of character sheets. Changes would only have to occur in one place. This may take me a bit to get up and running, but I'm liking where this is going so far. Thank you!
1514133484

Edited 1514149479
OK. Been doing some playing with this, and can I just say that I love PowerCards! The conditional statements are awesome! That said, one thing I'm trying to do that I can't figure out how to do is create generic macros that will work for all characters. The existing script example from Craven requires knowing the number of spells of a given level that you have and manually updating that list if the spell list changes. What I'm hoping to do is to update the list dynamically. So instead of deleting the lines that don't apply, I'd start them with a conditional statement instead. For example: --Level 1:| --?? selected|repeating_spell-1_ROWCOUNT > 0 AND @{selected|repeating_spell-1_$0_spellprepared} == 1 ?? !spell-1_$0| [@{selected|repeating_spell-1_$0_spellname}](~selected|repeating_spell-1_$0_spell) --?? selected|repeating_spell-1_ROWCOUNT > 1 AND @{selected|repeating_spell-1_$1_spellprepared} == 1 ?? !spell-1_$1| [@{selected|repeating_spell-1_$1_spellname}](~selected|repeating_spell-1_$1_spell) ... Let's say I put 50 of these lines per spell level. The first condition would only return true if the repeating_spell_1 repeating section had an element in the array for the spell. Otherwise it would be skipped. This would essentially auto update every time the macro was run, showing less or more spells depending on how the list changes. It would also allow me to use it for NPCs so I could have one macro that all NPCs would use regardless of how many spells they had of what level. The only problem is I don't know how to find the ROWCOUNT of a repeating section within a macro. Does anyone know of a way? If not, I could dig into exposing this through the API, as I can use the array.length property I assume, but I'm not 100% sure if I can pass a repeating section as a parameter to the API. Any thoughts on this would be appreciated.