It is currently September 20th, 2020, 9:15 pm

Send the name of the script

Discuss the use of Lua in Script measures.
User avatar
Callisto
Posts: 25
Joined: January 8th, 2013, 11:42 pm
Location: Russia, Novo-Nikolayevsk

Send the name of the script

Post by Callisto »

Hello.
Is it possible to send the Lua script name of the meters?

Code: Select all

[Ms_Script]
Measure=Script
ScriptFile=#@#Script.lua
UpdateDivider=-1

[m_Title]
Meter=String
MeterStyle=s_Title
LeftMouseUpAction=  --> Send name
User avatar
balala
Rainmeter Sage
Posts: 11369
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Send the name of the script

Post by balala »

Not sure what you'd like, but if I'm not wrong, you'd like to update the script measure with a click. If I'm right, you don't have to send anything, just use this LeftMouseUpAction on the [m_Title] meter: LeftMouseUpAction=[!UpdateMeasure "Ms_Script"]. Eg, the following Script.lua, returns a random number between 1 and 10:

Code: Select all

function Initialize()
end

function Update()
	local Ran = math.random(1, 10)
	SKIN:Bang('!SetVariable', 'Var', Ran)
end
The asociated ini file:

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=80,80,80,200
AccurateText=1
DynamicWindowSize=1
Blur=1

[Ms_Script]
Measure=Script
ScriptFile=#@#Script.lua
DynamicVariables=1
UpdateDivider=-1

[m_Title]
Meter=STRING
X=0
Y=0
PAdding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0
FontSize=12
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=#Var#
DynamicVariables=1
LeftMouseUpAction=[!UpdateMeasure "Ms_Script"]
When you click, the [Ms_Script] is updated, so a new value is returned.
So, am I right?
User avatar
Callisto
Posts: 25
Joined: January 8th, 2013, 11:42 pm
Location: Russia, Novo-Nikolayevsk

Re: Send the name of the script

Post by Callisto »

balala, I need a little more :)

I have exactly the name of a meter. To continue to work with him.
Now I am doing something like this:

Code: Select all

[Ms_Script]
Measure=Script
ScriptFile=#@#Script.lua
UpdateDivider=-1

[m_Title1]
Meter=String
MeterStyle=s_Title
LeftMouseUpAction=[!CommandMeasure my_function(1)]

[m_Title2]
Meter=String
MeterStyle=s_Title
LeftMouseUpAction=[!CommandMeasure my_function(2)]

Code: Select all

function my_function(a)
	if a == 1 then
		metername = 'm_Title1'
	elseif a == 2 then
		metername = 'm_Title2'
	end
	SKIN:Bang('!Hidemeter', metername )
end
But we want to transfer immediately the name of the meters
User avatar
balala
Rainmeter Sage
Posts: 11369
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Send the name of the script

Post by balala »

Looking at your code, I think you want to run the my_function function of the script, with two different parameters. Am I right? If so, I'd change the value of a variable with the LeftMouseUpAction, then read that variable into the script and execute the proper action:

Code: Select all

[Ms_Script]
Measure=Script
ScriptFile=#@#Script.lua
DynamicVariables=1
UpdateDivider=-1

[m_Title1]
Meter=String
Text=First
MeterStyle=s_Title
LeftMouseUpAction=[!SetVariable Var "1"][!UpdateMeasure "Ms_Script"]

[m_Title2]
Meter=String
Text=Second
MeterStyle=s_Title
LeftMouseUpAction=[!SetVariable Var "2"][!UpdateMeasure "Ms_Script"]
Script.lua:

Code: Select all

function Initialize()
end

function my_function(a)
	if a == 1 then
		metername = 'm_Title1'
	elseif a == 2 then
		metername = 'm_Title2'
	end
	SKIN:Bang('!Hidemeter', metername)
end

function Update()
	local Variab = tonumber(SKIN:GetVariable('Var'))
	my_function(Variab)
end
User avatar
Callisto
Posts: 25
Joined: January 8th, 2013, 11:42 pm
Location: Russia, Novo-Nikolayevsk

Re: Send the name of the script

Post by Callisto »

Thanks.

Such a method and decided to use :)
User avatar
balala
Rainmeter Sage
Posts: 11369
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Send the name of the script

Post by balala »

You're welcome.