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

How to remove a spell slots (via ogl companion spell tracking) while using scriptcards

Newbie question - first time using ScriptCards - just using it for magic missile. I have a script that is working but it is not removing a spell slot from the character sheet. I have the tracking spell slots on, if I do it manual, it removes a spell slot, but when using scriptcard, it doesn't deduct a spell slot.


This is the code I am using from the scriptcard wiki

!scriptcard  {{ 
  --#title|Magic Missile
  --#sourceToken|@{selected|token_id}
  --#targetToken|@{target|token_id}
  --=MissileCount|?{Spell Slot Level?|1|2|3|4|5|6|7|8|9} + 2
  --=DisplayCount|1
  --=MissileDamage|0
  --#leftsub|Slot level ?{Spell Slot Level?}
  --#rightsub|Ranged Attack
  --#emoteText|Fred uses a level ?{Spell Slot Level?} spell slot to fire [$MissileCount.Total] missiles of magical force!
  --:MissileLoop|
  -->FireMissile|
  --=DisplayCount|[$DisplayCount] + 1
  --?[$DisplayCount] -le [$MissileCount]|MissileLoop
  --+Total|Total damage is [$MissileDamage]
  --X|

  --:FireMissile|
  --=ThisMissile|1d4 + 1
  --=MissileDamage|[$MissileDamage] + [$ThisMissile]
  --+Missile|[$DisplayCount.Total] Hits for [$ThisMissile] [b]force[/b] damage
  --<|
}}

April 02 (1 week ago)
David M.
Pro
API Scripter

Scripts will not trigger other scripts unless they both are set up to "talk" to each other. The solution is to add spell slot deduction into your Scriptcard macro. This can be done either with a call to the ChatSetAttr script or by using the direct object modification capability within Scriptcards.

This example on the wiki shows using the external script call (ChatSetAttr) method. Search for "--:DeductSpellSlot"

This section of the wiki describes direct object modification. I think this would be the preferred methods since it doesn't rely on dependencies. I don't have any examples handy atm, but they're out there or you could ask on the Discord channel.