It is currently March 29th, 2024, 6:27 am

Delayed comparison?

Get help with creating, editing & fixing problems with skins
ItsJustRyan
Posts: 81
Joined: October 25th, 2019, 1:20 am

Delayed comparison?

Post by ItsJustRyan »

Hi!
I wanted to make kind of a rhythym bar thing where it compares the bass output now vs the instance before it, and if the difference is high enough it will do something. How do I make it store the value of that instance before now?
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Delayed comparison?

Post by mak_kawa »

I am not sure what you exactly want. But generally speaking, you can use [!SetVariable SomeVariable AnotherVariable] bang to store value "before now".

For example, following code stores former random value and compare current value with the former value.

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=128,128,128,192

[Variables]
CurrentRandom=0
FormerRandom=0
Difference=0
DifferenceThreshold=50
DifferenceStatus=""

[MeasureRandom]
Measure=Calc
Formula=Random
UniqueRandom=1
LowBound=1
HighBound=100
OnUpdateAction=[!SetVariable FormerRandom #CurrentRandom#][!SetVariable CurrentRandom [MeasureRandom]]
DynamicVariables=1

[DifferenceCheck]
Measure=Calc
Formula=Abs(#CurrentRandom#-#FormerRandom#)
IfCondition=#CURRENTSECTION#>#DifferenceThreshold#
IfTrueAction=[!SetVariable DifferenceStatus "Different!!"][!SetOption MeterDifferenceStatus FontColor 255,0,0,255]
IfFalseAction=[!SetVariable DifferenceStatus "Not so different..."][!SetOption MeterDifferenceStatus FontColor 64,64,64,255]
DynamicVariables=1

[MeterDisplay]
Meter=String
MeasureName=MeasureRandom
X=5
Y=5
W=150
H=30
Text=CurrentValue: %1#CRLF#FormerValue: #FormerRandom#
DynamicVariables=1

[MeterDifference]
Meter=String
MeasureName=DifferenceCheck
X=5
Y=40
W=150
H=20
StringStyle=Bold
Text="  -> Difference: %1"

[MeterDifferenceStatus]
Meter=String
X=5
Y=60
W=150
H=20
StringStyle=Bold
Text="(#DifferenceStatus#)"
DynamicVariables=1
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Delayed comparison?

Post by jsmorley »

Maybe something like this:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
OldValue=0

[MeasureRandom]
Measure=Calc
Formula=Random
LowBound=1
HighBound=50
UpdateRandom=1
UpdateDivider=5
OnChangeAction=[!UpdateMeasure MeasureCompare]

[MeasureCompare]
Measure=Calc
DynamicVariables=1
UpdateDivider=-1
IfCondition=MeasureRandom > #OldValue#
IfTrueAction=[!SetOption MeterString Text "New value [MeasureRandom] is greater than old value #OldValue#][!SetVariable OldValue [MeasureRandom]][!UpdateMeter *][!Redraw]
IfCondition2=MeasureRandom < #OldValue#
IfTrueAction2=[!SetOption MeterString Text "New value [MeasureRandom] is less than old value #OldValue#][!SetVariable OldValue [MeasureRandom]][!UpdateMeter *][!Redraw]
IfCondition3=MeasureRandom = #OldValue#
IfTrueAction3=[!SetOption MeterString Text "New value [MeasureRandom] is equal to old value #OldValue#][!SetVariable OldValue [MeasureRandom]][!UpdateMeter *][!Redraw]

[MeterString]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1

Edit: Sorry mak_kawa, I didn't see your response. That is a similar way to go about it.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Delayed comparison?

Post by balala »

mak_kawa wrote: November 28th, 2019, 1:37 am For example, following code stores former random value and compare current value with the former value.
I'd not add an Abs function to the Formula option of the [DifferenceCheck] measure, because the difference can be even negative, when the current value is lower then the former one. So instead of Formula=Abs(#CurrentRandom#-#FormerRandom#)
, I'd use Formula=(#CurrentRandom#-#FormerRandom#).
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Delayed comparison?

Post by balala »

jsmorley wrote: November 28th, 2019, 1:42 am Maybe something like this:
I think the [MeasureCompare] measure isn't even needed, it can be done with one single measure:

Code: Select all

[MeasureRandom]
Measure=Calc
Formula=Random
LowBound=1
HighBound=50
UpdateRandom=1
UpdateDivider=5
DynamicVariables=1
IfCondition=MeasureRandom > #OldValue#
IfTrueAction=[!SetOption MeterString Text "New value [MeasureRandom] is greater than old value #OldValue#"][!SetVariable OldValue [MeasureRandom]][!UpdateMeter *][!Redraw]
IfCondition2=MeasureRandom < #OldValue#
IfTrueAction2=[!SetOption MeterString Text "New value [MeasureRandom] is less than old value #OldValue#"][!SetVariable OldValue [MeasureRandom]][!UpdateMeter *][!Redraw]
IfCondition3=MeasureRandom = #OldValue#
IfTrueAction3=[!SetOption MeterString Text "New value [MeasureRandom] is equal to old value #OldValue#"][!SetVariable OldValue [MeasureRandom]][!UpdateMeter *][!Redraw]
Because the less measures, the better.
Also note the missing quotes at the end of the texts which are set through the !SetOption bangs. I also added them.