It is currently May 6th, 2024, 10:21 pm

Using Time to trigger event

Get help with creating, editing & fixing problems with skins
User avatar
Alkazaar
Posts: 2
Joined: April 13th, 2012, 4:51 am

Using Time to trigger event

Post by Alkazaar »

Hi, I'm almost completely new to this.


I have a clock, and I want to display a png image at 4:20 am and pm, (I specifically use 12 hr time anyway).
I decided to use a dynamic variable for the opacity of the image, and turn it up at the right time.



My Problem is with the measure's format and ifaboveValues.


Code: Select all

[Variables] 
420Opac=0

[Measure420]
;returns img at 420 (am & pm)
Measure=Time
Format=%I%M
IfAboveValue=419
IfAboveAction=!SetVariable 420Opac 165
IfAboveValue=430
IfAboveAction=!SetVariable 420Opac 0
DynamicVariables=1

[Meter420Girl] 
W=640
H=640
ImageAlpha=#420Opac#
Meter=IMAGE
MeasureName=Measure420
ImageName=420chanGirl.png


Will "Format=%I%M" give a HourMinute number? Or how exactly does it work?
I saw "Format=%#I" or something similar once or twice, but I couldn't get it working.
I thought maybe something nested, or possibly a separator, I'm not sure.




I'm sure my code is sloppy, and this is probably a common asked question, but i couldn't find anything similar for a few pages back.
Any help would be greatly appreciated,
Thank You,
Alkazaar
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using Time to trigger event

Post by jsmorley »

You are on the right track for sure.

You can't have two IfAboveValue / IfAboveAction options on one measure though. So let's do this another way:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[MeasureTime]
Measure=Time
Format=%#I%M

[MeasureCalcTime]
Measure=Calc
Formula=((MeasureTime >= 420) && (MeasureTime < 430) ? 1 : -1)
IfAboveValue=0
IfAboveAction=!SetOption Meter420Girl ImageAlpha 165
IfBelowValue=0
IfBelowAction=!SetOption Meter420Girl ImageAlpha 0

[Meter420Girl]
Meter=IMAGE
ImageName=420chanGirl.png
ImageAlpha=0
W=640
H=640
What this is doing is getting the time into a format that Rainmeter will see as a number, with the leading zeros removed Format=%#I%M. Then we are using a conditional formula in a Calc measure to test if the value is between 420 and 429, setting the value of the Calc measure to 1 if yes, and -1 if no. Then we can use !SetOption to set the alpha value of the image based on the result.

No need for any [Variables] or DynamicVaribles=1 to support this approach. You also don't need the MeasureName= setting on the image. That wasn't needed in your approach either, as on an Image meter that is used to get the name of an image from a measure, and would not do anything with the value of a Time measure in any case.

One last note, you had put the DynamicVariables=1 on the Time measure where you were setting the variable. Remember that DynamicVariables=1 needs to go on the measure or meter where you are "using" a variable in a dynamic way, not where you are "setting" it.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using Time to trigger event

Post by jsmorley »

Correction... I was using the old name for the Time measure you had in my formula. It should look like this:

Formula=((MeasureTime >= 420) && (MeasureTime < 430) ? 1 : -1)
User avatar
Alkazaar
Posts: 2
Joined: April 13th, 2012, 4:51 am

Re: Using Time to trigger event

Post by Alkazaar »

Thanks so much jsmorley.

Amazingly quick and amazingly helpful.
I'll be sure to come back and do my bit once my coding is up to scratch.

Thanks again,
Alkazaar
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using Time to trigger event

Post by jsmorley »

Glad to help.