It is currently March 28th, 2024, 11:28 am

Creating Independent Counters

Tips and Tricks from the Rainmeter Community
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK
Contact:

Re: Creating Independent Counters

Post by Seahorse »

Not the counter, what I'm doing with it - maths... O.O
User avatar
KreAch3R
Posts: 608
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Creating Independent Counters

Post by KreAch3R »

Seahorse wrote:Not the counter, what I'm doing with it - maths... O.O
Oh, ok. Even more scratching. :p
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Creating Independent Counters

Post by smurfier »

Disabling the counter would make it's value 0. To actually stop it while retaining the value:

Code: Select all

[Counter]
Measure=Calc
Formula=Counter+(Counter<#Value#)
User avatar
KreAch3R
Posts: 608
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Creating Independent Counters

Post by KreAch3R »

Beautiful. :) Wouldn't that work the same as pausing it, however? It provides some additional functionality, nevertheless.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Creating Independent Counters

Post by smurfier »

Yes, that would basically pause the counter at the given value.
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK
Contact:

Re: Creating Independent Counters

Post by Seahorse »

smurfier wrote:Having it reset after a given value is easy and is accomplished the same way as if you were using the Counter variable.

Code: Select all

[cCounter]
Measure=Calc
Formula=(cCounter+1)%31
This will have the counter reset to zero after it hits 30. Always add 1 to whatever value you want it to reset after otherwise it will reset at that value.
There is a pause after the last number before it starts counting up again, is there a way of removing this? my test skin is counting to 4:

Code: Select all

[CalcCounter]
Measure=Calc
Formula=(CalcCounter+1)%5
but there is clearly a 2 second wait (Update=1000) after 4 before it starts again, i.e. gets to %5, then counts another second before triggering - making a total of 6 seconds total elapsed time for something I am trying to do in 5?
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Creating Independent Counters

Post by smurfier »

There should not be a delay like that, or at least none that I have experienced.

Also, if you want it to count 1-4 instead of 0-4 use (cCounter%4)+1
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK
Contact:

Re: Creating Independent Counters

Post by Seahorse »

Delay is there I can time it. Your suggestion removes the problem:

Code: Select all

[CalcCounter]
Measure=Calc
Formula=(CalcCounter%4)+1
User avatar
KreAch3R
Posts: 608
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Creating Independent Counters

Post by KreAch3R »

Just a post to cover something that isn't completely covered on the awesome first post:

You can make a counter reset automatically using %value and reset manually using a variable:

Code: Select all

[ScrollCounter]
Measure=Calc
Formula=((ScrollCounter+1)*#restart1#)%61
DynamicVariables=1
IfEqualValue=60
IfEqualAction=!Execute !bangs
IfBelowValue=1
IfBelowAction=!SetVariable restart1 1
In this example, it's a counter that automatically counts till 60, where it restarts and fires !bangs. But I wanted to restart the counter each time I was pressing a button. So the above code will work. I am using it in Kaelri's Evereader, to make the pages scroll automatically, and restart the scroll counter each time I click to see a page (so that I don't see the page for a few seconds before the counter takes it away from me) :)
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Creating Independent Counters

Post by smurfier »

To be honest I covered it as well as I felt was necessary. Also, you should be able to cut back on the parenthesis by following the order of operations.

Code: Select all

[ScrollCounter]
Measure=Calc
Formula=(ScrollCounter+1)%61*#restart1#
DynamicVariables=1
IfEqualValue=60
IfEqualAction=!Execute !bangs
IfBelowValue=1
IfBelowAction=!SetVariable restart1 1
Post Reply