It is currently April 18th, 2024, 3:31 am

Nesting variables inside strings that are set as the values for other variables

Get help with creating, editing & fixing problems with skins
ingridd
Posts: 17
Joined: June 20th, 2021, 1:38 am

Nesting variables inside strings that are set as the values for other variables

Post by ingridd »

i was working on my rainmeter skin recently, and got stuck on one of the skins. the skin is one that shows a new quote per day, and there are 3 sets of quotes that it shows. what it does it that from 3 separate text files, it chooses a quote and saves each quote to a variable (CurrentBSDQuote, CurrentFBQuote and CurrentKJQuote).

The quote meter only displays one quote at a time and to switch between the 3 selected quotes, you will have to click onto the 3 "buttons" below.

The problem now is that the length (of the height of text) of the 3 quotes are different, so the 3 "buttons" would have to move according to the new height of the quote, once pressed. I saved the height into the variable CirclePosition which indicates the height of the circle, then reset the shape of the CircleMeters into the correct string with modified height. However, after nesting the variable into this string, the height of the 3 circles, once pressed, do not change accordingly and instead are shifted to Y=0.

I was wondering why this happened - is it because im not nesting the variables correctly? (not sure if nesting is the correct term but yea)
here is my code for the skin below:

Code: Select all

[Rainmeter]
Update=360000
DynamicWindowSize=1

[Variables]
CirclePosition=[QuoteMeter:Y]+[QuoteMeter:H]+20
FilledCircle1="Ellipse 130, ([QuoteMeter:Y]+[QuoteMeter:H]+20), 5 | Fill Color 255, 255, 255, 100 | Stroke Color 255, 255, 255, 100"
UnfilledCircle1="Ellipse 130, ([QuoteMeter:Y]+[QuoteMeter:H]+20), 5 | Fill Color 255, 255, 255, 1 | Stroke Color 255, 255, 255, 200" 
FilledCircle2="Ellipse 150, ([QuoteMeter:Y]+[QuoteMeter:H]+20), 5 | Fill Color 255, 255, 255, 100 | Stroke Color 255, 255, 255, 100"
UnfilledCircle2="Ellipse 150, ([QuoteMeter:Y]+[QuoteMeter:H]+20), 5 | Fill Color 255, 255, 255, 1 | Stroke Color 255, 255, 255, 200"
FilledCircle3="Ellipse 170, ([QuoteMeter:Y]+[QuoteMeter:H]+20), 5 | Fill Color 255, 255, 255, 100 | Stroke Color 255, 255, 255, 100"
UnfilledCircle3="Ellipse 170, ([QuoteMeter:Y]+[QuoteMeter:H]+20), 5 | Fill Color 255, 255, 255, 1 | Stroke Color 255, 255, 255, 200"
CurrentFBQuote="It's frightening that there's no guarantee that I'll be loved."#CRLF#- Akito Sohma
CurrentBSDQuote="I saw a bright world. I cannot go back to a time when I did not know such a thing existed."#CRLF#- Kyouka Izumi
CurrentKJQuote=haha

[Day]
Measure=Time
Format=%#d
OnChangeAction=[!EnableMeasure FBQuotes][!EnableMeasure BSDQuotes][!EnableMeasure KJQuotes][!UpdateMeasure FBQuotes][!UpdateMeasure BSDQuotes][!UpdateMeasure KJQuotes][!UpdateMeter QuoteMeter][!Redraw][!Refresh]

[FBQuotes]
Measure=Plugin
Plugin=QuotePlugin
PathName=C:\Users\ingri\OneDrive\Documents\- quotes -\fruitsbasketquotes.txt
Separator=";"
UpdateDivider=-1
Disabled=1
OnUpdateAction=[!WriteKeyValue Variables CurrentFBQuote "[FBQuotes]"][!SetVariable CurrentFBQuote "[FBQuotes]"][!UpdateMeter "QuoteMeter"][!Redraw]

[BSDQuotes]
Measure=Plugin
Plugin=QuotePlugin
PathName=C:\Users\ingri\OneDrive\Documents\- quotes -\bungouquotes.txt
Separator=";"
UpdateDivider=-1
Disabled=1
OnUpdateAction=[!WriteKeyValue Variables CurrentBSDQuote "[BSDQuotes]"][!SetVariable CurrentBSDQuote "[BSDQuotes]"][!UpdateMeter "QuoteMeter"][!Redraw]

[KJQuotes]
Measure=Plugin
Plugin=QuotePlugin
Pathname=C:\Users\ingri\OneDrive\Documents\- quotes -\kemonoquotes.txt
Separator=";"
UpdateDivider=-1
Disabled=1
OnUpdateAction=[!WriteKeyValue Variables CurrentKJQuote "[KJQuotes]"][!SetVariable CurrentKJQuote "[KJQuotes]"][!UpdateMeter "QuoteMeter"][!Redraw]

[BackgroundMeter]
Meter=Shape
Shape=Rectangle 0,0,315,200 | Fill Color 255, 255, 255, 0 | Stroke Color 255,255,255, 0

[QuoteMeter]
Meter=String
UpdateDivider=-1
Disabled=1
ClipString=2
Text="#CurrentFBQuote#"
FontSize=13
FontColor=255, 255, 255, 200
FontFace=Rajdhani
SolidColor=0,0,0,1
Y=60r
X=10r
W=303
AntiAlias=1
DynamicVariables=1

[CircleMeter1]
Meter=Shape
Shape=#FilledCircle1#
DynamicVariables=1
LeftMouseUpAction=[!SetOption QuoteMeter Text """#CurrentFBQuote#"""][!SetVariable CirclePosition "[QuoteMeter:Y]+[QuoteMeter:H]+20"][!SetOption CircleMeter1 Shape "Ellipse 130, [#CirclePosition], 5 | Fill Color 255, 255, 255, 100 | Stroke Color 255, 255, 255, 100"][!SetOption CircleMeter2 Shape "Ellipse 150, [#CirclePosition], 5 | Fill Color 255, 255, 255, 1 | Stroke Color 255, 255, 255, 200"][!SetOption CircleMeter3 Shape "Ellipse 170, [#CirclePosition], 5 | Fill Color 255, 255, 255, 1 | Stroke Color 255, 255, 255, 200"][!UpdateMeter QuoteMeter][!UpdateMeter CircleMeter1][!UpdateMeter CircleMeter2][!UpdateMeter CircleMeter3][!Redraw]
;[!SetOption CircleMeter1 Shape "#FilledCircle1#"][!SetOption CircleMeter2 Shape "#UnfilledCircle2#"][!SetOption CircleMeter3 Shape "#UnfilledCircle3#"]

[CircleMeter2]
Meter=Shape
Shape=#UnfilledCircle2#
DynamicVariables=1 
LeftMouseUpAction=[!SetOption QuoteMeter Text """#CurrentBSDQuote#"""][!SetVariable CirclePosition "[QuoteMeter:Y]+[QuoteMeter:H]+20"][!SetOption CircleMeter1 Shape "Ellipse 130, [#CirclePosition], 5 | Fill Color 255, 255, 255, 1 | Stroke Color 255, 255, 255, 200" ][!SetOption CircleMeter2 Shape "Ellipse 150, [#CirclePosition], 5 | Fill Color 255, 255, 255, 100 | Stroke Color 255, 255, 255, 100"][!SetOption CircleMeter3 Shape "Ellipse 170, [#CirclePosition], 5 | Fill Color 255, 255, 255, 1 | Stroke Color 255, 255, 255, 200"][!UpdateMeter QuoteMeter][!UpdateMeter CircleMeter1][!UpdateMeter CircleMeter2][!UpdateMeter CircleMeter3][!Redraw]
;[!SetOption CircleMeter1 Shape "#UnfilledCircle1#"][!SetOption CircleMeter2 Shape "#FilledCircle2#"][!SetOption CircleMeter3 Shape "#UnfilledCircle3#"][!UpdateMeter QuoteMeter][!Redraw]

[CircleMeter3]
Meter=Shape
Shape=#UnfilledCircle3#
DynamicVariables=1 
LeftMouseUpAction=[!SetOption QuoteMeter Text """#CurrentKJQuote#"""][!SetVariable CirclePosition "[QuoteMeter:Y]+[QuoteMeter:H]+20"][!SetOption CircleMeter1 Shape "Ellipse 130, [#CirclePosition], 5 | Fill Color 255, 255, 255, 1 | Stroke Color 255, 255, 255, 200" ][!SetOption CircleMeter2 Shape "Ellipse 150, [#CirclePosition], 5 | Fill Color 255, 255, 255, 1 | Stroke Color 255, 255, 255, 200"][!SetOption CircleMeter3 Shape "Ellipse 170, [#CirclePosition], 5 | Fill Color 255, 255, 255, 100 | Stroke Color 255, 255, 255, 100"][!UpdateMeter QuoteMeter][!UpdateMeter CircleMeter1][!UpdateMeter CircleMeter2][!UpdateMeter CircleMeter3][!Redraw]
;[!SetOption CircleMeter1 Shape "#UnfilledCircle1#"][!SetOption CircleMeter2 Shape "#UnfilledCircle2#"][!SetOption CircleMeter3 Shape "#FilledCircle3#"][!UpdateMeter QuoteMeter][!Redraw]
what it is supposed to look like:
Image

what it actually looks like:
Image

any help would be much appreciated!!
User avatar
CodeCode
Posts: 1365
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Nesting variables inside strings that are set as the values for other variables

Post by CodeCode »

Check this out, hopefully it can help you align things better.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
ingridd
Posts: 17
Joined: June 20th, 2021, 1:38 am

Re: Nesting variables inside strings that are set as the values for other variables

Post by ingridd »

CodeCode wrote: August 26th, 2021, 2:19 pm Check this out, hopefully it can help you align things better.
wait sorry im not really sure how that helps
User avatar
CodeCode
Posts: 1365
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Nesting variables inside strings that are set as the values for other variables

Post by CodeCode »

ingridd wrote: August 26th, 2021, 2:32 pm wait sorry im not really sure how that helps
The Dots would be placed with a Relative "R" or numxR on the Y coordinate then the dots will act dynamically to the last line of the text no matter hoe long or short it may be - within the scope of your skin that is. I may not be fully imagining the code you are using.

Also, why dont you just the the Quote Plugin to randomly choose a text string, rather than several/many lines of code, that look unnecessarily complex.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Nesting variables inside strings that are set as the values for other variables

Post by death.crafter »

ingridd wrote: August 26th, 2021, 2:32 pm wait sorry im not really sure how that helps
He meant using relative positioning.
Relative positioning: If the value is appended with r, the position is relative to the top/left edge of the previous meter. If the value is appended with R, the position is relative to the bottom/right edge of the previous meter.

Example:
X=10R : Meter begins 10 horizontal pixels to the right of the previous meter.
Y=0r : Meter begins at the same vertical position as the previous meter.
Anyways, here is a simplified version of your code.

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]
CurrentFBQuote="It's frightening that there's no guarantee that I'll be loved."#CRLF#- Akito Sohma
CurrentBSDQuote="I saw a bright world. I cannot go back to a time when I did not know such a thing existed."#CRLF#- Kyouka Izumi
CurrentKJQuote=haha

Index=1
Index1=FB
Index2=BSD
Index3=KJ

CURRENTDATE=26/8

[Day]
Measure=Time
Format=%#d/%#m
DynamicVariables=1
IfMatch=#CURRENTDATE#
IfNotMatch=[!WriteKeyValue Variables CURRENTDATE "[Day]"][!EnableMeasureGroup Quotes][!UpdateMeasureGroup Quotes][!WriteKeyValue Variables CURRENTDATE "[&Day]"][!Refresh]

[FBQuotes]
Measure=Plugin
Plugin=QuotePlugin
PathName=C:\Users\ingri\OneDrive\Documents\- quotes -\fruitsbasketquotes.txt
Separator=";"
UpdateDivider=-1
Disabled=1
OnUpdateAction=[!WriteKeyValue Variables CurrentFBQuote "[FBQuotes]"][!SetVariable CurrentFBQuote "[FBQuotes]"][!UpdateMeter "QuoteMeter"][!Redraw]

[BSDQuotes]
Measure=Plugin
Plugin=QuotePlugin
PathName=C:\Users\ingri\OneDrive\Documents\- quotes -\bungouquotes.txt
Separator=";"
UpdateDivider=-1
Disabled=1
OnUpdateAction=[!WriteKeyValue Variables CurrentBSDQuote "[BSDQuotes]"][!SetVariable CurrentBSDQuote "[BSDQuotes]"][!UpdateMeter "QuoteMeter"][!Redraw]

[KJQuotes]
Measure=Plugin
Plugin=QuotePlugin
Pathname=C:\Users\ingri\OneDrive\Documents\- quotes -\kemonoquotes.txt
Separator=";"
UpdateDivider=-1
Disabled=1
OnUpdateAction=[!WriteKeyValue Variables CurrentKJQuote "[KJQuotes]"][!SetVariable CurrentKJQuote "[KJQuotes]"][!UpdateMeter "QuoteMeter"][!Redraw]

[BackgroundMeter]
Meter=Shape
Shape=Rectangle 0,0,315,200 | Fill Color 255, 255, 255, 0 | Stroke Color 255,255,255, 0

[QuoteMeter]
Meter=String
UpdateDivider=-1
Disabled=1
ClipString=2
Text=[#Current[#Index[#Index]]Quote]
FontSize=13
FontColor=255, 255, 255, 200
FontFace=Rajdhani
SolidColor=0,0,0,1
Y=60r
X=10r
W=300
AntiAlias=1
DynamicVariables=1

[CircleMeter1]
Meter=Shape
Y=R
Shape=Ellipse 130, 20, 5 | Fill Color 255, 255, 255, (#Index#=1?100:1) | Stroke Color 255, 255, 255, 100
DynamicVariables=1
LeftMouseUpAction=[!SetVariable Index 1][!UpdateMeter *][!Redraw]

[CircleMeter2]
Meter=Shape
Y=r
Shape=Ellipse 150, 20, 5 | Fill Color 255, 255, 255, (#Index#=2?100:1) | Stroke Color 255, 255, 255, 100
DynamicVariables=1 
LeftMouseUpAction=[!SetVariable Index 2][!UpdateMeter *][!Redraw]

[CircleMeter3]
Meter=Shape
Y=r
Shape=Ellipse 170, 20, 5 | Fill Color 255, 255, 255, (#Index#=3?100:1) | Stroke Color 255, 255, 255, 100
DynamicVariables=1 
LeftMouseUpAction=[!SetVariable Index 3][!UpdateMeter *][!Redraw]
Edit:
See that I changed OnChangeAction on [Date] to IfMatch. This changes the quotes even if you shutdown your system and turn it on the next day. And ofc I changed the update to 1000.

P.S. Can I have the quotes?
from the Realm of Death
ingridd
Posts: 17
Joined: June 20th, 2021, 1:38 am

Re: Nesting variables inside strings that are set as the values for other variables

Post by ingridd »

death.crafter wrote: August 26th, 2021, 3:08 pm He meant using relative positioning.

Edit:
See that I changed OnChangeAction on [Date] to IfMatch. This changes the quotes even if you shutdown your system and turn it on the next day. And ofc I changed the update to 1000.

P.S. Can I have the quotes?
here are the quotes~
kemonoquotes.txt
bungouquotes.txt
fruitsbasketquotes.txt
as to using relative positioning, im not really sure how i can use it here, since i cant set the Y position of the Shape of CircleMeter to be __r.

p.s. i tried simplifying things before by just using [QuoteMeter:H]+[QuoteMeter:Y]+20 as the Y position of the Shape of CircleMeters, but i found out that the values of [QuoteMeter:H] and [QuoteMeter:Y] do not get updated at the same rate as the QuoteMeter - as in, when the quote is changed after clicking onto the circles, the values of [QuoteMeter:H] and [QuoteMeter:Y] are still the height/y-position of the previous quote and they kind of lag behind at a gap of 1 quote.

(sorry if im explaining it clumsily TT)
You do not have the required permissions to view the files attached to this post.
User avatar
CodeCode
Posts: 1365
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Nesting variables inside strings that are set as the values for other variables

Post by CodeCode »

Have you tried the Relative positioning yet?

The way it works is not by x or y but the relative position of any meter that is visible (can be hidden)) to the lowest Y position unless you do a -45R which would move the positioning up by 45 pixels. The more common use is to do it from the default bottom or right Y or x respectively.

That is why it seemed like a solution since the relative bottom of your quotes is dynamic and the R only cares about the bottom or right edges.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
ingridd
Posts: 17
Joined: June 20th, 2021, 1:38 am

Re: Nesting variables inside strings that are set as the values for other variables

Post by ingridd »

CodeCode wrote: August 27th, 2021, 2:48 am Have you tried the Relative positioning yet?

The way it works is not by x or y but the relative position of any meter that is visible (can be hidden)) to the lowest Y position unless you do a -45R which would move the positioning up by 45 pixels. The more common use is to do it from the default bottom or right Y or x respectively.

That is why it seemed like a solution since the relative bottom of your quotes is dynamic and the R only cares about the bottom or right edges.
ah that fixed it thanks a lot! sorry i didnt know
User avatar
CodeCode
Posts: 1365
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Nesting variables inside strings that are set as the values for other variables

Post by CodeCode »

ingridd wrote: August 27th, 2021, 4:41 am ah that fixed it thanks a lot! sorry i didnt know
Glad you got it sorted.

Keep the questions coming, we love fixing or creating solutions, in addition to the basic manual.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.