It is currently April 26th, 2024, 11:59 pm

[Not Solved] Measure: Help with Percentage Input Problem

Get help with creating, editing & fixing problems with skins
User avatar
JosephB2000
Posts: 155
Joined: July 29th, 2014, 7:02 pm

[Not Solved] Measure: Help with Percentage Input Problem

Post by JosephB2000 »

I am making a skin with a meter that includes a SolidColor, and I want to implement an 'opacity' option to this meter.

The only problem I have is that:
I want a measure to calculate how much the opacity is set to, and change it depending on what is put. By that, I mean if someone puts 110, then the measure would set it to 100, and if it is -50, then the measure would set it to 0 etc.
Here is the skin's .ini:

Code: Select all

[Variables]
Input=10
Output=(#Input# * (255 / 100))

[Background]
Meter=String
.
.
SolidColor=255,255,255,#Output#

[MeasurePercentage]
Measure=Calc
Formula=#Input#
IfCondition=[MeasurePercentage] > 100
IfTrueAction=[!WriteKeyValue Variables Input 100][!Refresh]
IfCondition2=[MeasurePercentage] < 0
IfTrueAction=[!WriteKeyValue Variables Input 0][!Refresh]
[Insert Joke Here]
User avatar
killall-q
Posts: 305
Joined: August 14th, 2009, 8:04 am

Re: [Not Solved] Measure: Help with Percentage Input Problem

Post by killall-q »

Remove the brackets in IfCondition. See the example in the doc.

Code: Select all

IfCondition=MeasurePercentage > 100
IfCondition2=MeasurePercentage < 0
User avatar
JosephB2000
Posts: 155
Joined: July 29th, 2014, 7:02 pm

Re: [Not Solved] Measure: Help with Percentage Input Problem

Post by JosephB2000 »

Still doesn't want to work.

Here is the new measure:

Code: Select all

[MeasurePercentage]
Measure=Calc
Formula=#Input#
IfCondition=MeasurePercentage > 100
IfTrueAction=[!WriteKeyValue Variables Input 100][!Refresh]
IfCondition2=MeasurePercentage < 0
IfTrueAction=[!WriteKeyValue Variables Input 0][!Refresh]
Though I have discovered something, when I set the opacity to 110, the opacity is actually set to 10, and if I put 130, then it would be set to 30...

I am still having the situation of the measure not working!
[Insert Joke Here]
prince1142003
Posts: 56
Joined: December 27th, 2011, 12:32 pm

Re: [Not Solved] Measure: Help with Percentage Input Problem

Post by prince1142003 »

If you get the latest 3.2 Beta, there is a Clamp function that would make this easier.

Code: Select all

[Variables]
Input=10
Output=(Clamp(#Input#,0,100)*255/100)

[Background]
Meter=String
.
.
SolidColor=255,255,255,#Output#
User avatar
killall-q
Posts: 305
Joined: August 14th, 2009, 8:04 am

Re: [Not Solved] Measure: Help with Percentage Input Problem

Post by killall-q »

The same thing could have been accomplished before using ternary. I can perhaps see the ease of use of Clamp(), but Min() and Max() barely simplify anything.

You need DynamicVariables=1 to use formulas in place of static values.

Code: Select all

[Background]
...
SolidColor=255,255,255,((#Input#>100?100:(#Input#<0?0:#Input#))*2.55)
DynamicVariables=1
prince1142003
Posts: 56
Joined: December 27th, 2011, 12:32 pm

Re: [Not Solved] Measure: Help with Percentage Input Problem

Post by prince1142003 »

Agreed. Clamp just provides a way of preventing the formula from getting over-complicated. There's usually more than on way of doing things in Rainmeter, which one to use depends on the person writing the skin.