It is currently March 29th, 2024, 12:26 am

[#BUG]GetMeter:GetOption in Inline Lua and MeterStyle

Report bugs with the Rainmeter application and suggest features.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

[#BUG]GetMeter:GetOption in Inline Lua and MeterStyle

Post by death.crafter »

So Jax, a friend of mine has discovered a bug in inline lua. It messes up the other options in a meterstyle in the meter where it is used.

In the current example it messes up StringAlign( in a nutshell, Right,Center=LeftTop || RightCenter, CenterCenter = LeftCenter

BUG
The function is:

Code: Select all

function Y()
    local Meter = SKIN:GetMeter('Textbox')
	local GetVar = Meter:GetOption('Shape', 'Error')
    return GetVar
end
The skin:

Code: Select all

[X]
Measure=Script
ScriptFile=Tester.lua

[MeterStyle]
X=100r
Y=25r
StringAlign=CenterCenter
AntiAlias=1
FontSize=20
Padding=5,5,5,5
SolidColor=FFFFFF
Text=[&X:Y()]
DynamicVariables=1

[Textbox]
Meter=Shape
Shape=Rectangle 0,0,200,50

[Textbox.Text]
Meter=String
MeterStyle=MeterStyle
Preview( with meter style):
meterstyle.png
These work normally:
If meterstyle is not used, the skin works normally:

The skin:

Code: Select all

[X]
Measure=Script
ScriptFile=Tester.lua

[Textbox]
Meter=Shape
Shape=Rectangle 0,0,200,50

[Textbox.Text]
Meter=String
X=100r
Y=25r
StringAlign=CenterCenter
AntiAlias=1
FontSize=20
Padding=5,5,5,5
SolidColor=FFFFFF
Text=[&X:Y()]
DynamicVariables=1
Preview(without meterstyle):
nometerstyle.png
And also this function works as expected( with GetMeasure) with or without meterstyle:

Code: Select all

function Y()
    local Meter = SKIN:GetMeasure('X')
	local GetVar = Meter:GetOption('ScriptFile', 'Error')
    return GetVar
end
Preview(with meterstyle but with GetMeasure):
getmeasure.png
You do not have the required permissions to view the files attached to this post.
from the Realm of Death
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [#BUG]GetMeter:GetOption in Inline Lua and MeterStyle

Post by Yincognito »

death.crafter wrote: July 13th, 2021, 3:07 pmSo Jax, a friend of mine has discovered a bug in inline lua. It messes up the other options in a meterstyle in the meter where it is used.
Not sure when your friend Jax discovered this, but if it didn't happen more than 3 months ago, I'll claim the "Christopher Columbus" award for this one... :lol: See the last paragraph of this post - what do you think, could it be the same problem/bug?
There is one problem though, or maybe I'm missing something here: when uncommenting the 2nd Text options and commenting the 1st ones in the meters, the font and its size is reset.
Meter2 there also had a MeterStyle, and inline Lua was also involved, just like :GetOption().
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: [#BUG]GetMeter:GetOption in Inline Lua and MeterStyle

Post by death.crafter »

Yincognito wrote: July 13th, 2021, 4:30 pm Not sure when your friend Jax discovered this, but if it didn't happen more than 3 months ago, I'll claim the "Christopher Columbus" award for this one... :lol: See the last paragraph of this post - what do you think, could it be the same problem/bug?

Meter2 there also had a MeterStyle, and inline Lua was also involved, just like :GetOption().
It is indeed. And what's more weird is, GetMeasure works fine.
But since he reported the bug(well, indirectly), he gets the OverLord position 8-)
:rolmfao:
P.S. Jax was doing exactly what you were doing in the above case.
from the Realm of Death
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [#BUG]GetMeter:GetOption in Inline Lua and MeterStyle

Post by Yincognito »

death.crafter wrote: July 13th, 2021, 4:40 pm It is indeed. And what's more weird is, GetMeasure works fine.
But since he reported the bug(well, indirectly), he gets the OverLord position 8-)
:rolmfao:
P.S. Jax was doing exactly what you were doing in the above case.
Ah, ok - nice. At that time I thought that it was because I added a non-standard "custom option" to that meter. That was partly the reason I gave up using Jeff's :GetOption and SKIN:GetMeasure/SKIN:GetMeter approach and went the plain string route in my section index approach. ;-)

Ok, I'll give your friend Jax the honours, LOL.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: [#BUG]GetMeter:GetOption in Inline Lua and MeterStyle

Post by death.crafter »

Yincognito wrote: July 13th, 2021, 4:51 pm Ah, ok - nice. At that time I thought that it was because I added a non-standard "custom option" to that meter. That was partly the reason I gave up using Jeff's :GetOption and SKIN:GetMeasure/SKIN:GetMeter approach and went the plain string route in my section index approach. ;-)
Actually I thought that as well. But when I tried this without a custom option and it still wielded the same results. So I guess more work for the devs.
from the Realm of Death
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [#BUG]GetMeter:GetOption in Inline Lua and MeterStyle

Post by Yincognito »

death.crafter wrote: July 13th, 2021, 5:26 pm Actually I thought that as well. But when I tried this without a custom option and it still wielded the same results. So I guess more work for the devs.
Now that you posted this in a different way than I encountered it, maybe it has to do with either Lua not "parsing" / "replacing" the meter style with its actual content properly or executing both Rainmeter native code and inline Lua on the meter at roughly the same time somehow conflicting with each other.

Have you tried this on other meter types, other than String, by the way? Or changing the options order to see if the effect is order related or option related? I'm saying this because even back then I found it odd that only certain things got "broken" while others didn't suffer any negative effects (e.g. X, Y, etc)...
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
EnhancedJax
Posts: 19
Joined: October 17th, 2020, 11:57 am

Re: [#BUG]GetMeter:GetOption in Inline Lua and MeterStyle

Post by EnhancedJax »

Hey, Jax here. Thankyou deathCrafter for posting this problem on the forums :D
Have you tried this on other meter types, other than String, by the way? Or changing the options order to see if the effect is order related or option related? I'm saying this because even back then I found it odd that only certain things got "broken" while others didn't suffer any negative effects (e.g. X, Y, etc)...
I've tested the same inline lua with different types of meters. Here are the results
-Image meter and shape meter works properly
-With W/H of string meter set to inlineLua, AntiAlias / FontSize stops working property, while FontWeight / FontColor / SolidColor / XY works properly, regardless of where the W/H options are put in the meter section

Code: Select all

[X]
Measure=Script
ScriptFile=Test.lua

[MeterStyle]
X=100r
Y=25r
W=[&X:Y()]
H=[&X:Y()]
; W=200
StringAlign=CenterCenter
AntiAlias=1
FontSize=40
FOntWeight=900
Text=[&X:Y()]
SolidColor=255,255,255,70
FontColor=255,255,255
DynamicVariables=1

[Textbox]
Meter=Shape
Get=100
Shape=Rectangle 0,0,200,50 | Fill Color 25,25,25

[Textbox.Text]
Meter=String
MeterStyle=MeterStyle

[Textbox.image]
Meter=Image
SolidColor=255,255,255,70
Y=50
W=[&X:Y()]
H=[&X:Y()]
DynamicVariables=1

[Textbox.Shape]
Meter=Shape
X=R
Y=r
Shape=Rectangle 0,0,[&X:Y()],[&X:Y()]
DynamicVariables=1
P.S. I am kind of new to the whole forums thing, so may I ask how to upload an image from local files?
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [#BUG]GetMeter:GetOption in Inline Lua and MeterStyle

Post by Yincognito »

EnhancedJax wrote: July 14th, 2021, 3:01 amP.S. I am kind of new to the whole forums thing, so may I ask how to upload an image from local files?
Just add an Attachment, below the Preview & Submit buttons, and place it Inline wherever you need in the message text. You can also attach Gifs if you want to illustrate animations, though in this case you'll need to convert your screen captured video to a GIF first, using free online tools / sites.

Thanks for testing out things, maybe it will help the devs identify and fix the issue better. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Brian
Developer
Posts: 2674
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: [#BUG]GetMeter:GetOption in Inline Lua and MeterStyle

Post by Brian »

Thank you for reporting! This has been fixed for the next beta.

-Brian
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [#BUG]GetMeter:GetOption in Inline Lua and MeterStyle

Post by Yincognito »

Brian wrote: July 22nd, 2021, 6:55 am Thank you for reporting! This has been fixed for the next beta.

-Brian
Thanks, Brian! :rosegift:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth