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 .
×

Creating an API for the Sleep spell

<a href="https://gist.github.com/AKNeub/889775732c410a8c0f6cb6f9a0ada0e3" rel="nofollow">https://gist.github.com/AKNeub/889775732c410a8c0f6cb6f9a0ada0e3</a> The problem I have encountered, according to the Roll20 API are, } in line 21. The other issue I had was the API was doubling the number of spell slots expended. Anyone have any ideas?
Line 21 has two different kinds of single quote marks.&nbsp; ' versus&nbsp; `. &nbsp;Almost imperceptible but it'll make a difference.&nbsp; Try this: &nbsp; &nbsp; HpOutput+='{{Sleep = [[(${spellLevel}*2 + 3)d8]]}}'; What is the command you are using to call this? I'm guessing something like: !customSpellbook2 sleep 2
!customSpellbook2 Sleep ?{What Level Sleep|1|2|3|4|5|6|7|8|9} This is the macro used. When I choose to cast as a first level spell it sends the message,&nbsp; (From ChatSetAttr): Setting attributes Setting lvl1_slots_expended to 3 for character Bobby St. Kind. (From ChatSetAttr): Setting attributes Setting lvl1_slots_expended to 2 for character Bobby St. Kind. Is this because I am using&nbsp; ${spellLevel}*2 so it is going back and referencing line 15 twice? sendChat("API",`!modbattr --charid @{${charID}} --lvl${spellLevel}_slots_expended|-1`);
It looks like it is correctly attempting to subtract 1 from the spell slot.&nbsp; Did you adjust the script on line 21 like I suggested above?
I did, that corrected that issue. When I copied the "function" part of the API to a customSpellbook I grabbed from Nick Olivo the sleep spell doesn't subtract one from the spell slot twice.
1617342359

Edited 1617342449
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I would have thought both of those quote marks in line 21 should be back ticks, since&nbsp; ${spellLevel} &nbsp;is a template literal. It looks like you corrected it.