Image change with new month

Help with creating, editing & fixing problems with skins
User avatar

Image change with new month

February 13th, 2018, 11:15 am
chaser_dracodi
   [1 posts]

hello, i tried to create skin that will be display one of twelve images, one image per month.
Based on something that i found in this forum i create something like this but its not working.

Code: Select all

[Rainmeter]

[MeasureTime]
Measure=Time
TimeFormat=%m

[MonthlyImage]
Measure=MeasureTime
Substitute="1":"kalen 1.jpg","2":"kalen 2.jpg","3":"kalen 3.jpg","4":"kalen 4.jpg","5":"kalen

5.jpg","6":"kalen 6.jpg","7":"kalen 7.jpg", "8":"kalen 8.jpg","9":"kalen 9.jpg","10":"kalen

10.jpg", "11":"kalen 11.jpg","12":"kalen 12.jpg"
DynamicVariables=1
 
[MeterDay]
Meter=Image
ImageName=[MonthlyImage]
DynamicVariables=1
User avatar

Re: Image change with new month

February 13th, 2018, 11:35 am
balala
Rainmeter Sage   [5433 posts]

There are more possibilities to achieve something like this. I'd use the following one:

Code: Select all

[Rainmeter]

[MeasureTime]
Measure=Time
Format=%#m
IfCondition=(#CURRENTSECTION#=1)
IfTrueAction=[!SetOption MeterDay ImageName "Image-For-January.png"][!UpdateMeter "MeterDay"][!Redraw]
IfCondition2=(#CURRENTSECTION#=2)
IfTrueAction2=[!SetOption MeterDay ImageName "Image-For-February.png"][!UpdateMeter "MeterDay"][!Redraw]
IfCondition3=(#CURRENTSECTION#=3)
IfTrueAction3=[!SetOption MeterDay ImageName "Image-For-March.png"][!UpdateMeter "MeterDay"][!Redraw]
IfCondition4=(#CURRENTSECTION#=4)
IfTrueAction4=[!SetOption MeterDay ImageName "Image-For-April.png"][!UpdateMeter "MeterDay"][!Redraw]
IfCondition5=(#CURRENTSECTION#=5)
IfTrueAction5=[!SetOption MeterDay ImageName "Image-For-May.png"][!UpdateMeter "MeterDay"][!Redraw]
IfCondition6=(#CURRENTSECTION#=6)
IfTrueAction6=[!SetOption MeterDay ImageName "Image-For-June.png"][!UpdateMeter "MeterDay"][!Redraw]
IfCondition7=(#CURRENTSECTION#=7)
IfTrueAction7=[!SetOption MeterDay ImageName "Image-For-July.png"][!UpdateMeter "MeterDay"][!Redraw]
IfCondition8=(#CURRENTSECTION#=8)
IfTrueAction8=[!SetOption MeterDay ImageName "Image-For-August.png"][!UpdateMeter "MeterDay"][!Redraw]
IfCondition9=(#CURRENTSECTION#=9)
IfTrueAction9=[!SetOption MeterDay ImageName "Image-For-September.png"][!UpdateMeter "MeterDay"][!Redraw]
IfCondition10=(#CURRENTSECTION#=10)
IfTrueAction10=[!SetOption MeterDay ImageName "Image-For-October.png"][!UpdateMeter "MeterDay"][!Redraw]
IfCondition11=(#CURRENTSECTION#=11)
IfTrueAction11=[!SetOption MeterDay ImageName "Image-For-November.png"][!UpdateMeter "MeterDay"][!Redraw]
IfCondition12=(#CURRENTSECTION#=12)
IfTrueAction12=[!SetOption MeterDay ImageName "Image-For-December.png"][!UpdateMeter "MeterDay"][!Redraw]

[MeterDay]
Meter=Image
UpdateDivider=-1

I added some IfConditions directly to the [MeasureTime] measure, which returns the month. Note that:
  • a Time measure doesn't have a TimeFormat option, just a Format option (fixed).
  • I modified a bit the Format initial option, to remove the leading zeros (used Format=%#m, instead of the initial Format=%m)
The !SetOption bangs used in the IfTrueAction options set the appropriate image to the [MeterDay] image meter. Because the image used into this meter is changing onlz once per month, I added an UpdateDivider=-1 option to the [MeterDay] meter (to avoid its update), then I updated it through the !UpdateMeter bangs of the IfTrueAction options.
I completely removed the [MonthlyImage] measure, because it's not needed any more.

Re: Image change with new month

February 13th, 2018, 11:43 am
mak_kawa
   [213 posts]

My simple try...

Code: Select all

[MeasureTime]
Measure=Time
Format=%#m
Substitute="1":"kalen 1.jpg","2":"kalen 2.jpg","3":"kalen 3.jpg","4":"kalen 4.jpg","5":"kalen 5.jpg","6":"kalen 6.jpg","7":"kalen 7.jpg", "8":"kalen 8.jpg","9":"kalen 9.jpg","10":"kalen 10.jpg", "11":"kalen 11.jpg","12":"kalen 12.jpg"
 
[MeterDay]
Meter=Image
MeasureName=MeasureTime
User avatar

Re: Image change with new month

February 13th, 2018, 1:00 pm
balala
Rainmeter Sage   [5433 posts]

mak_kawa wrote:My simple try...

Code: Select all

[MeasureTime]
Measure=Time
Format=%#m
Substitute="1":"kalen 1.jpg","2":"kalen 2.jpg","3":"kalen 3.jpg","4":"kalen 4.jpg","5":"kalen 5.jpg","6":"kalen 6.jpg","7":"kalen 7.jpg", "8":"kalen 8.jpg","9":"kalen 9.jpg","10":"kalen 10.jpg", "11":"kalen 11.jpg","12":"kalen 12.jpg"
 
[MeterDay]
Meter=Image
MeasureName=MeasureTime

The substitution solution can definitely work, but not this way (sorry mak_kawa). The problem is that those substitutions are made in order. So, eg In November, when the [MeasureTime] returns 11, in the order of the substitutions the 1 is before 11, so both 1s will be substituted by the kalen 1.jpg image, and the substituted value of the measure will look, instead of what it should have to be (kalen 11.jpg), like kalen 1.jpgkalen 1.jpg (both digits 1 substituted by kalen 1.jpg).
In such cases you have to use the regular expression substitution. Replace the posted Substitute option with the following two:

Code: Select all

[MeasureTime]
Measure=Time
Format=%#m
RegExpSubstitute=1
Substitute="^1$":"kalen 1.jpg","^2$":"kalen 2.jpg","^3$":"kalen 3.jpg","^4$":"kalen 4.jpg","^5$":"kalen 5.jpg","^6$":"kalen 6.jpg","^7$":"kalen 7.jpg", "^8$":"kalen 8.jpg","^9$":"kalen 9.jpg","^10$":"kalen 10.jpg", "^11$":"kalen 11.jpg","^12$":"kalen 12.jpg"

In this case the substitutions are made only if the whole value returned by the measure is 1, 2 and so on, accordingly.
Last edited by balala on February 18th, 2018, 11:00 am, edited 1 time in total.

Re: Image change with new month

February 13th, 2018, 9:06 pm
mak_kawa
   [213 posts]

Hi balala

Yes, I was missing the "order" of substitution. Sorry. :)
User avatar

Re: Image change with new month

February 13th, 2018, 9:09 pm
balala
Rainmeter Sage   [5433 posts]

mak_kawa wrote:Yes, I was missing the "order" of substitution. Sorry. :)

No, not the order. Reordering them isn't enough, I think. Or at least it'd be very hard to achieve the proper substitution.
User avatar

Re: Image change with new month

February 17th, 2018, 11:22 pm
ChicknwithNoName
   [7 posts]

You need to use %#m instead, to remove the leading zero.

Otherwise, you can omit the substitution routine altogether with something simpler.

Code: Select all

[MeasureTime]
Measure=Time
Format=%#m
 
[MeterDay]
Meter=Image
MeasureName=MeasureTime
ImageName=kalen %1.jpg
DynamicVariables=1
User avatar

Re: Image change with new month

February 18th, 2018, 11:01 am
balala
Rainmeter Sage   [5433 posts]

ChicknwithNoName wrote:You need to use %#m instead, to remove the leading zero.

Otherwise, you can omit the substitution routine altogether with something simpler.

As usual, there are more possibilities.

Return to “Help: Rainmeter Skins”



Who is online

Users browsing this forum: No registered users and 3 guests