It is currently July 15th, 2019, 9:14 pm

[HELP] Test whether Meter is hidden or visible

Discuss the use of Lua in Script measures.
User avatar
smurfier
Moderator
Posts: 1937
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

[HELP] Test whether Meter is hidden or visible

smurfier » September 23rd, 2011, 11:42 pm

Is there a way to find whether a meter is hidden or visible?

I would prefer not having to use a variable to accomplish what I desire.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
Kaelri
Developer
Posts: 1739
Joined: July 25th, 2009, 4:47 am

Re: Test whether Meter is hidden or visible

Kaelri » September 24th, 2011, 12:13 am

You can do this with Lua:

Code: Select all

mMeter = SKIN:GetMeter('MeterName')
sHidden = mMeter:GetOption('Hidden')
Note that if the meter doesn't actually have a "Hidden" key, the GetOption() will initially return a blank string, so you may need/want to set "Hidden=0" on the relevant meters, depending on what you're trying to do.

EDIT: Sorry, I may be wrong about this. Hiding the meter with !HideMeter isn't changing the returned value in my test skin. Gonna play with it some more.
User avatar
smurfier
Moderator
Posts: 1937
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Test whether Meter is hidden or visible

smurfier » September 24th, 2011, 12:16 am

When I tried that then used !HideMeterGroup or !HideMeter, nothing was returned.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
jsmorley
Developer
Posts: 19287
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Test whether Meter is hidden or visible

jsmorley » September 24th, 2011, 12:17 am

mtMeterTwo = SKIN:GetMeter("MeterTwo")
iMeterTwoHidden = mtMeterTwo:GetW()

You can also test for the width of a meter. A hidden meter will always be 0.
User avatar
Kaelri
Developer
Posts: 1739
Joined: July 25th, 2009, 4:47 am

Re: Test whether Meter is hidden or visible

Kaelri » September 24th, 2011, 12:19 am

smurfier wrote:When I tried that then used !HideMeterGroup or !HideMeter, nothing was returned.
Yeah, I had the same result. See my edited post.

Ironically, although "!SetOption Meter Hidden 1" does not work to hide the meter, it does actually change the value of the "option."
User avatar
jsmorley
Developer
Posts: 19287
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Test whether Meter is hidden or visible

jsmorley » September 24th, 2011, 12:23 am

Trouble with GetOption("Hidden") is that "Hidden", like MeasureName, is not one you can set with !SetOption, and GetOption in Lua will not see !HideMeter as changing the "option", so it will never change in Lua.

The width thing was the only reliable thing I found so far.

Edit: Ah. I see that Lua does see the change to the "option", but it doesn't really help as !SetOption Meter Hidden 1 doesn't actually hide the meter.
User avatar
Kaelri
Developer
Posts: 1739
Joined: July 25th, 2009, 4:47 am

Re: Test whether Meter is hidden or visible

Kaelri » September 24th, 2011, 12:26 am

jsmorley wrote:Trouble with GetOption("Hidden") is that "Hidden", like MeasureName, is not one you can set with !SetOption, and GetOption in Lua will not see !HideMeter as changing the "option", so it will never change in Lua.
Right. Each other property that isn't affected by !SetOption has its own "get" function in Lua (XYWH), so if possible, we should probably add a GetHidden() function as well.
fanielthefan
Posts: 2
Joined: March 15th, 2019, 2:07 pm

Re: Test whether Meter is hidden or visible

fanielthefan » March 15th, 2019, 2:50 pm

jsmorley wrote:
September 24th, 2011, 12:17 am
mtMeterTwo = SKIN:GetMeter("MeterTwo")
iMeterTwoHidden = mtMeterTwo:GetW()

You can also test for the width of a meter. A hidden meter will always be 0.
I'm sorry, sort of new.
Where do i place these lines? This is exactly what i was looking for when i came to this thread but I'm still learning lua.
https://ibb.co/H7gkf0q
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 19287
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [HELP] Test whether Meter is hidden or visible

jsmorley » March 15th, 2019, 3:23 pm

I'd need to know a bit more about what you are trying to accomplish. It may be that Lua is part of the answer, but maybe not.
User avatar
jsmorley
Developer
Posts: 19287
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [HELP] Test whether Meter is hidden or visible

jsmorley » March 15th, 2019, 3:51 pm

You might do something like this to detect a hidden meter using Lua:

Skin:

Code: Select all

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

[Lua]
Measure=Script
ScriptFile=#CURRENTPATH#Test.lua
Disabled=1

[MeterOne]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Hello World

[MeterTwo]
Meter=String
Y=30
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Text=[&Lua:IsHidden('MeterOne')]
LeftMouseUpAction=[!ToggleMeter MeterOne][!UpdateMeter *][!Redraw]

Test.Lua:

Code: Select all

function IsHidden(meterArg)

	meterHandle = SKIN:GetMeter(meterArg)
	
	hiddenState = meterHandle:GetOption('Hidden', '0')
	
	if hiddenState == '1' then
		return meterArg.. ' is Hidden'
	else
		return meterArg.. ' is not Hidden'
	end

end

GIF.gif
You do not have the required permissions to view the files attached to this post.