It is currently April 18th, 2024, 5:02 am

Counter

Get help with creating, editing & fixing problems with skins
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Counter

Post by smurfier »

Is there a way to reset the Counter using a bang?
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
Alex2539
Rainmeter Sage
Posts: 642
Joined: July 19th, 2009, 5:59 am
Location: Montreal, QC, Canada

Re: Counter

Post by Alex2539 »

That depends. If you just want it to count to a certain number then restart, you can use the modulus operator, which is "%", to have it loop around. So, for example, the following would count from zero to 99, then restart:

Code: Select all

[Counter100]
Measure=Calc
Formula=Counter%100
However, if you want to have the counter reset at some arbitrary time, there is no way to do this. At least, not without closing and reopening the skin. What you can do is make your own counter though. A Calc measure can actually refer to itself like it does other measures, so if you tell it to add 1 to its current value it will just keep going up. If you disable the measure, it will reset back to zero. Once you re-enable it, it will start counting up again.

Code: Select all

[MyCount]
Measure=Calc
Formula=MyCount+1

[Trigger]
Measure=Calc
Formula=1
IfEqualValue=1
IfEqualAction=!Execute [!RainmeterEnableMeasure MyCount][!RainmeterDisableMeasure Trigger]

[Reset]
Meter=String
MeasureName=MyCount
W=50
H=50
SolidColor=255,0,0
LeftMouseUpAction=!Execute [!RainmeterDisableMeasure MyCount][!RainmeterEnableMeasure Trigger]
This will make a counter with a big red button to reset it. The MyCount measure needs at least one update to set itself to zero before counting up again, so the button disables it and enables the Trigger measure, which is set to enable MyCount and disable itself as soon as it's activate. This effectively staggers the re-enabling of MyCount, giving it the time it needs.
ImageImageImageImage
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Counter

Post by smurfier »

That's pretty much what I was figuring and was just hoping there was an easier way. What I want to do is have the counter reset when you click on the Grabber to change the feed in the RSS multi-reader.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: Counter

Post by Chewtoy »

Well. you could always refresh the whole skin. That resets the counter.

We should have a !RainmeterRefreshMeter and a !RainmeterRefreshMeasure.
I don't think, therefore I'm not.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Counter

Post by smurfier »

That would technically work, but would force everything to update, including forcing the switcher back to the first one. I've actually accomplished what I set out to do.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Counter

Post by poiru »

smurfier wrote:I've actually accomplished what I set out to do.
Mind sharing your accomplishment?

EDIT: Nevermind, I think I've a good enough solution now.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Counter

Post by smurfier »

There's actually a problem with my method. Occasionally when a page is parsed, my self made counter sets to 1 and freezes. What's weird is that they are not intertwined at all and it doesn't happen all the time.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .