It is currently March 29th, 2024, 12:36 pm

trying to make meters appear with several If conditions

Get help with creating, editing & fixing problems with skins
User avatar
AlphaEdd
Posts: 11
Joined: November 24th, 2017, 12:51 am

trying to make meters appear with several If conditions

Post by AlphaEdd »

hello !
I'm kind of struggling to make a widged appear and dissapear as I wish !
I built a while ago a small widget that simply says "to draw next : [name of a character]" with a background and a reset button.
I had written it previously so it would measure a random number from 0 to 11, with each number tied to calc measures with If stuff that would then show a text meter for each value.
But thing is that now I want my widget to be hidden unless I'm hovering over the (always visible of course) reset button. While that was an okay task for all the non changing text and background, i still haven't figured it out for the changing text, since it needs to depend also of the random value rather than only the mouse hovering.
I tried setting said text meters in a group for hiding, but it'd override what I did with the value stuff, so all the text meters would display when hovering rather than just 1, resulting in a big blergh.

here are the parts of the code that are giving me an hard time :

Code: Select all

[measureRandom]
	Measure=calc
	Formula=Round(Random)
	LowBound=0
	HighBound=11
	Update=-1

[Button]
	Meter=IMAGE
	ImageName=#@#reset button.png
	LeftMouseUpAction=[!UpdateMeasure measureRandom][!Refresh]
	DynamicVariables=1
	X=110
	Y=10
	MouseOverAction=[!ShowMeterGroup Nonchangingstuff][!Redraw]
	MouseLeaveAction=[!HideMeterGroup Nonchangingstuff][!Redraw]

[meterEdd]
	Meter=String
	MeterStyle=styleTwo
	Text=edd
	FontSize=8
	X=54
	Y=40
	Hidden=1

[meterTom]
	Meter=String
	MeterStyle=styleTwo
	Text=tom
	FontSize=8
	X=54
	Y=40
	Hidden=1

[measureEdd]
Measure=calc
Formula=measureRandom
IfEqualValue = 0
IfEqualAction=!RainmeterShowMeter meterEdd

[measureTom]
Measure=calc
Formula=measureRandom
IfEqualValue = 1
IfEqualAction=!RainmeterShowMeter meterTom
(note : there are 12 not just 2 but you get the gist)

my goal is to find a way to add an additionnal if condition- or anything that would work, really, so that Edd meter would show only when the random value is 0 AND when my mouse is hovering over the reset button, and same for the Tom one exept it'd be for the value 1, and so on. think anyone could help me with that ??
Last edited by fonpaolo on November 24th, 2017, 12:44 pm, edited 1 time in total.
Reason: Please use the [Code] tags to display your code.
Image
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: trying to make meters appear with several If conditions

Post by balala »

The code is uselessly complicated in my opinion.
  • The Update option is valid only in the [Rainmeter] section. You've used a such option in the [measureRandom] measure, where you can't. Probably it should be an UpdateDivider option. So replace the Update=-1 option of the [measureRandom] measure with UpdateDivider=-1.
  • A Random function isn't update unless you're add an UpdateRandom=1 option to the measure. So, add this option to the [measureRandom] measure.
  • Don't refresh the skin every time you're clicking the button. Refresh is a quite destructive operation, you should have to avoid it, if it's possible (details). And here it is. Although it also can be done with a such option, I'd remove it from the LeftMouseUpAction option of the [Button] meter. Adding the above UpdateRandom=1 option will update the measure every time you're clicking the buton (through the [!UpdateMeasure measureRandom] bang).
  • You'll need just one single String meter. Keep one of them (eg the first one, [meterEdd]) and remove the others. All of them, excepting the first.
  • You should have to do this kept String meter to show the value returned by the [measureRandom] measure (also see the next point, where I'll tell you how to replace the number returned by the random function with the appropriate name). For this just add the MeasureName=measureRandom option and replace its Text option with Text=%1.
  • And finally to see not the numbers returned by the random function, but the character's name, add the following options to the [measureRandom] measure (keeping all other existing options):

    Code: Select all

    [measureRandom]
    ...
    RegExpSubstitute=1
    Substitute="^0$":"First character","^1$":"Second character","^2$":"Third character","^3$":"Fourth character","^4$":"Fifth character","^5$":"Sixth character","^6$":"Seventh character","^7$":"Eighth character","^8$":"Ninth character","^9$":"Tenth character","^10$":"Eleventh character","^11$":"Twelweth character"
    This way the String meter will show you the character, instead of the number.
Please let me know if this solution works well for you.
User avatar
AlphaEdd
Posts: 11
Joined: November 24th, 2017, 12:51 am

Re: trying to make meters appear with several If conditions

Post by AlphaEdd »

yes, it worked just perfectly !! thank you !! now all these silly drawing counters take much less space !!
Image
Image
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: trying to make meters appear with several If conditions

Post by balala »

I'm glad you got it working well.