It is currently April 18th, 2024, 9:18 am

How do I make an animation play after every hour?

Get help with creating, editing & fixing problems with skins
User avatar
severedmars
Posts: 17
Joined: July 17th, 2021, 6:31 pm

How do I make an animation play after every hour?

Post by severedmars »

I am working on a clock display that uses a bar to measure minutes. I currently have the bar working, but I want an animation to play before it resets to the empty bar again. How would I make that work?

I currently have this code:

Code: Select all

[Rainmeter]
Update=1000

[MeasureTime]
Measure=Time
Format=%M

[Calculate]
Measure=Calc
Formula=[MeasureTime]
MaxValue=59
DynamicVariables=1

[MeterProgressBar]
Meter=BAR
MeasureName=Calculate
X=13
Y=21
BarImage=#@#Images\minutebar.png
BarOrientation=Vertical
Thanks in advance!
-mars
User avatar
SilverAzide
Rainmeter Sage
Posts: 2602
Joined: March 23rd, 2015, 5:26 pm

Re: How do I make an animation play after every hour?

Post by SilverAzide »

severedmars wrote: July 17th, 2021, 6:40 pm I am working on a clock display that uses a bar to measure minutes. I currently have the bar working, but I want an animation to play before it resets to the empty bar again. How would I make that work?
You've got the first step, your [Calculate] measure. What you need to add are some "if conditions" to that measure. Check the docs on this here: IfConditions.

So, in pseudo-code, you are going to need something like this:

Code: Select all

[Calculate]
Measure=Calc
Formula=[MeasureTime]
...
IfCondition=([Calculate] = 59)
IfTrueAction=[!some bang to start your animation]
Depending on the duration of your animation, you might want it to start before 59 seconds elapses. If the animation is 5 seconds long, then change 59 to 54 or 55, something like that.
Gadgets Wiki GitHub More Gadgets...
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How do I make an animation play after every hour?

Post by balala »

severedmars wrote: July 17th, 2021, 6:40 pm I am working on a clock display that uses a bar to measure minutes. I currently have the bar working, but I want an animation to play before it resets to the empty bar again. How would I make that work?
First you need an ActionTimer plugin measure, add the following one to your code:

Code: Select all

[MeasureReset]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat Reset,20,10
Reset=[!SetVariable Step "(Clamp((#Step#+1),0,10))"]#U#
IfCondition=(#Step#=10)
IfTrueAction=[!SetVariable Step "0"]#U#
DynamicVariables=1
As you can see this measure uses two variables, U and Step. Add them to the [Variables] section:

Code: Select all

[Variables]
Step=0
U=[!UpdateMeasure "MeasureReset"][!UpdateMeasure "Calculate"][!UpdateMeter "MeterProgressBar"][!Redraw]
Modify the [Calculate] measure as it follows:

Code: Select all

[Calculate]
Measure=Calc
Formula=(( MeasureTime > 0 ) ? MeasureTime : (( #Step# > 0 ) ? ( 60 - 60 * #Step# / 10 ) : 0 ))
MaxValue=59
DynamicVariables=1
And finally as SilverAzide said, you need to add a condition to the [MeasureTime] to execute the previously added [MeasureReset] ActionTimer plugin measure. Add the following condition:

Code: Select all

[MeasureTime]
Measure=Time
Format=%M
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!CommandMeasure "MeasureReset" "Execute 1"]
With all this your code will look this way:

Code: Select all

[Rainmeter]
Update=1000

[Variables]
Step=0
U=[!UpdateMeasure "MeasureReset"][!UpdateMeasure "Calculate"][!UpdateMeter "MeterProgressBar"][!Redraw]

[MeasureReset]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat Reset,20,10
Reset=[!SetVariable Step "(Clamp((#Step#+1),0,10))"]#U#
IfCondition=(#Step#=10)
IfTrueAction=[!SetVariable Step "0"]#U#
DynamicVariables=1

[MeasureTime]
Measure=Time
Format=%M
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!CommandMeasure "MeasureReset" "Execute 1"]

[Calculate]
Measure=Calc
Formula=(( MeasureTime > 0 ) ? MeasureTime : (( #Step# > 0 ) ? ( 60 - 60 * #Step# / 10 ) : 0 ))
MaxValue=59
DynamicVariables=1

[MeterProgressBar]
Meter=BAR
MeasureName=Calculate
X=13
Y=21
BarImage=#@#Images\minutebar.png
BarOrientation=Vertical
Please let me know if this is what you want.
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How do I make an animation play after every hour?

Post by balala »

severedmars wrote: July 17th, 2021, 6:40 pm I am working on a clock display that uses a bar to measure minutes. I currently have the bar working, but I want an animation to play before it resets to the empty bar again. How would I make that work?

I currently have this code:

Code: Select all

[Rainmeter]
Update=1000

[MeasureTime]
Measure=Time
Format=%M

[Calculate]
Measure=Calc
Formula=[MeasureTime]
MaxValue=59
DynamicVariables=1

[MeterProgressBar]
Meter=BAR
MeasureName=Calculate
X=13
Y=21
BarImage=#@#Images\minutebar.png
BarOrientation=Vertical
Thanks in advance!
-mars
SilverAzide wrote: July 17th, 2021, 7:15 pm You've got the first step, your [Calculate] measure. What you need to add are some "if conditions" to that measure. Check the docs on this here: IfConditions.

So, in pseudo-code, you are going to need something like this:

Code: Select all

[Calculate]
Measure=Calc
Formula=[MeasureTime]
...
IfCondition=([Calculate] = 59)
IfTrueAction=[!some bang to start your animation]
Depending on the duration of your animation, you might want it to start before 59 seconds elapses. If the animation is 5 seconds long, then change 59 to 54 or 55, something like that.
One more for both of you. Since [MeasureTime] is a Time measure, having a well defined format (Format=%M), there is not needed to use it as a section variable into the [Calculate] Calc measure. This type of measure is always using the numeric value of a measure, so as you can see in my above posted code the [Calculate] measure can easily deal without using the [Calculate] measure as a section variable. This could avoid the need of setting the dynamic variables on the measure, which always is a good idea. Unfortunately here I had to set it back, due to the #Step# variable used into the formula option of the [Calculate] measure, but otherwise we could renounce to the DynamicVariables=1 option.
User avatar
severedmars
Posts: 17
Joined: July 17th, 2021, 6:31 pm

Re: How do I make an animation play after every hour?

Post by severedmars »

Code: Select all

[Rainmeter]
Update=1000

[Variables]
Step=0
U=[!UpdateMeasure "MeasureReset"][!UpdateMeasure "Calculate"][!UpdateMeter "MeterProgressBar"][!Redraw]

[MeasureReset]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat Reset,20,10
Reset=[!SetVariable Step "(Clamp((#Step#+1),0,10))"]#U#
IfCondition=(#Step#=10)
IfTrueAction=[!SetVariable Step "0"]#U#
DynamicVariables=1

[MeasureTime]
Measure=Time
Format=%M
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!CommandMeasure "MeasureReset" "Execute 1"]

[Calculate]
Measure=Calc
Formula=(( MeasureTime > 0 ) ? MeasureTime : (( #Step# > 0 ) ? ( 60 - 60 * #Step# / 10 ) : 0 ))
MaxValue=59
DynamicVariables=1

[MeterProgressBar]
Meter=BAR
MeasureName=Calculate
X=13
Y=21
BarImage=#@#Images\minutebar.png
BarOrientation=Vertical
thank you, This code works in my case, but how do i actually use it to play the animation? also, I'm sorry for not clarifying in case this changes anything, but the animation is 5 image frames titled "SoulBurst1" replacing 1 with the frame number. I'm sorta new to this stuff if you couldn't tell
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How do I make an animation play after every hour?

Post by balala »

severedmars wrote: July 17th, 2021, 9:39 pm This code works in my case, but how do i actually use it to play the animation? also, I'm sorry for not clarifying in case this changes anything, but the animation is 5 image frames titled "SoulBurst1" replacing 1 with the frame number.
Ok, what I've understood from your request was what I've been posting before. But here is what you have to modify:
  • Actually for the animation you don't need the [Calculate] measure. If you want to keep how the Bar meter is "decreasing" keep it, but otherwise you can remove it. However take care that if you remove it, modify the MeasureName option of the [MeterProgressBar] meter as well, not to get error in log. Come back if you don't know how to do all this, but want to do them.
  • Add the following Image meter to your code:

    Code: Select all

    [MeterAnimation]
    Meter=Image
    X=0
    Y=0
    ImageName=#@#Animation\SoulBurst#Step#.png
    DynamicVariables=1
    Make sure to properly adjust the position of meter (by changing its X and Y value accordingly to your needs / desires) and the path of the images (as you can see in the ImageName option above, I placed the images into a folder named Animation, created inside the @Resources folder of your config - modify it if needed - probably it is needed!).
  • Finally add the name of the above meter to the U variable, to be updated when the ActionTimer plugin measure is running. Modify the mentioned U variable (into the [Variables] section) to this: U=[!UpdateMeasure "MeasureReset"][!UpdateMeasure "Calculate"][!UpdateMeter "MeterProgressBar"][!UpdateMeter "MeterAnimation"][!Redraw] (if you removed the animated decrease of the Bar meter - as said in the first point above -, remove the [!UpdateMeter "MeterProgressBar"] bang from the above variable as well).
User avatar
severedmars
Posts: 17
Joined: July 17th, 2021, 6:31 pm

Re: How do I make an animation play after every hour?

Post by severedmars »

Thank you very much, it now plays the animation. But, the animation plays twice. Is this a problem with the numbers in the previous code? i will update if i can fix it myself. Thanks again.
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How do I make an animation play after every hour?

Post by balala »

severedmars wrote: July 18th, 2021, 4:47 pm But, the animation plays twice. Is this a problem with the numbers in the previous code?
Don't know, but please pack the whole config you have the images in (the folder under the Skins folder, which contains the images and the .ini file of skin) and upload the package here, to can check it.
User avatar
Yincognito
Rainmeter Sage
Posts: 7120
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: How do I make an animation play after every hour?

Post by Yincognito »

severedmars wrote: July 17th, 2021, 9:39 pmI'm sorry for not clarifying in case this changes anything, but the animation is 5 image frames titled "SoulBurst1" replacing 1 with the frame number.
severedmars wrote: July 18th, 2021, 4:47 pmBut, the animation plays twice. Is this a problem with the numbers in the previous code?
It's possible. Your #Step# variable goes from 1 to 10 in [MeasureReset], but you said you only need to iterate through 5 images, with the first one being numbered as 1. Not familiar with the thread evolution till now so I might miss something, but you can try setting this measure to:

Code: Select all

[MeasureReset]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat Reset,20,5
Reset=[!SetVariable Step "(Clamp((#Step#+1),1,5))"]#U#
IfCondition=(#Step#=5)
IfTrueAction=[!SetVariable Step "0"]#U#
DynamicVariables=1
and see if that helps.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How do I make an animation play after every hour?

Post by balala »

Yincognito wrote: July 19th, 2021, 6:01 pm It's possible. Your #Step# variable goes from 1 to 10 in [MeasureReset], but you said you only need to iterate through 5 images, with the first one being numbered as 1. Not familiar with the thread evolution till now so I might miss something, but you can try setting this measure to:
:? :? :?
MY BAD!!!
I initially wrote the code for 10 frames / images, later found out that the desired animation has only 5 frames, but forgot to fix this.
So, yep, you probably are right.