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

A macro to track a number.

I know the title isn't very descriptive, but I wasn't sure how to say it. What I want to do is keep track of a number. We'll call that number 'Tension'. Tension is going to start at zero, and every time I click a macro, I want it to add one to that number, and tell me the current Tension number. Once that number hits six, I want the next time I press the macro to reset it back to zero. And I also want a separate macro to X six-sided dice, where X is that number (or 1 if the number is currently zero). Can anyone help me?
1725821319

Edited 1725821692
Gauss
Forum Champion
Hi Red Archon,  Macros (by themselves) cannot make changes to attributes. You will need a Mod (API Script) to do that, ChatSetAttr  might be a good option for that but I will have to give some thought to the reseting at 6.  Since you have a Pro account you can do that if you are the game owner. Regarding rolling multiple d6s, you can do that with a basic macro.  This should be what you want for that (put it in a roll or an inline roll as part of a template or whatnot): [[{@{charactername|attributename},1}kh1]]d6
1725822460

Edited 1725822507
Gauss
Forum Champion
Alright, here is the ChatSetAttr command you need, put it in the Attributes and Abilities tab in an Ability:  !modattr --sel --Tension|[[[[{@{tension},6}<5]]*1 +[[{@{tension},0}>6]]*(-6)]] You can change the "sel" if you don't want to use a selected token. The guide I linked above can help with that. 
1725856739

Edited 1725865052
There's two ways to do this without Mods (that I could think of) - one is to use the chat as memory, and another using the initiative tracker to hold the value. Here's both approaches: &{template:default} {{Tension level:= [[?{Tension level|0|Cancel,}}}]] [Roll](`[[[[{?{Tension level},1}kh1]]d6]])}} {{=[Add Tension](`[[[[?{Tension level}+1]]*[[abs([[{0,[[?{Tension level}+1]]}>7]]-1)]]]] ?{Tension level|$[[5]]|Cancel,}}} %{Tester|tension})}} This is the more cumbersome option - save it as an ability on a character sheet of your choosing (replacing the "Tester" with that sheet's name), with the name "tension" (no quotation marks) for the ability, and it'll work - every time you click "add tension" in the chat, the tension level will increment resetting after 6, and clicking "roll" will roll dice equal to the tension level. The downside is that if it gets lost in the chat, you lose the number. &{template:default} {{name=Tension}} {{Tension Level:=[[ [[@{tracker|tension}+1]]*[[abs([[{0,@{tracker|tension}}>6-1]])]] &{tracker}]] [Roll](`[[[[{@{tracker|tension},1}k1]]d6]])}} This is the initiative tracker method - arguably the better option. You'll need to have a token set up for it, with the name "tension", but that's the end of the setup. You could also add a link to the template to repeat it right from the chat, like with the previous method. Both of these could be set up in collections macros too, but they both utilize html replacements, and since whenever you open a saved collections macro the html replacements are resolved, these are better suited to character sheet abilities. EDIT: Noticed a slight error with the roll buttons, will fix. EDIT2: Fixed. EDIT3: Since it's a relatively controlled and small sequence, you could also get away with 6 separate sequenced abilities, each linking to next, but that has the same limitations as the first.
1725859259

Edited 1725859393
GiGs
Pro
Sheet Author
API Scripter
Tuo, I'm curious how that chat version works. I have created a character named Tester, added an ability named tension, and it reports an error each time I click the Add Tension button ("No ability was found for %{Tester|tension}") It pops up an input box with options 1 and cancel, but that error message pups up before the inputbox, and clicking 1 in the inputbox prints this to chat: "1 1}} Tester|tension". On a roll, it rolls 1 dice with a Tension level of 0. By the way, I'm unsure how this is supposed to work: it's long been conventional wisdom that attributes on the sheet can't be changed without a script (or, later, the addition of Custom Roll Parsing).
GiGs said: Tuo, I'm curious how that chat version works. I have created a character named Tester, added an ability named tension, and it reports an error each time I click the Add Tension button ("No ability was found for %{Tester|tension}") It pops up an input box with options 1 and cancel, but that error message pups up before the inputbox, and clicking 1 in the inputbox prints this to chat: "1 1}} Tester|tension". On a roll, it rolls 1 dice with a Tension level of 0. By the way, I'm unsure how this is supposed to work: it's long been conventional wisdom that attributes on the sheet can't be changed without a script (or, later, the addition of Custom Roll Parsing). Did you save the ability on the character sheet? That sounds like what happens when you paste the ability into the field but don't save it - you can test it, but you can't call the ability until you save it. And it's not interacting with attributes - it gets around it by saving the number into the button that repeats the macro, so as long as you have it in the chat, you can increment it. Rolling 1 die with tension level of 0 was what was requested, which I had to specifically account for and originally forgot to.
1725885419

Edited 1725885715
timmaugh
Pro
API Scripter
I was just looking at the post in the Tricks/Tips thread that references the trick Tuo is using... or, at least it was the discussion that followed the introduction of the method. I'm not sure I ever saw the original post. In any case, it's a trick of "unpacking" a given roll in a button so that it can be "re-used" in a different message. I'm pretty sure it has to be a "value" roll rather than a figured roll -- so you might have to enclose a figured roll in more double brackets to get a version that can be unpacked like this. Let me see if I can find that post, again... EDIT: Yep, it was a Tuo suggestion , initially, that RainbowEncoder expanded on (subsequent post from that link).
1725889760

Edited 1725889884
Gauss said: Hi Red Archon,  Macros (by themselves) cannot make changes to attributes. You will need a Mod (API Script) to do that, ChatSetAttr  might be a good option for that but I will have to give some thought to the reseting at 6.  Since you have a Pro account you can do that if you are the game owner. Regarding rolling multiple d6s, you can do that with a basic macro.  This should be what you want for that (put it in a roll or an inline roll as part of a template or whatnot): [[{@{charactername|attributename},1}kh1]]d6 The Tension attribute looks to work, but while it says it's rolling, I'm not getting a result. (I changed the charactername and attribute name to the names of the character and attribute first. Did I do it right?
1725901174
timmaugh
Pro
API Scripter
It looks like you set the capital-T version of "Tension" with ChatSetAttr... but then you're calling the lowercase version in your roll. You can check that, of course, just by entering the attribute retrieval syntax in your chat and seeing what you get: @{Tension|Tension} vs. @{Tension|tension} Then correct whichever side is wrong. Once you have the value in the attribute, the roll will work.
1725902667

Edited 1725902742
Gauss
Forum Champion
Red Archon said: Gauss said: This should be what you want for that (put it in a roll or an inline roll as part of a template or whatnot): [[{@{charactername|attributename},1}kh1]]d6 The Tension attribute looks to work, but while it says it's rolling, I'm not getting a result. (I changed the charactername and attribute name to the names of the character and attribute first. Did I do it right? As I stated, I only gave you the calculation, I don't know how you are using it so I didn't give you the roll method. Please post the macro so that a roll method can be included.
Gauss said: Red Archon said: Gauss said: This should be what you want for that (put it in a roll or an inline roll as part of a template or whatnot): [[{@{charactername|attributename},1}kh1]]d6 The Tension attribute looks to work, but while it says it's rolling, I'm not getting a result. (I changed the charactername and attribute name to the names of the character and attribute first. Did I do it right? As I stated, I only gave you the calculation, I don't know how you are using it so I didn't give you the roll method. Please post the macro so that a roll method can be included. That explains it. I put in the roll method and it worked fine.  One other question related to this: how do I set it to announce the new tension level whenever I raise it?