It is currently July 13th, 2024, 3:23 pm

Dynamic words in sentences

General topics related to Rainmeter.
KOR.EAtable
Posts: 2
Joined: April 15th, 2011, 3:38 am

Dynamic words in sentences

Post by KOR.EAtable »

Sorry if this has been asked before, but I couldn't come up with any key words to search that came up with what I had in mind...
Image
I'm looking for a way to configure my skin so that the words in the sentence "It is ___F and ______________ outside" adjust to what the webparser feeds them. (Yes, in my picture I don't have an "outside" at the end, but I didn't want to add it until I figured this out) That is, when it's 90F it will have a certain spacing between "It is" and "and", but when it gets to 100F it will adjust between the two words to properly fit the extra digit. I found a rather unelegant way to add "outside" at the end by simply replacing Substitute="Fair":"fair" with Substitute="Fair":"fair outside.", but this doesn't account for times when the weather is BOTH "rainy outside" and "cloudy outside", etc. Is there a better way to achieve this?

Also, a third part to my request for help (sorry I have so many >.< ): Is there any way to change the color of the font within a meter? For example, I would like the words "It is ____ and _______ outside" to be all in white, while the actual temperature and weather statuses would be in blue... How would I go about doing this?

Thanks for reading and for providing support, all.
User avatar
Alex2539
Rainmeter Sage
Posts: 642
Joined: July 19th, 2009, 5:59 am
Location: Montreal, QC, Canada

Re: Dynamic words in sentences

Post by Alex2539 »

You can have a string meter use the measures for both temperature and condition and refer to then using %N within the Text parameter. Here's an example:

Code: Select all

[WeatherSentence]
Meter=String
MeasureName=MeasureTemperature
MeasureName2=MeasureCondition
Text=It is %1F and %2 outside
Of course, replace MeasureTemperature and MeasureCondition with the names of your own measures. %1 and %2 will be replaced with the values of their respective measures. So, if it is 80 degrees and partly cloudy, the string meter will show "It is %1F and %2 outside".
ImageImageImageImage
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: Dynamic words in sentences

Post by Chewtoy »

The only way to have different colours is to have separate meters.

Code: Select all

[ItIs]
Meter=String
FontColor=255,255,255,255
Text=It is

[Temperature]
Meter=String
MeasureName=MeasureTemperature
FontColor=0,0,255,255
Text=%1F
X=R
Y=r

[And]
Meter=String
FontColor=255,255,255,255
Text=and
X=R
Y=r

[Condition]
Meter=String
MeasureName=MeasureCondition
FontColor=0,0,255,255
Text=%1
X=R
Y=r

[Outside]
Meter=String
FontColor=255,255,255,255
Text=outside
X=R
Y=r
I don't think, therefore I'm not.
KOR.EAtable
Posts: 2
Joined: April 15th, 2011, 3:38 am

Re: Dynamic words in sentences

Post by KOR.EAtable »

Thanks for the quick replies, guys. Works like a charm. :D