It is currently June 25th, 2019, 6:30 am

Meter Name ?

Discuss the use of Lua in Script measures.
sobaka
Posts: 9
Joined: September 30th, 2011, 6:56 am

Meter Name ?

sobaka » December 29th, 2013, 6:59 am

Hi All !!!

example:
in - .ini
[scr]
measure=script
scriptfile=#currentpath#scr.lua
dynamicvariables=1
[icon_1]
meter=image
meterstyle=menu|icon
mouseoveraction=!execute [!commandmeasure "scr" "name=true"]
[icon_2]
meter=image
meterstyle=menu|icon
mouseoveraction=!execute [!commandmeasure "scr" "name=true"]
[icon_3]
meter=image
meterstyle=menu|icon
mouseoveraction=!execute [!commandmeasure "scr" "name=true"]

script

function Update()
if name
then
for num = 1,3
scr_name=SKIN:GetMeter("icon_"..num)
n = scr_name:GetName() <-- get names

if a = n then
bla bla bla ...
end
end
end

should that be in "mouse over" command
script variable becomes equal number of meter ...
-
then "mouse over"
on meter icon_1 > a = 1
on meter icon_2 > a = 2
on meter icon_3 > a = 3
...

please help :yawn: !

PS: sorry google translator :yawn: ...
User avatar
jsmorley
Developer
Posts: 19268
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Meter Name ?

jsmorley » December 29th, 2013, 12:10 pm

I'm not entirely sure what you are trying to do, but if you want to take some action based on the meter that the mouse is over, you might look at something like:

Skin:

Code: Select all

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

[MeasureScript]
Measure=Script
ScriptFile=#CURRENTPATH#Test.lua
UpdateDivider=-1

[MeterDisplay]
Meter=String
FontSize=12
FontColor=255,255,255,255
AntiAlias=1
Text=Meter Name:#CRLF#Meter Number:

[MeterIcon_1]
Meter=Image
Y=5R
W=20
H=20
SolidColor=47,47,47,255
MouseOverAction=[!CommandMeasure MeasureScript """GetName("#CURRENTSECTION#")"""]
MouseLeaveAction=[!SetOption MeterDisplay Text "Meter Name:#CRLF#Meter Number:"][!UpdateMeter MeterDisplay][!Redraw]

[MeterIcon_2]
Meter=Image
X=5R
Y=0r
W=20
H=20
SolidColor=47,47,47,255
MouseOverAction=[!CommandMeasure MeasureScript """GetName("#CURRENTSECTION#")"""]
MouseLeaveAction=[!SetOption MeterDisplay Text "Meter Name:#CRLF#Meter Number:"][!UpdateMeter MeterDisplay][!Redraw]

[MeterIcon_3]
Meter=Image
X=5R
Y=0r
W=20
H=20
SolidColor=47,47,47,255
MouseOverAction=[!CommandMeasure MeasureScript """GetName("#CURRENTSECTION#")"""]
MouseLeaveAction=[!SetOption MeterDisplay Text "Meter Name:#CRLF#Meter Number:"][!UpdateMeter MeterDisplay][!Redraw]
Test.lua:

Code: Select all

function Initialize()

end

function Update()

end

function GetName(meterArg)

	meterName = meterArg
	meterNum = meterName:match('_(%d+)')
	
	SKIN:Bang('!SetOption', 'MeterDisplay', 'Text', 'Meter Name: '..meterName..'#CRLF#Meter Number: '..meterNum)
	SKIN:Bang('!UpdateMeter', 'MeterDisplay')
	SKIN:Bang('!Redraw')

end
test.gif
You do not have the required permissions to view the files attached to this post.
sobaka
Posts: 9
Joined: September 30th, 2011, 6:56 am

Re: Meter Name ?

sobaka » December 29th, 2013, 11:04 pm

Many Еhanks!!!
I thought that it can be implemented through a table and comparing ... Thanks again ! :bow: ...