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

Could one of you awesome script wizards tell me if this idea would be difficult to implement?

Hey everyone. Could one of you awesome script-wizards tell me if the following idea would be difficult to implement? This script here can activate itself whenever a spell is cast in roll20. <a href="" rel="nofollow"></a> So would it be possible to create a script that does the following? Whenever someone casts a spell, the script will detect the level of the spell, and then do the following... ...if the spell was 1st-level, input "#S1" into the chat, and press enter. ...if the spell was 2nd-level, input "#S2" into the chat, and press enter. ...etc... As you see, I need this script to trigger a different macro for each level of spell that is cast. Would this be difficult to implement?
The Aaron
Roll20 Production Team
API Scripter
Not terrible. The API can't execute macros, but it can load them and send the individual commands to chat. Any @{target} and @{selected} references can't be expanded. Other than that, it's just watching for the right events and parsing the text.&nbsp;
Thank you so much for replying! :-D Do you maybe have any suggestions for a better way to accomplish what I am trying to do? Here is what I am going for, btw: "if a level n spell is cast, then roll20 will automatically remove the correct amount of spell points for a level n spell". I would be most grateful if you have any suggestions :-)
You could attach a setattr API command to the spell to do that. I build all my spells in powercards and have it set up that way.&nbsp;
Here is an example. I bolded the line that reduces that caster's available spells. !power {{ --name|First Aid --tokenid|@{selected|token_image} --emote|** Lunitari's Idish, SHIRAK, Damen Du!** --leftsub|**R:** Touch **CT:** 1 **D:** Permanent **C:** VSM --?? @{selected|numspells_0} &gt; 0 ?? Effect:| When the caster lays hands upon a living creature, this minor healing spell magically bandages any wound on the creature’s body, preventing further loss of hit points from bleeding. It prevents infection, but cures no damage. --?? @{selected|numspells_0} &gt; 0 AND @{selected|Class} == Illusionist ?? Illusion Magic:| When cast by an Illusionist the recipient of the spell must make an intelligence saving throw. If the creature fails the saving throw, the spell acts normally. If the creature makes the saving throw, the spell fails as the creature realizes that the spell is an illusion. --?? @{selected|numspells_0} &gt; 0 ?? vfx_opt|@{selected|token_id} burn-holy&nbsp; --?? @{selected|numspells_0} &gt; 0 ?? vfx_opt|@{target|token_id} burn-holy&nbsp; --soundfx|_audio,play,nomenu|spell one --?? @{selected|numspells_0} &gt; 0 ?? api_setattr|_name @{selected|token_name} _mod _numspells_0|-1 _silent --Spell Inventory: |**@{selected|token_name}** has [[ @{selected|numspells_0} -1 ]] 0 level spell(s) remaining! --?? @{selected|numspells_0} &lt; 1 ?? Spell Failure:| You are out of 0 Level spells }}
Whoah! That powercards script looks AMAZING! And the powercards macro helper looks amazing too! Just wow... I cannot WAIT to dig into the documentation for those scripts, and create awesome stuff with them :-D Thank you so much for pointing them out to me! :-D
David M.
API Scripter
You may also (or instead?) want to check out the new(er)&nbsp; Scriptcards api script. It is based loosely on Powercards but has support for creating loops, functions (and function libraries), iterating through arrays of tokens to filter by properties/location, etc. Some of the more advanced features have a bit of a syntax learning curve, but if you have any kind of programming experience you may ultimately&nbsp;find it to be more intuitive. It is stable but also under active development so new features are getting rolled out all the time.
Even better! Thank you so much for pointing it out :-D