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
This post has been closed. You can still view previous posts, but you can't post any new replies.

Round counter trick macro?

1380115795
Tom
Plus
Sheet Author
A buddy of mine showed me a great trick to create a round clock in your turn order panel, by assigning a NPC token with an initiative of +0.1 each round. So now that I've started to experiment with macro creation, I wonder if there is a way to create a macro to do this. All it would do is take a to men's current initiative in the turn order, add 0.1 and update the turn order. Is that possible? Tom
API script could do it but not a macro.
1380122374
Gid
Roll20 Team
Actually, you probably can without the API. Riley just added some new macro functions that affects the turn tracker. <a href="https://app.roll20.net/forum/post/361734/new-update-9-slash-24-selected-token-variables-slash-abilities-roll-to-initiative-text-editor-upgrades-and-more#post-363829" rel="nofollow">https://app.roll20.net/forum/post/361734/new-update-9-slash-24-selected-token-variables-slash-abilities-roll-to-initiative-text-editor-upgrades-and-more#post-363829</a> The last post talks about the "/roll 1d20 &amp;{tracker:+}" macro which will add to a currently selected token's initiative number in the turn tracker.
1380127076
Tom
Plus
Sheet Author
That might just work. I'll have to give it a shot. Something like /roll .01 &amp;{tracker:+}, wouldn't you think?
1380128639
Gid
Roll20 Team
Just tested that out, Tom. Looks like it's working on my end.
1380133412
Tom
Plus
Sheet Author
Working here too, though it works better if I use the "/roll 0.01 &amp;{tracker:+}" action. Otherwise, I sometimes get some really weird fractions. Now the only one thing keeps this from being perfect. Is there a command that will "auto select" a particular token? For instance, lets say I assign a token on the screen with the name "Round Clock." Is there a command I can add to this macro that, when I execute it, it will immediate select "Round Clock" and perform the action for it? There is a lot of stuff about select-ed tokens in the wiki, but most of it looks as though I have to have manually selected the token before executing the macro.
1380134038
Tom
Plus
Sheet Author
Ok, testing this a bit more. Seems the weird fractions come up pretty consistently actually. Enough so one of the devs should check this out. Everything works fine on 0.01-0.05. On 0.06, I get "0.060000000000000005" Then 0.07-0.09, everything works fine again. Then, on 0.10, I get "0.09999999999999999", followed by "0.10999999999999999", "0.11999999999999998", "0.12999999999999998", etc. On 0.15, it works fine again, then loopy again from that point on. Pretty sure this is a bug. Not one that would affect anyone who isn't using decimals, though. Can anyone confirm this? I'm using Safari as my browser.
1380134973
Gid
Roll20 Team
Presently you have to manually select the token. As for the odd fractioning I'll check with the Devs on that.
It has to do with the way that Javascript handles floating-point numbers. Why are you doing 0.01 instead of just 1?
1380135809
Lithl
Pro
Sheet Author
API Scripter
Tom said: Ok, testing this a bit more. Seems the weird fractions come up pretty consistently actually. Enough so one of the devs should check this out. Everything works fine on 0.01-0.05. On 0.06, I get "0.060000000000000005" Then 0.07-0.09, everything works fine again. Then, on 0.10, I get "0.09999999999999999", followed by "0.10999999999999999", "0.11999999999999998", "0.12999999999999998", etc. On 0.15, it works fine again, then loopy again from that point on. Pretty sure this is a bug. Not one that would affect anyone who isn't using decimals, though. Can anyone confirm this? I'm using Safari as my browser. That's floating-point rounding errors. 0.01 cannot be accurately represented with binary floating-point numbers (nor can 0.1), and computers are always working with binary numbers, no matter what you try to tell them to do. The closest floating-point binary number to 0.01 translates to the decimal number 0.009999999776482582092285156250. Is there any particular reason why you're trying to represent a turn counter with fractions rather than counting numbers (1, 2, 3, etc.)?
1380136042
Gid
Roll20 Team
I'm going to assume that Tom was doing that so his NPC round counter always appears on the bottom of the turn tracker... though you could probably use negative integers and not have to deal with the fraction problem now that I think about it.
1380137286

Edited 1380137456
Tom
Plus
Sheet Author
Yes, Kristin is exactly right. The round counter is meant to always be at the end of the turn order. Its not a perfect solution, but it'll work in a pinch until a real option becomes available. That the problem lies in the underlying script doesn't surprise me. Now using negative numbers as a work around. THAT is an interesting solution. Does it work?
1380139430
Gid
Roll20 Team
Sure does! /roll -1 &amp;{tracker:+} That will start the counter token at -1 (round 1) and each time you run the macro it'll count further into the negative.
1380139952
Tom
Plus
Sheet Author
Tried it and it works like a charm! Thanks Kristin!
I would just like to say +1 (or -1 as the case seems to be?) on this thread. Very useful trick.