Is there any easy way to check if a certain section exists in the skin?
The only way i can imagine to do this is parse through the skin.ini looking for [section].
It is currently April 19th, 2024, 8:26 am
[HELP] Check if a [section] exists
-
- Moderator
- Posts: 1931
- Joined: January 29th, 2010, 1:43 am
- Location: Willmar, MN
[HELP] Check if a [section] exists
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 . . .
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 . . .
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Check if a [section] exists
If you know the name you are looking for, then just:smurfier wrote:Is there any easy way to check if a certain section exists in the skin?
The only way i can imagine to do this is parse through the skin.ini looking for [section].
msIsMeasure = SKIN:GetMeasure("MeasureName")
if not msIsMeasure then print("FUBAR") end
Or even this should work:
if not SKIN:GetMeasure("MeasureName") then print("You were eaten by a grue")
-
- Moderator
- Posts: 1931
- Joined: January 29th, 2010, 1:43 am
- Location: Willmar, MN
Re: Check if a [section] exists
Even if I'm checking for a certain Meter Style?
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 . . .
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 . . .
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Check if a [section] exists
No, it will only work with meters and measures. Parse away...smurfier wrote:Even if I'm checking for a certain Meter Style?
You could always add the MeterStyle name as a variable or as a "setting" on the script measure. Then you could test for it easy enough. I suspect there is some good reason why a script you wrote to go with a skin you wrote doesn't know what is in the skin...
-
- Moderator
- Posts: 1931
- Joined: January 29th, 2010, 1:43 am
- Location: Willmar, MN
Re: Check if a [section] exists
fun...
Before I go through all that work, is there any problem with setting MeterStyle to a non-existent style? I tried earlier and Rainmeter froze, but something tells me it wasn't what I was doing at the time.
Before I go through all that work, is there any problem with setting MeterStyle to a non-existent style? I tried earlier and Rainmeter froze, but something tells me it wasn't what I was doing at the time.
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 . . .
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 . . .
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Check if a [section] exists
Not sure what that would do. By the way, another thought occurred to me. A MeterStyle can also be a meter...smurfier wrote:fun...
Before I go through all that work, is there any problem with setting MeterStyle to a non-existent style? I tried earlier and Rainmeter froze, but something tells me it wasn't what I was doing at the time.
[MyStyle]
Meter=String
FontSize=10
FontColor=FFFFFF
X=0
Y=2R
Just don't have it display any actual text of any kind (and preferably don't give it any width or height) and you can then use it as a style in other meters, and test for it from Lua with
if not SKIN:GetMeter("MyStyle") then print("I'm sorry Dave, I can't do that")
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Check if a [section] exists
One side benefit of doing that is that you can then use "GetOption" from Lua and actually read all the values for the style too.
-
- Developer
- Posts: 1721
- Joined: July 25th, 2009, 4:47 am
Re: Check if a [section] exists
Looks ok to me. Test skin:smurfier wrote:Before I go through all that work, is there any problem with setting MeterStyle to a non-existent style? I tried earlier and Rainmeter froze, but something tells me it wasn't what I was doing at the time.
Code: Select all
[Rainmeter]
BackgroundMode=2
SolidColor=0,0,0,128
W=300
H=200
; [MeterStyle1]
; FontSize=25
[MeterStyle2]
FontColor=255,0,0
FontSize=50
[Null]
Meter=String
MeterStyle=MeterStyle1
FontColor=ffffff
Text=Hi
W=300
H=200
LeftMouseUpAction=!SetOption Null MeterStyle "MeterStyle2"
-
- Moderator
- Posts: 1931
- Joined: January 29th, 2010, 1:43 am
- Location: Willmar, MN
Re: Check if a [section] exists
I'm working on making LuaCalendar more customizable using MeterStyles. I need to make certain options optional. Also, through my somewhat brief existence I've learned that these things need to be as idiot proof and user friendly as possible.
I believe the easiest approach to my predicament is to have the user pass the names of the optional meterstyles to the script as options.
I believe the easiest approach to my predicament is to have the user pass the names of the optional meterstyles to the script as options.
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 . . .
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 . . .
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Check if a [section] exists
Certainly the most reliable. Well, at least you can blame them if they mess it up, instead of them blaming you...smurfier wrote:I'm working on making LuaCalendar more customizable using MeterStyles. I need to make certain options optional. Also, through my somewhat brief existence I've learned that these things need to be as idiot proof and user friendly as possible.
I believe the easiest approach to my predicament is to have the user pass the names of the optional meterstyles to the script as options.