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

Is there and API script (or macro) that can display the spell description for the last played spell?

I already use the spell-desc macro with the universalchatmenu.js. That works great, but to speed things up a bit when we are questioning a spells capabilities I would love to just hit a macro button that will populate the chat window with the description of last spell played, preferably public as we all like to have input. 
1612473370
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I don't think the system "remembers" chat messages. I.e. that info is not recorded anywhere in a retrievable manner.
1612473526
The Aaron
Roll20 Production Team
API Scripter
You'd have to write something that watches for the messages, then stores the previous one and allows you to call it back.  It wouldn't be too difficult, juts not aware of anyone having done it yet.
1612478768
Oosh
Sheet Author
API Scripter
That would rely on a bit of sheet-specific information, is this for 5e by R20?
1612479563

Edited 1612480153
Jordan C.
Pro
API Scripter
Just my two cents, but it seems you could also write something that turns the spell name into a macro button that outputs the spell's description. This is easy to do manually but would get very repetitive for many spells. For example: Where the range field is this: Touch }} {{rname=[Cure Wounds](`!
A creature you touch regains a number of hit points equal to 1d8 + your spellcasting ability modifier. This spell has no effect on undead or constructs.) Obviously you can change the format to be more appealing but this was more proof of concept.
1612506093

Edited 1612506281
Oosh
Sheet Author
API Scripter
Here's a really rough "is this what you mean?" script. It just spits the info out rather than being prompted, but that's easy to change. It only listens for atkdmg and dmg templates... I'm assuming there's already enough info on Spellcard templates that you don't want those? on('ready', () =&gt; { on('chat:message', (msg) =&gt; { log(msg.content); if (msg.rolltemplate &amp;&amp; msg.rolltemplate.match(/(dmg|atkdmg)/i) &amp;&amp; msg.content.match(/spelllevel=(c|\d)/i)) { log('Spell detected.'); let charName = (msg.content.match(/charname=([^}0{]+)/)) ? msg.content.match(/charname=([^}0{]+)/)[1] : false; charName = (charName) ? charName : msg.who let char = findObjs({type: 'character', name: charName})[0]; log(char); if (!char) char = findObjs({type: 'character', controlledby: msg.playerid})[0]; if (!char) return log(`Cannot find character associated with ${msg.who}'s chat message`); //char = char[0]; let spellName = (msg.content.match(/rname=([^}]+)}/)) ? msg.content.match(/rname=([^}]+)}/)[1] : null if (!spellName) return log(`Couldn't find spell name.`); log(`spell name: ${spellName}`); let rxSpell = new RegExp(`${spellName}`, 'i'); log(`spell regex: ${rxSpell}`); let attrs = findObjs({type: 'attribute', characterid: char.id}); //&amp;&amp; a.get('current').match(rxSpell)) log(`Found spells: `); attrs = attrs.filter(a =&gt; a.get('name').match(/spellname/i)); attrs = attrs.find(a =&gt; a.get('current').match(rxSpell)); log(`Found spell: ${attrs}`); if (!attrs) return log(`Couldn't find ${spellName} on ${charName}.`) let spellRow = (attrs.get('name').match(/_([A-Z0-9a-z_\-]{20})_spellname/)) ? attrs.get('name').match(/_([A-Z0-9a-z_\-]{20})_spellname/)[1] : false; log(`got row ID: ${spellRow}`); if (!spellRow) return log(`Failed to find spellrow for ${spellName} on ${charName}`); let rxSpellDesc = new RegExp(`${spellRow}_spelldescription`); let spellDesc = findObjs({type: 'attribute', characterid: char.id}).find(a =&gt; a.get('name').match(rxSpellDesc)) if (!spellDesc) return log(`Couldn't find spell description`); spellDesc = spellDesc.get('current'); sendChat('SpellSpy', `&amp;{template:npcaction} {{rname=${spellName} Info}} {{description=${spellDesc}&lt;br&gt;[Compendium Entry](<a href="https://app.roll20.net/compendium/dnd5e/${spellName})}}`" rel="nofollow">https://app.roll20.net/compendium/dnd5e/${spellName})}}`</a>); } }); }); So I guess the question is.... is this what you mean? Apart from changing it so it stores the template rather than sends it to chat, and waits for someone to request it. It has a few cracks at figuring out who cast the spell, but if it's not in the template (from a custom macro) and the speaker is using their player name and controls multiple characters, it can fail. Not much to be done about that. Also it won't work for NPC's if you have nameplates turned off. And there's probably 1000 ways to throw errors.
1612536723

Edited 1612536828
Victor B.
Pro
Sheet Author
API Scripter
Combat Master could but I'd need to add something to it.&nbsp; It's been on my plan, just haven't done it.&nbsp; CM tracks the spells assigned to the PCs and NPCs and shows spell name and remaining duration of the spell when the PC or NPC is active in the turnorder.&nbsp; If I put a link on the spell name, I could display the spell description, as I'm already tracking that.&nbsp; The spell description comes from the OGL char sheet, so ultimately the compendium.&nbsp;&nbsp;
1612543660

Edited 1612543670
Jordan C.
Pro
API Scripter
Could you technically link the spell name to an API command and the spells repeating action, change the spell output to spell card temporarily when clicked (via API command), then change it back to its previous setting? That way you could utilize a lot of the sheet's/templates' current functionality and it would theoretically handle all spells dynamically if tied to the repeating action numbers.
1612742343

Edited 1612742503
Sorry, I am in the middle of moving so I get sidetracked easily...&nbsp; Although I think D&amp;D is my top priority, my wife thinks differently. I guess what I am thinking is how when you go into the chat box and press the up arrow it will output the last equation.&nbsp; I am wondering about that but for spell descriptions.&nbsp; Player casts spell, the group wonders about exact spell definition, bam! easy answer in the chat window for all to see. oosh, yes 5E roll20 sheet.&nbsp; I will try this and see, thanks!
Victor, embarrassed to say that I don't use Combat Master although just what you described sounds super useful.&nbsp; I am going to check it out now!&nbsp;