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

DC20 Macro Help, Macro to add/subtract number status icons from a token?

So I'm planning to jump from D&D to DC20 when its fully released. I feel like a very useful macro for playing on Roll20 would be a macro to help with tracking your Action Points (especially for a DM with multiple creatures to track). The macro I had in mind would do the following but maybe someone who is profficent with creating the macro script could help,

-Load up status effect icons of numbers 1-10 to your game
-Create the macro script

How it Works
-Select token
-Click macro button
-Macro asks reduce or increase Action Points?
-Macro asks by how much?
-Hit enter, and the token selected displays the appropriate number status effect on it.

Any help with this would be appreciated!

March 12 (2 days ago)
timmaugh
Pro
API Scripter

This can be done with TokenMod and the MetascriptToolbox. But before I work up an example, I have to ask some questions...

I believe you are saying you'd have custom statusmarkers that represent 1-10 (rather than values applied to existing statusmarkers where the number indicates the level). Is that correct?

Also, what happens if the player tries to add/subtract a number of points where the result would be out of bounds of the 1-10 (or 0-10, if you would allow removing the statusmarker altogether)? Do you want to enforce the bounding... so that 2 points minus 4 would be a 0 (ie, remove the statusmarker)?

While what you're describing can be done with mod scripts... why not just use token bars?

I mean as long as the token can display the number I suppose it doesnt have to be a status effect, just seemed like the easiest route. But yeah I have 10 number status effects from 1-10 setup in the game. Yeah putting a boundry of 0 for lowest and 10 for highest would probably be easiest.

timmaugh said:

This can be done with TokenMod and the MetascriptToolbox. But before I work up an example, I have to ask some questions...

I believe you are saying you'd have custom statusmarkers that represent 1-10 (rather than values applied to existing statusmarkers where the number indicates the level). Is that correct?

Also, what happens if the player tries to add/subtract a number of points where the result would be out of bounds of the 1-10 (or 0-10, if you would allow removing the statusmarker altogether)? Do you want to enforce the bounding... so that 2 points minus 4 would be a 0 (ie, remove the statusmarker)?





Tuo said:

While what you're describing can be done with mod scripts... why not just use token bars?


I use the token bars for HP/AC/TempHP, sometime elevation or stealth score

March 12 (2 days ago)
timmaugh
Pro
API Scripter

OK, so two more questions:

1) what are the names of the status markers you would use? (If you don't know, you can run the TokenMod help:

!token-mod --help

...and find the section that lists all of the statusmarkers in the game along with their names.

2) Is this a Jumpgate game?

1- Do you need the numbers too or just the names? Example, Buff-1::5875985
2-Yes it would be Jumpgate

timmaugh said:

OK, so two more questions:

1) what are the names of the status markers you would use? (If you don't know, you can run the TokenMod help:

!token-mod --help

...and find the section that lists all of the statusmarkers in the game along with their names.

2) Is this a Jumpgate game?




March 12 (2 days ago)
Gauss
Forum Champion


DM Deadman said:


Tuo said:

While what you're describing can be done with mod scripts... why not just use token bars?


I use the token bars for HP/AC/TempHP, sometime elevation or stealth score


Same here. HP, AC, and TempHP for my groups.

Although for elevation I use the token markers and for Stealth scores I use a macro that whispers them to me. 

March 12 (2 days ago)
timmaugh
Pro
API Scripter

OK, I think this is what you need. I can't fully test it because I don't have a marker analog to your "Buff-1", "Buff-2", etc., but if this doesn't work, I'll try to create an analog and figure out what's going wrong.

To make this work, you need TokenMod, the Metascript Toolbox, and the set of markers named Buff-1 through Buff-10. What should happen is that the old statusmarker should be removed and the new one (based on the math) should be added. If the math renders a 0, then no marker should be added.

Let me know if this works, or if you want an explanation for what is going on:

!{{
  {\&global ([globCur]{&if @(selected.is.Buff-1)=yes}1{&elseif @(selected.is.Buff-2)=yes}2{&elseif @(selected.is.Buff-3)=yes}3{&elseif @(selected.is.Buff-4)=yes}4{&elseif @(selected.is.Buff-5)=yes}5{&elseif @(selected.is.Buff-6)=yes}6{&elseif @(selected.is.Buff-7)=yes}7{&elseif @(selected.is.Buff-8)=yes}8{&elseif @(selected.is.Buff-9)=yes}9{&elseif @(selected.is.Buff-10)=yes}10{&else}0{&end})}
  {\\&global ([globNew]{\&math ?{Add or Subtract|Add,min|Subtract,max}(globCur{&if ?{Add or Subtract}=min}+{&else}-{&end}?{By How Much|1|2|3|4|5|6|7|8|9|10},{&if ?{Add or Subtract}=min}10{&else}0{&end})})}
  !token-mod --set statusmarkers|-Buff-globCur{\\&if globNew > 0}|+Buff-globNew{\\&end}
}}


So far it works good but there are two issues with it if you don't mind looking into it. The first issue is that if there are 0 action points or its subtracted past 0 I was hoping it would display the 0 status effect number. The second and this is the one I can see causing issues, if you set separate number for the action points on different tokens Token-1 has 2 points, Token-2 has 5 points, Token-3 has 1 point. Then you select all of them and add 2 points, what happens is on the tokens it displays an extra number instead of adjusting the number already on it so Token-1 has 2/7, Token-2 has 7, and Token-3 has 1/7 so something is clearly bugging out there.





timmaugh said:

OK, I think this is what you need. I can't fully test it because I don't have a marker analog to your "Buff-1", "Buff-2", etc., but if this doesn't work, I'll try to create an analog and figure out what's going wrong.

To make this work, you need TokenMod, the Metascript Toolbox, and the set of markers named Buff-1 through Buff-10. What should happen is that the old statusmarker should be removed and the new one (based on the math) should be added. If the math renders a 0, then no marker should be added.

Let me know if this works, or if you want an explanation for what is going on:

!{{
  {\&global ([globCur]{&if @(selected.is.Buff-1)=yes}1{&elseif @(selected.is.Buff-2)=yes}2{&elseif @(selected.is.Buff-3)=yes}3{&elseif @(selected.is.Buff-4)=yes}4{&elseif @(selected.is.Buff-5)=yes}5{&elseif @(selected.is.Buff-6)=yes}6{&elseif @(selected.is.Buff-7)=yes}7{&elseif @(selected.is.Buff-8)=yes}8{&elseif @(selected.is.Buff-9)=yes}9{&elseif @(selected.is.Buff-10)=yes}10{&else}0{&end})}
  {\\&global ([globNew]{\&math ?{Add or Subtract|Add,min|Subtract,max}(globCur{&if ?{Add or Subtract}=min}+{&else}-{&end}?{By How Much|1|2|3|4|5|6|7|8|9|10},{&if ?{Add or Subtract}=min}10{&else}0{&end})})}
  !token-mod --set statusmarkers|-Buff-globCur{\\&if globNew > 0}|+Buff-globNew{\\&end}
}}





March 13 (1 day ago)

Edited March 13 (1 day ago)
timmaugh
Pro
API Scripter

Yeah, that's all fixable. Initially you'd said you had markers 1-10, so I didn't know you had a 0-marker, as well.

Also, the math is being done on the first selected token, then applied to them all. The way to get around this is to use a 'forselected' handle on the whole thing, and iterate over the selected tokens...

That would look more like:

!forselected(^) token-mod --set statusmarkers|-Buff-globCur|+Buff-globNew {\^&global ([globCur]{^&if @^(selected.is.Buff-0)=yes}0{^&elseif @^(selected.is.Buff-1)=yes}1{^&elseif @^(selected.is.Buff-2)=yes}2{^&elseif @^(selected.is.Buff-3)=yes}3{^&elseif @^(selected.is.Buff-4)=yes}4{^&elseif @^(selected.is.Buff-5)=yes}5{^&elseif @^(selected.is.Buff-6)=yes}6{^&elseif @^(selected.is.Buff-7)=yes}7{^&elseif @^(selected.is.Buff-8)=yes}8{^&elseif @^(selected.is.Buff-9)=yes}9{^&elseif @^(selected.is.Buff-10)=yes}10{^&else}0{^&end})} {\\^&global ([globNew]{\^&math ?{Add or Subtract|Add,min|Subtract,max}(globCur{^&if ?{Add or Subtract}=min}+{^&else}-{^&end}?{By How Much|1|2|3|4|5|6|7|8|9|10},{^&if ?{Add or Subtract}=min}10{^&else}0{^&end})})}

...which is a bit harder to read than the previous version, but is essentially the same except 1) reduced to a single line, 2) token-specific references and logic have been deferred so they don't run as a part of the parent message, and 3) allowing a 'Buff-0' marker

EDIT: To get things straightened around the first time, you'll have to remove the extra markers manually as this command only removes the *first* Buff marker it finds before adding the new one. Once everything is in sync, you shouldn't get those extra markers applied.

Awesome! This worked like a charm, thank you so much!

timmaugh said:

Yeah, that's all fixable. Initially you'd said you had markers 1-10, so I didn't know you had a 0-marker, as well.

Also, the math is being done on the first selected token, then applied to them all. The way to get around this is to use a 'forselected' handle on the whole thing, and iterate over the selected tokens...

That would look more like:

!forselected(^) token-mod --set statusmarkers|-Buff-globCur|+Buff-globNew {\^&global ([globCur]{^&if @^(selected.is.Buff-0)=yes}0{^&elseif @^(selected.is.Buff-1)=yes}1{^&elseif @^(selected.is.Buff-2)=yes}2{^&elseif @^(selected.is.Buff-3)=yes}3{^&elseif @^(selected.is.Buff-4)=yes}4{^&elseif @^(selected.is.Buff-5)=yes}5{^&elseif @^(selected.is.Buff-6)=yes}6{^&elseif @^(selected.is.Buff-7)=yes}7{^&elseif @^(selected.is.Buff-8)=yes}8{^&elseif @^(selected.is.Buff-9)=yes}9{^&elseif @^(selected.is.Buff-10)=yes}10{^&else}0{^&end})} {\\^&global ([globNew]{\^&math ?{Add or Subtract|Add,min|Subtract,max}(globCur{^&if ?{Add or Subtract}=min}+{^&else}-{^&end}?{By How Much|1|2|3|4|5|6|7|8|9|10},{^&if ?{Add or Subtract}=min}10{^&else}0{^&end})})}

...which is a bit harder to read than the previous version, but is essentially the same except 1) reduced to a single line, 2) token-specific references and logic have been deferred so they don't run as a part of the parent message, and 3) allowing a 'Buff-0' marker

EDIT: To get things straightened around the first time, you'll have to remove the extra markers manually as this command only removes the *first* Buff marker it finds before adding the new one. Once everything is in sync, you shouldn't get those extra markers applied.