It is currently March 28th, 2024, 10:32 am

Change Measure with LUA

Discuss the use of Lua in Script measures.
Post Reply
User avatar
krakoukas
Posts: 71
Joined: December 11th, 2018, 5:56 pm
Location: France
Contact:

Change Measure with LUA

Post by krakoukas »

Hi Friends,

I have a Torrent widget based on JSMorley workout here https://forum.rainmeter.net/viewtopic.php?f=5&t=31548&p=159546&hilit=torrent#p159546 . Thanks for his help so much ! Looks like this :

Image

The "126Ko/s" string down-right is the sum of all the actual download speeds ("Vitesse" in french).
It is generated with LUA.

Now I would like to have a LINE also, with this IRL value (126Ko/s)
The line is ready :

Code: Select all

		; UPLOAD TORRENT
		[Histogramme-UPLOAD-1]
		Meter=Line
		MeasureName=XXXXXXXXX
		LineColor=#Vert#
		X=r
		Y=r
		W=#LargeurHistogramme2#
		H=#HauteurHistogramme#
		AntiAlias=#AntiAliasHistogramme#
How can I change this MeasureName=XXXXXXXXX with LUA ?
Hope my English wasn't so rude
Thanks for your help !
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change Measure with LUA

Post by balala »

krakoukas wrote: July 10th, 2019, 7:19 pm How can I change this MeasureName=XXXXXXXXX with LUA ?
Why would you want to change it through a Lua script? It definitely can be done, but I1m not sure it worth. Can't you add the appropriate name of the measure directly to the code, without having to change it?
However if you anyway want to change it, first take into account you can change it directly from the code of the skin, using a !SetOption bang. When do you want to change it? Depending on this detail, you have to add somewhere the following bangs: [!SetOption Histogramme-UPLOAD-1 MeasureName "NAME-OF-THE-NEW-MEASURE"][!UpdateMeasure "Histogramme-UPLOAD-1"] (obviously, replace the NAME-OF-THE-NEW-MEASUREabove, with the appropriate name). When executed, these bangs change the MeasureName option and update the measure.
If you finally want to change it from the Lua code, you have to create a line to set similarly the MeasureName. Something like this: SKIN:Bang('!SetOption', 'Histogramme-UPLOAD-1', 'MeasureName', 'NAME-OF-THE-NEW-MEASURE'). Note the similar structure of the command.

Comment: there is no lua script involved into the provided skin, so definitely can't see why would you want to add one, just to change the above option.
User avatar
krakoukas
Posts: 71
Joined: December 11th, 2018, 5:56 pm
Location: France
Contact:

Re: Change Measure with LUA

Post by krakoukas »

balala wrote: July 10th, 2019, 8:12 pm Why would you want to change it through a Lua script? It definitely can be done, but I1m not sure it worth. Can't you add the appropriate name of the measure directly to the code, without having to change it?
Hi Balala and thank you

I can't add the appropriate name of the measure XXXXXX in the code because there is no measure.
In fact, a LUA script parses the local webUI of Torrent (an HTML page with datas) and displays titles and download speeds
The same LUA script calculates the sum of of download speeds (126Ko/s) known as TailleTotale

This value TailleTotale is not known in the INI skin, only in the LUA script.
I can drop the value through LUA in a Meter :

Code: Select all

SKIN:Bang("!SetOption MeterUPLOADText Text \""..TailleTotale.." Ko/s\"")
But I am not able to drop it in a Measure (in order to have a pretty line).
See below full LUA script (not very interesting). The Sum variable is known as TailleTotale

Code: Select all


function Initialize()
	
		dofile(SKIN:GetVariable('@')..'Scripts_Lua\\Torrent-General.lua')

	tItem = {}
	tHASH = {}
	tSTATUS = {}
	tNAME = {}
	tSIZE = {}
	tPERCENTPROGRESS = {}
	tDOWNLOADED = {}
	tUPLOADED = {}
	tRATIO = {}
	tUPLOADSPEED = {}
	tDOWNLOADSPEED = {}
	tETA = {}
	tLABEL = {}
	tPEERSCONNECTED = {}
	tPEERSINSWARM = {}
	tSEEDSCONNECTED = {}
	tSEEDSINSWARM = {}
	tAVAILABILITY = {}
	tTORRENTQUEUEORDER = {}
	tREMAINING = {}
	tField21 = {}
	tField22 = {}
	tTEXTSTATUS = {}
	tField24 = {}
	tField25 = {}
	tField26 = {}
	tField27 = {}
	tSAVEFOLDER = {}
	
	sNormalColor = SKIN:GetVariable("ListFontColor")
	sGreyColor = SKIN:GetVariable("GreyColor")
	RunningState = SKIN:GetMeasure("CalcTranslatePIDToRunningState")
	msMain = SKIN:GetMeasure("MeasureWebUI")
	CurrDir = SKIN:GetVariable("CURRENTPATH")
	
end -- function Initialize

function Update()

	IsRunning = RunningState:GetValue()
	
	if IsRunning == 1 then --uTorrent running
	
		Pos = 0
		Cpt = 1
		TailleTotale = 0
	
		sAllText = msMain:GetStringValue()
		sAllText = string.match(sAllText, ".-\034torrents\034%:(.-)$")
		sTemp, iItemCount = string.gsub(sAllText, ".-%[\"(.-)\"%]", "")
		
		--
		-- ICI 1/3 POUR LES ITERATIONS DE DOWNLOADS
		--
		iItemCount = (iItemCount < 301) and iItemCount or 300
		for i = 1, iItemCount do
	
			tItem[i] = "[\""..string.match(sAllText, ".-%[\"(.-)\"%]", Pos).."\"]"
			Pos = Pos + string.len(tItem[i])+1

			tHASH[i], tSTATUS[i], tNAME[i], tSIZE[i], tPERCENTPROGRESS[i], tDOWNLOADED[i], tUPLOADED[i], tRATIO[i], tUPLOADSPEED[i], tDOWNLOADSPEED[i], tETA[i], tLABEL[i], tPEERSCONNECTED[i], tPEERSINSWARM[i], tSEEDSCONNECTED[i], tSEEDSINSWARM[i], tAVAILABILITY[i], tTORRENTQUEUEORDER[i], tREMAINING[i], tField21[i], tField22[i], tTEXTSTATUS[i], tField24[i], tField25[i], tField26[i], tField27[i], tSAVEFOLDER[i] = string.match(tItem[i], '%[\"(.-)\",(.-),\"(.-)\",(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-),\"(.-)\",(.-),(.-),(.-),(.-),(.-),(.-),(.-),\"(.-)\",\"(.-)\",\"(.-)\",\"(.-)\",(.-),(.-),\"(.-)\",\"(.-)\".-%]')
		
			
			
			
		
			-- RENDRE INVISIBLE
			if (i>1) then
				SKIN:Bang("!SetOption Meter"..i.."Icone Y \"-1r\"")
			else
				SKIN:Bang("!SetOption Meter"..i.."Icone Y \"27\"")
			end
			SKIN:Bang("!HideMeter Meter"..i.."Icone")
			SKIN:Bang("!HideMeter Meter"..i.."DLSpeed")
			SKIN:Bang("!HideMeter Meter"..i.."Bar")
			SKIN:Bang("!HideMeter Meter"..i.."Status")
			SKIN:Bang("!HideMeter Meter"..i.."Name")
			SKIN:Bang("!HideMeter Meter"..i.."Size")
			SKIN:Bang("!HideMeter Meter"..i.."%")

				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "Connecting to peers", "Connexion")
				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "Downloading", "Download")
				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "Queued", "Pause")
				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "Finding peers", "Recherche")
				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "Seeding", "Upload")
				
				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "%d", "")
				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "%%", "")
				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "%.", "")
				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "  ", "")

			if ( ( tTEXTSTATUS[i]=="Upload" ) and ( round(tonumber(tUPLOADSPEED[i]/1024),0) > 0 ) ) then

				tSAVEFOLDER[i] = string.gsub(tSAVEFOLDER[i], "\092\092", "\092")
			
				tNAME[i] = NettoyerTitreFilm(tNAME[i])
				
				-- SKIN:Bang("!ShowMeterGroup Torrent"..i)
				

				-- RENDRE VISIBLE 
				SKIN:Bang("!SetOption Meter"..i.."Icone Y \"#HauteurDeLigne_TexteNormal#r\"")
				SKIN:Bang("!ShowMeter Meter"..i.."Icone")
				SKIN:Bang("!ShowMeter Meter"..i.."DLSpeed")
				SKIN:Bang("!ShowMeter Meter"..i.."Status")
				SKIN:Bang("!ShowMeter Meter"..i.."Name")
				SKIN:Bang("!ShowMeter Meter"..i.."Size")
				SKIN:Bang("!ShowMeter Meter"..i.."%")


				
				SKIN:Bang("!SetOption Meter"..i.."Size Text \" "..format_num(round(tonumber(tDOWNLOADED[i]*tRATIO[i]/(1024*1024*1024*1024)),1),1).." Go / "..format_num(round(tonumber(tSIZE[i]/1073741824),1),1).." Go\"")
				-- SKIN:Bang("!SetOption Meter"..i.."\% Text \"* Up *\"")
			
				-- SKIN:Bang("!SetOption Meter"..i.."Size Text \"Upload\"")
				SKIN:Bang("!SetOption Meter"..i.."DLSpeed Text \""..round(tonumber(tUPLOADSPEED[i]/1024),0).." Ko/s\"")

				-- Cpt = Cpt - 1
				-- SKIN:Bang("!SetOption Meter"..i.."Name Text \""..tLABEL[i].." \t         "..tNAME[i].."\"")
				SKIN:Bang("!SetOption Meter"..i.."Name Text \""..tLABEL[i].." \t "..string.format("%02d",Cpt)..".   "..tNAME[i].."\"")

				-- SKIN:Bang("!SetOption Meter"..i.."% Text \""..tonumber(tRATIO[i]/1000).." ("..round(tonumber(100*(tRATIO[i]/1000)),0).." %) \"")
				SKIN:Bang("!SetOption Meter"..i.."% Text \""..round(tonumber(100*(tRATIO[i]/1000)),1).." %\"")
			
				-- TOOLTIPS
				-- SKIN:Bang("!SetOption Meter"..i.."Name ToolTipText \""..tNAME[i].."#CRLF#Dossier : "..tSAVEFOLDER[i].."\092#CRLF#Pairs : "..tPEERSCONNECTED[i].."("..tPEERSINSWARM[i]..")#CRLF#Téléchargé : "..round(tonumber(tDOWNLOADED[i]/1048576),0).." Mo".."#CRLF#Restant : "..round(tonumber(tREMAINING[i]/1048576),0).." Mo#CRLF#Ratio : "..round(tonumber(tRATIO[i]/1000),3).."\"")




				SKIN:Bang("!SetOption Meter"..i.."Name FontColor \"#Blanc#\"")
				SKIN:Bang("!SetOption Meter"..i.."Size FontColor \"#Blanc#\"")
				SKIN:Bang("!SetOption Meter"..i.."DLSpeed FontColor \"#Blanc#\"")
				SKIN:Bang("!SetOption Meter"..i.."Status FontColor \"#Blanc#\"")
				SKIN:Bang("!SetOption Meter"..i.."Bar BarColor \"#Blanc#\"")
				SKIN:Bang("!SetOption Meter"..i.."Icone ImageTint \"#Blanc#\"")
				SKIN:Bang("!SetOption Meter"..i.."% FontColor \"#Blanc#\"")
				
				Cpt = Cpt + 1
				TailleTotale = TailleTotale + round(tonumber(tUPLOADSPEED[i]/1024),0)
				

	


				-- COULEURS
				if round(tonumber(tUPLOADSPEED[i]/1024),0) >30 then
					SKIN:Bang("!SetOption Meter"..i.."Name FontColor \"#Vert#\"")
					SKIN:Bang("!SetOption Meter"..i.."Size FontColor \"#Vert#\"")
					SKIN:Bang("!SetOption Meter"..i.."DLSpeed FontColor \"#Vert#\"")
					SKIN:Bang("!SetOption Meter"..i.."Status FontColor \"#Vert#\"")
					SKIN:Bang("!SetOption Meter"..i.."Bar BarColor \"#Vert#\"")
					SKIN:Bang("!SetOption Meter"..i.."Icone ImageTint \"#Vert#\"")
					SKIN:Bang("!SetOption Meter"..i.."% FontColor \"#Vert#\"")
				end
				if round(tonumber(tUPLOADSPEED[i]/1024),0) >200 then
					SKIN:Bang("!SetOption Meter"..i.."Name FontColor \"#Jaune#\"")
					SKIN:Bang("!SetOption Meter"..i.."Size FontColor \"#Jaune#\"")
					SKIN:Bang("!SetOption Meter"..i.."DLSpeed FontColor \"#Jaune#\"")
					SKIN:Bang("!SetOption Meter"..i.."Status FontColor \"#Jaune#\"")
					SKIN:Bang("!SetOption Meter"..i.."Bar BarColor \"#Jaune#\"")
					SKIN:Bang("!SetOption Meter"..i.."Icone ImageTint \"#Jaune#\"")
					SKIN:Bang("!SetOption Meter"..i.."% FontColor \"#Jaune#\"")
				end
				if round(tonumber(tUPLOADSPEED[i]/1024),0) >750 then
					SKIN:Bang("!SetOption Meter"..i.."Name FontColor \"#Orange#\"")
					SKIN:Bang("!SetOption Meter"..i.."Size FontColor \"#Orange#\"")
					SKIN:Bang("!SetOption Meter"..i.."DLSpeed FontColor \"#Orange#\"")
					SKIN:Bang("!SetOption Meter"..i.."Status FontColor \"#Orange#\"")
					SKIN:Bang("!SetOption Meter"..i.."Bar BarColor \"#Orange#\"")
					SKIN:Bang("!SetOption Meter"..i.."Icone ImageTint \"#Orange#\"")
					SKIN:Bang("!SetOption Meter"..i.."% FontColor \"#Orange#\"")
				end
				if round(tonumber(tUPLOADSPEED[i]/1024),0) >2000 then
					SKIN:Bang("!SetOption Meter"..i.."Name FontColor \"#Rouge#\"")
					SKIN:Bang("!SetOption Meter"..i.."Size FontColor \"#Rouge#\"")
					SKIN:Bang("!SetOption Meter"..i.."DLSpeed FontColor \"#Rouge#\"")
					SKIN:Bang("!SetOption Meter"..i.."Status FontColor \"#Rouge#\"")
					SKIN:Bang("!SetOption Meter"..i.."Bar BarColor \"#Rouge#\"")
					SKIN:Bang("!SetOption Meter"..i.."Icone ImageTint \"#Rouge#\"")
					SKIN:Bang("!SetOption Meter"..i.."% FontColor \"#Rouge#\"")
				end

				
				-- SKIN:Bang("!SetOption Meter"..i.."Seeds Text \""..tSEEDSCONNECTED[i].."("..tSEEDSINSWARM[i]..")\"")
				-- SKIN:Bang("!SetOption Meter"..i.."Status Text \""..tTEXTSTATUS[i].."\"")			
				

			end
		end
		
		SKIN:Bang("!EnableMeasureGroup AllMeasures")
		-- if iItemCount == 0 then
		-- 	SKIN:Bang("!HideMeterGroup Body")
		-- else	
		-- 	SKIN:Bang("!ShowMeterGroup Body")
		-- end
		
		-- SKIN:Bang("!SetVariable BackgroundHeight "..tostring(iItemCount * 31))
		
	
		SKIN:Bang("!SetOption MeterUPLOADText Text \""..TailleTotale.." Ko/s\"")

		
		
		-- ICI 2/3 POUR LES ITERATIONS DE DOWNLOADS
		
		 if iItemCount < 300 then
		 	for i = iItemCount + 1, 300 do
		 		
				-- SKIN:Bang("!HideMeterGroup Torrent"..i)
				-- RENDRE INVISIBLE
				SKIN:Bang("!SetOption Meter"..i.."Icone Y \"-1r\"")
				SKIN:Bang("!HideMeter Meter"..i.."Icone")
				SKIN:Bang("!HideMeter Meter"..i.."DLSpeed")
				SKIN:Bang("!HideMeter Meter"..i.."Bar")
				SKIN:Bang("!HideMeter Meter"..i.."Status")
				SKIN:Bang("!HideMeter Meter"..i.."Name")
				SKIN:Bang("!HideMeter Meter"..i.."Size")
				SKIN:Bang("!HideMeter Meter"..i.."%")


		 	end	
		  end
		
	else -- uTorrent not running
		
		SKIN:Bang("!DisableMeasureGroup AllMeasures")
		
		-- SKIN:Bang("!HideMeterGroup Body")
		
		
		--
		-- ICI 3/3 POUR LES ITERATIONS DE DOWNLOADS
		--		
		
		for i = 1, 300 do
		 	
				-- SKIN:Bang("!HideMeterGroup Torrent"..i)
				
				-- RENDRE INVISIBLE
				SKIN:Bang("!SetOption Meter"..i.."Icone Y \"-1r\"")
				SKIN:Bang("!HideMeter Meter"..i.."Icone")
				SKIN:Bang("!HideMeter Meter"..i.."DLSpeed")
				SKIN:Bang("!HideMeter Meter"..i.."Bar")
				SKIN:Bang("!HideMeter Meter"..i.."Status")
				SKIN:Bang("!HideMeter Meter"..i.."Name")
				SKIN:Bang("!HideMeter Meter"..i.."Size")
				SKIN:Bang("!HideMeter Meter"..i.."%")
		end	
		
	end	-- Test for uTorrent running

	return IsRunning
	
end -- function Update


User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change Measure with LUA

Post by balala »

krakoukas wrote: July 11th, 2019, 10:32 am I can drop the value through LUA in a Meter :

Code: Select all

SKIN:Bang("!SetOption MeterUPLOADText Text \""..TailleTotale.." Ko/s\"")
But I am not able to drop it in a Measure (in order to have a pretty line).
If you want to use the value of the TailleTotale variable into a Line meter, you have to pass it through a simple Calc measure of the skin. If you don't have a measure, you can't get a Line meter to work.
So, try the following: add a Calc measure to your code, something like this:

Code: Select all

[MeasureTailleTotale]
Measure=Calc
Now modify the above !SetOption command within the script file to something like: SKIN:Bang('!SetOption', 'MeasureTailleTotale', 'Formula', TailleTotale) (note that I'm using little bit different syntax for this command than your). With this command, the [MeasureTailleTotale] measure gets the value of the TailleTotale variable from the script file. Now you can use this measure within the Line meter, adding it into the MeasureName option of the meter (MeterName=MeasureTailleTotale).
Please try out the above solution and if you can't get it to work, pack the whole config you have and upload it, to can check.
User avatar
krakoukas
Posts: 71
Joined: December 11th, 2018, 5:56 pm
Location: France
Contact:

Re: Change Measure with LUA

Post by krakoukas »

Balala,

The whole widget is not working anymore with these changes

The INI skin (truncated because of 21.000 lines) :

Code: Select all


[Rainmeter]

	; *****************************************************************************
	; RAINMETER
	; *****************************************************************************
	MiddleMouseUpAction=[!Refresh]
	@include1=#@#Rainmeter.inc

[Metadata]

	; *****************************************************************************
	; METADATA
	; *****************************************************************************

	@include2=#@#Metadata.inc

[Variables]

	LargeurModuleExterieur = 		748
	LargeurModuleInterieur = 		737
	LargeurSeparateurHorizontal =	725

	HauteurModuleExterieur = 		300
	HauteurModuleInterieur =		279
	
	RefreshModule =					120
	
	
	
	
		
		
		
		; JSMORLEY
		
		; TORRENT INFOS
		UserName=piregwan
		Password=XXXXX
		uTorrentPort=8080
		ProcessName="utorrent"
		PathToUTorrent="C:\Program Files (x86)\uTorrent\uTorrent.exe"

		; COULEURS POUVANT ETRE CHANGEES
		ListFontColor=255,255,255,255
		HeaderColor=239,219,137,255
		UTorrentColor=239,219,137
		PanelColor=0,0,0,180
		ProgressBarColor=#Blanc#
		SeparatorLineColor=150,150,150,255
		GreyColor=210,210,210,255


		; DO NOT CHANGE THIS
		uTorrentURL=http://#UserName#:#Password#@127.0.0.1:#uTorrentPort#/gui/?list=1
		Item=(?(?=.*\[\").*\[\"(.*)\",(.*),\"(.*)\",(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),\"(.*)\",(.*),(.*),(.*),(.*),(.*),(.*),(.*)\])
		BackgroundHeight=230

		
		

	
	
			
; *****************************************************************************
; INCLUDES
; *****************************************************************************
	
	@include3=#@#CSS-General.inc
	@include4=#@#CSS-Modules-Widgets.inc
	BG_Interieur_DecalageY = 		11
	@include5=#@#Debug.inc

; *****************************************************************************
; STYLES PROPRES AU MODULE 
; *****************************************************************************

			[Style-Barre-Progression]
			X=r
			Y=#HauteurDeLigne_TexteNormal#r
			H=3
			W=77
			BarColor=255,255,255,255
			BarOrientation=HORIZONTAL
			SolidColor=255,255,255,75
			SolidColor2=255,255,255,10

; *****************************************************************************
; MEASURES
; *****************************************************************************





		; JSMORLEY

		;[CHECK UTORRENT PROCESS]===========================================

		[MeasureProcessPID]
		Measure=Plugin
		Plugin=Perfmon.dll
		PerfMonObject="Process"
		PerfMonCounter="ID Process"
		PerfMonInstance=#ProcessName#
		PerfMonDifference=0
		UpdateDivider=#Refresh_Torrent#

		[CalcTranslatePIDToRunningState]
		Measure=Calc
		Formula=MeasureProcessPID > 0 ? 1 : 0
		IfAboveValue=0
		IfAboveAction=!Execute [!EnableMeasure MeasureWebUI][!SetOption MeterUTorrent ImageTint 224,56,59,255][!SetOption MeterUTorrent ToolTipText "Close uTorrent application"][!SetOption MeterUTorrent LeftMouseUpAction """!Execute ["#CURRENTPATH#KillUTorrent.exe"]["#ADDONSPATH#PlayTone\PlayTone.exe" "500" "200"]"""]
		IfEqualValue=0
		IfEqualAction=!Execute [!DisableMeasure MeasureWebUI][!SetOption MeterUTorrent ImageTint #HeaderColor#][!SetOption MeterUTorrent ToolTipText "Run uTorrent application"][!SetOption MeterUTorrent LeftMouseUpAction """!Execute ["#PathToUTorrent#"]["#ADDONSPATH#PlayTone\PlayTone.exe" "500" "200"]"""]

		;[GET UTORRENT INFO FROM WEB UI]=====================================

		[MeasureWebUI]
		Group=AllMeasures
		Measure=Plugin
		Plugin=Plugins\WebParser.dll
		URL=#uTorrentURL#
		RegExp="(?siU)^(.*)$"
		ForceReload=1
		UpdateRate=#Refresh_Torrent#
		Disabled=1
		FinishAction=!Execute [!EnableMeasure MeasureLua]

		;[LUA MEASURE]========================================================

		[MeasureLua]
		Measure=SCRIPT
		ScriptFile=#@#Scripts_Lua\Torrent-Uploads.lua
		UpdateDivider=#Refresh_Torrent#
		Disabled=1


		[MeasureTailleTotale]
		Measure=Calc

		
				
; *****************************************************************************
; METERS
; *****************************************************************************

	[Titre1-Module]
	Meter=String
	MeterStyle=Style-Titre
	Text="Uploads Torrent (Seed)                                    Volume       Vitesse                                       Ratio"
	Y=15

	[Titre1_Module_Totale]
	Meter=String
	MeterStyle=Style-Titre
	Y=r
	X=514



	[Spacer]
	Meter=String
	MeterStyle=Style-Titre
	Y=12r
	
	
		; JSMORLEY



		[Meter1Icone]
		Meter=Image
		x=#PaddingModuleInterieur#
		; Y=150
		ImageName=#@#Images\Ping\Dot.png

		[Meter1Name]
		Group=Torrent1
		Meter=String
		MeterStyle=Style-Contenu
		W=285
		H=15
		ClipString=1
		X=18r
		Y=1r

		[Meter1Size]
		Group=Torrent1
		Meter=String
		MeterStyle=Style-Contenu
		X=428
		Y=r
		StringAlign=RIGHT

		[Meter1DLSpeed]
		Group=Torrent1
		Meter=String
		MeterStyle=Style-Contenu
		X=513
		Y=r
		StringAlign=RIGHT

		; [Meter1Seeds]
		; Group=Torrent1
		; Meter=String
		; MeterStyle=Style-Contenu
		; X=310
		; Y=r

		; [Meter1Status]
		; Group=Torrent1
		; Meter=String
		; MeterStyle=Style-Contenu
		; X=316
		; Y=r

		; [Meter1Line]
		; Group=Torrent1
		; Meter=Image
		; SolidColor=#SeparatorLineColor#
		; W=70
		; H=1
		; X=537
		; Y=5r
		; Hidden=1

		[Measure1BarCalc]
		Group=Torrent1
		Measure=Calc
		Formula=#Bar1Calc#
		MinValue=0
		MaxValue=100
		DynamicVariables=1

		[Meter1Bar]
		MeterStyle=Style-Barre-Progression
		Group=Torrent1
		Meter=Bar
		MeasureName=Measure1BarCalc
		BarColor=#ProgressBarColor#
		BarOrientation=Horizontal
		W=70
		H=3
		X=537
		Y=5r

		[Meter1%]
		Group=Torrent1
		Meter=String
		MeterStyle=Style-Contenu
		; FontSize=7
		StringAlign=RIGHT
		X=739
		Y=-5r

		;=============================================

		[Meter2Icone]
		Meter=Image
		x=#PaddingModuleInterieur#
		Y=#HauteurDeLigne_TexteNormal#r
		ImageName=#@#Images\Ping\Dot.png

		[Meter2Name]
		Group=Torrent2
		Meter=String
		MeterStyle=Style-Contenu
		W=285
		H=15
		ClipString=1
		x=18r
		Y=1r

		[Meter2Size]
		Group=Torrent2
		Meter=String
		MeterStyle=Style-Contenu
		X=428
		Y=0r
		StringAlign=RIGHT

		[Meter2DLSpeed]
		Group=Torrent2
		Meter=String
		MeterStyle=Style-Contenu
		X=513
		Y=0r
		StringAlign=RIGHT

		; [Meter2Seeds]
		; Group=Torrent2
		; Meter=String
		; MeterStyle=Style-Contenu
		; X=310
		; Y=0r

		; [Meter2Status]
		; Group=Torrent2
		; Meter=String
		; MeterStyle=Style-Contenu
		; X=316
		; Y=0r

		; [Meter2Line]
		; Group=Torrent2
		; Meter=Image
		; SolidColor=#SeparatorLineColor#
		; W=70
		; H=1
		; X=537
		; Y=5r
		; Hidden=1

		[Measure2BarCalc]
		Group=Torrent2
		Measure=Calc
		Formula=#Bar2Calc#
		MinValue=0
		MaxValue=100
		DynamicVariables=1

		[Meter2Bar]
		MeterStyle=Style-Barre-Progression
		Group=Torrent2
		Meter=Bar
		MeasureName=Measure2BarCalc
		BarColor=#ProgressBarColor#
		BarOrientation=Horizontal
		W=70
		H=3
		X=537
		Y=5r

		[Meter2%]
		Group=Torrent2
		Meter=String
		MeterStyle=Style-Contenu
		; FontSize=7
		StringAlign=RIGHT
		X=739
		Y=-5r

		;=============================================




	[...........................................]
	
	; *****************************************************************************
	; HISTOGRAMME UPLOAD
	; *****************************************************************************

		[Fond-Grillage-UPLOAD]
		Meter=IMAGE
		ImageName=#@#Images\Graphiques\Fond_0_piece_10min.png
		X=19
		Y=195
		H=42
		W=659

		; UPLOAD TORRENT
		[Histogramme-UPLOAD-1]
		Meter=Line
		MeasureName=MeasureTailleTotale
		-- MeasureName=XXXXXXXXX
		LineColor=#Vert#
		X=r
		Y=r
		W=#LargeurHistogramme2#
		H=#HauteurHistogramme#
		AntiAlias=#AntiAliasHistogramme#

		
	; *****************************************************************************
	; VALEUR UPLOAD
	; *****************************************************************************

		[MeterUPLOADText]
		Meter=String
		X=719r
		Y=12r
		MeterStyle=Style-Contenu
		NumOfDecimals=2
		; FontColor=#Vert#
		AutoScale=1
		StringAlign=Right
	
		

	
	
	
		; [Image-RATIO-1]
		; Meter=IMAGE
		; ImageName=#@#Images\Ratio\fleche_haut_3_1.png
		; X=-341r
		; Y=-40r
		; ImageAlpha=22
		; [Image-RATIO-2]
		; Meter=IMAGE
		; ImageName=#@#Images\Ratio\fleche_bas_3_1.png
		; X=r
		; Y=21r
		; ImageAlpha=22
	


The LUA file :

Code: Select all


function Initialize()
	
		dofile(SKIN:GetVariable('@')..'Scripts_Lua\\Torrent-General.lua')

	tItem = {}
	tHASH = {}
	tSTATUS = {}
	tNAME = {}
	tSIZE = {}
	tPERCENTPROGRESS = {}
	tDOWNLOADED = {}
	tUPLOADED = {}
	tRATIO = {}
	tUPLOADSPEED = {}
	tDOWNLOADSPEED = {}
	tETA = {}
	tLABEL = {}
	tPEERSCONNECTED = {}
	tPEERSINSWARM = {}
	tSEEDSCONNECTED = {}
	tSEEDSINSWARM = {}
	tAVAILABILITY = {}
	tTORRENTQUEUEORDER = {}
	tREMAINING = {}
	tField21 = {}
	tField22 = {}
	tTEXTSTATUS = {}
	tField24 = {}
	tField25 = {}
	tField26 = {}
	tField27 = {}
	tSAVEFOLDER = {}
	
	sNormalColor = SKIN:GetVariable("ListFontColor")
	sGreyColor = SKIN:GetVariable("GreyColor")
	RunningState = SKIN:GetMeasure("CalcTranslatePIDToRunningState")
	msMain = SKIN:GetMeasure("MeasureWebUI")
	CurrDir = SKIN:GetVariable("CURRENTPATH")
	
end -- function Initialize

function Update()

	IsRunning = RunningState:GetValue()
	
	if IsRunning == 1 then --uTorrent running
	
		Pos = 0
		Cpt = 1
		TailleTotale = 0
	
		sAllText = msMain:GetStringValue()
		sAllText = string.match(sAllText, ".-\034torrents\034%:(.-)$")
		sTemp, iItemCount = string.gsub(sAllText, ".-%[\"(.-)\"%]", "")
		
		--
		-- ICI 1/3 POUR LES ITERATIONS DE DOWNLOADS
		--
		iItemCount = (iItemCount < 301) and iItemCount or 300
		for i = 1, iItemCount do
	
			tItem[i] = "[\""..string.match(sAllText, ".-%[\"(.-)\"%]", Pos).."\"]"
			Pos = Pos + string.len(tItem[i])+1

			tHASH[i], tSTATUS[i], tNAME[i], tSIZE[i], tPERCENTPROGRESS[i], tDOWNLOADED[i], tUPLOADED[i], tRATIO[i], tUPLOADSPEED[i], tDOWNLOADSPEED[i], tETA[i], tLABEL[i], tPEERSCONNECTED[i], tPEERSINSWARM[i], tSEEDSCONNECTED[i], tSEEDSINSWARM[i], tAVAILABILITY[i], tTORRENTQUEUEORDER[i], tREMAINING[i], tField21[i], tField22[i], tTEXTSTATUS[i], tField24[i], tField25[i], tField26[i], tField27[i], tSAVEFOLDER[i] = string.match(tItem[i], '%[\"(.-)\",(.-),\"(.-)\",(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-),\"(.-)\",(.-),(.-),(.-),(.-),(.-),(.-),(.-),\"(.-)\",\"(.-)\",\"(.-)\",\"(.-)\",(.-),(.-),\"(.-)\",\"(.-)\".-%]')
		
			
			
			
		
			-- RENDRE INVISIBLE
			if (i>1) then
				SKIN:Bang("!SetOption Meter"..i.."Icone Y \"-1r\"")
			else
				SKIN:Bang("!SetOption Meter"..i.."Icone Y \"27\"")
			end
			SKIN:Bang("!HideMeter Meter"..i.."Icone")
			SKIN:Bang("!HideMeter Meter"..i.."DLSpeed")
			SKIN:Bang("!HideMeter Meter"..i.."Bar")
			SKIN:Bang("!HideMeter Meter"..i.."Status")
			SKIN:Bang("!HideMeter Meter"..i.."Name")
			SKIN:Bang("!HideMeter Meter"..i.."Size")
			SKIN:Bang("!HideMeter Meter"..i.."%")

				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "Connecting to peers", "Connexion")
				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "Downloading", "Download")
				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "Queued", "Pause")
				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "Finding peers", "Recherche")
				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "Seeding", "Upload")
				
				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "%d", "")
				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "%%", "")
				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "%.", "")
				tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "  ", "")

			if ( ( tTEXTSTATUS[i]=="Upload" ) and ( round(tonumber(tUPLOADSPEED[i]/1024),0) > 0 ) ) then

				tSAVEFOLDER[i] = string.gsub(tSAVEFOLDER[i], "\092\092", "\092")
			
				tNAME[i] = NettoyerTitreFilm(tNAME[i])
				
				-- SKIN:Bang("!ShowMeterGroup Torrent"..i)
				

				-- RENDRE VISIBLE 
				SKIN:Bang("!SetOption Meter"..i.."Icone Y \"#HauteurDeLigne_TexteNormal#r\"")
				SKIN:Bang("!ShowMeter Meter"..i.."Icone")
				SKIN:Bang("!ShowMeter Meter"..i.."DLSpeed")
				SKIN:Bang("!ShowMeter Meter"..i.."Status")
				SKIN:Bang("!ShowMeter Meter"..i.."Name")
				SKIN:Bang("!ShowMeter Meter"..i.."Size")
				SKIN:Bang("!ShowMeter Meter"..i.."%")


				
				SKIN:Bang("!SetOption Meter"..i.."Size Text \" "..format_num(round(tonumber(tDOWNLOADED[i]*tRATIO[i]/(1024*1024*1024*1024)),1),1).." Go / "..format_num(round(tonumber(tSIZE[i]/1073741824),1),1).." Go\"")
				-- SKIN:Bang("!SetOption Meter"..i.."\% Text \"* Up *\"")
			
				-- SKIN:Bang("!SetOption Meter"..i.."Size Text \"Upload\"")
				SKIN:Bang("!SetOption Meter"..i.."DLSpeed Text \""..round(tonumber(tUPLOADSPEED[i]/1024),0).." Ko/s\"")

				-- Cpt = Cpt - 1
				-- SKIN:Bang("!SetOption Meter"..i.."Name Text \""..tLABEL[i].." \t         "..tNAME[i].."\"")
				SKIN:Bang("!SetOption Meter"..i.."Name Text \""..tLABEL[i].." \t "..string.format("%02d",Cpt)..".   "..tNAME[i].."\"")

				-- SKIN:Bang("!SetOption Meter"..i.."% Text \""..tonumber(tRATIO[i]/1000).." ("..round(tonumber(100*(tRATIO[i]/1000)),0).." %) \"")
				SKIN:Bang("!SetOption Meter"..i.."% Text \""..round(tonumber(100*(tRATIO[i]/1000)),1).." %\"")
			
				-- TOOLTIPS
				-- SKIN:Bang("!SetOption Meter"..i.."Name ToolTipText \""..tNAME[i].."#CRLF#Dossier : "..tSAVEFOLDER[i].."\092#CRLF#Pairs : "..tPEERSCONNECTED[i].."("..tPEERSINSWARM[i]..")#CRLF#Téléchargé : "..round(tonumber(tDOWNLOADED[i]/1048576),0).." Mo".."#CRLF#Restant : "..round(tonumber(tREMAINING[i]/1048576),0).." Mo#CRLF#Ratio : "..round(tonumber(tRATIO[i]/1000),3).."\"")




				SKIN:Bang("!SetOption Meter"..i.."Name FontColor \"#Blanc#\"")
				SKIN:Bang("!SetOption Meter"..i.."Size FontColor \"#Blanc#\"")
				SKIN:Bang("!SetOption Meter"..i.."DLSpeed FontColor \"#Blanc#\"")
				SKIN:Bang("!SetOption Meter"..i.."Status FontColor \"#Blanc#\"")
				SKIN:Bang("!SetOption Meter"..i.."Bar BarColor \"#Blanc#\"")
				SKIN:Bang("!SetOption Meter"..i.."Icone ImageTint \"#Blanc#\"")
				SKIN:Bang("!SetOption Meter"..i.."% FontColor \"#Blanc#\"")
				
				Cpt = Cpt + 1
				TailleTotale = TailleTotale + round(tonumber(tUPLOADSPEED[i]/1024),0)
				

	


				-- COULEURS
				if round(tonumber(tUPLOADSPEED[i]/1024),0) >30 then
					SKIN:Bang("!SetOption Meter"..i.."Name FontColor \"#Vert#\"")
					SKIN:Bang("!SetOption Meter"..i.."Size FontColor \"#Vert#\"")
					SKIN:Bang("!SetOption Meter"..i.."DLSpeed FontColor \"#Vert#\"")
					SKIN:Bang("!SetOption Meter"..i.."Status FontColor \"#Vert#\"")
					SKIN:Bang("!SetOption Meter"..i.."Bar BarColor \"#Vert#\"")
					SKIN:Bang("!SetOption Meter"..i.."Icone ImageTint \"#Vert#\"")
					SKIN:Bang("!SetOption Meter"..i.."% FontColor \"#Vert#\"")
				end
				if round(tonumber(tUPLOADSPEED[i]/1024),0) >200 then
					SKIN:Bang("!SetOption Meter"..i.."Name FontColor \"#Jaune#\"")
					SKIN:Bang("!SetOption Meter"..i.."Size FontColor \"#Jaune#\"")
					SKIN:Bang("!SetOption Meter"..i.."DLSpeed FontColor \"#Jaune#\"")
					SKIN:Bang("!SetOption Meter"..i.."Status FontColor \"#Jaune#\"")
					SKIN:Bang("!SetOption Meter"..i.."Bar BarColor \"#Jaune#\"")
					SKIN:Bang("!SetOption Meter"..i.."Icone ImageTint \"#Jaune#\"")
					SKIN:Bang("!SetOption Meter"..i.."% FontColor \"#Jaune#\"")
				end
				if round(tonumber(tUPLOADSPEED[i]/1024),0) >750 then
					SKIN:Bang("!SetOption Meter"..i.."Name FontColor \"#Orange#\"")
					SKIN:Bang("!SetOption Meter"..i.."Size FontColor \"#Orange#\"")
					SKIN:Bang("!SetOption Meter"..i.."DLSpeed FontColor \"#Orange#\"")
					SKIN:Bang("!SetOption Meter"..i.."Status FontColor \"#Orange#\"")
					SKIN:Bang("!SetOption Meter"..i.."Bar BarColor \"#Orange#\"")
					SKIN:Bang("!SetOption Meter"..i.."Icone ImageTint \"#Orange#\"")
					SKIN:Bang("!SetOption Meter"..i.."% FontColor \"#Orange#\"")
				end
				if round(tonumber(tUPLOADSPEED[i]/1024),0) >2000 then
					SKIN:Bang("!SetOption Meter"..i.."Name FontColor \"#Rouge#\"")
					SKIN:Bang("!SetOption Meter"..i.."Size FontColor \"#Rouge#\"")
					SKIN:Bang("!SetOption Meter"..i.."DLSpeed FontColor \"#Rouge#\"")
					SKIN:Bang("!SetOption Meter"..i.."Status FontColor \"#Rouge#\"")
					SKIN:Bang("!SetOption Meter"..i.."Bar BarColor \"#Rouge#\"")
					SKIN:Bang("!SetOption Meter"..i.."Icone ImageTint \"#Rouge#\"")
					SKIN:Bang("!SetOption Meter"..i.."% FontColor \"#Rouge#\"")
				end

				
				-- SKIN:Bang("!SetOption Meter"..i.."Seeds Text \""..tSEEDSCONNECTED[i].."("..tSEEDSINSWARM[i]..")\"")
				-- SKIN:Bang("!SetOption Meter"..i.."Status Text \""..tTEXTSTATUS[i].."\"")			
				

			end
		end
		
		SKIN:Bang("!EnableMeasureGroup AllMeasures")
		-- if iItemCount == 0 then
		-- 	SKIN:Bang("!HideMeterGroup Body")
		-- else	
		-- 	SKIN:Bang("!ShowMeterGroup Body")
		-- end
		
		-- SKIN:Bang("!SetVariable BackgroundHeight "..tostring(iItemCount * 31))
		
	
		SKIN:Bang("!SetOption MeterUPLOADText Text \""..TailleTotale.." Ko/s\"")
		SKIN:Bang('!SetOption', 'MeasureTailleTotale', 'Formula', TailleTotale
		
		
		-- ICI 2/3 POUR LES ITERATIONS DE DOWNLOADS
		
		 if iItemCount < 300 then
		 	for i = iItemCount + 1, 300 do
		 		
				-- SKIN:Bang("!HideMeterGroup Torrent"..i)
				-- RENDRE INVISIBLE
				SKIN:Bang("!SetOption Meter"..i.."Icone Y \"-1r\"")
				SKIN:Bang("!HideMeter Meter"..i.."Icone")
				SKIN:Bang("!HideMeter Meter"..i.."DLSpeed")
				SKIN:Bang("!HideMeter Meter"..i.."Bar")
				SKIN:Bang("!HideMeter Meter"..i.."Status")
				SKIN:Bang("!HideMeter Meter"..i.."Name")
				SKIN:Bang("!HideMeter Meter"..i.."Size")
				SKIN:Bang("!HideMeter Meter"..i.."%")


		 	end	
		  end
		
	else -- uTorrent not running
		
		SKIN:Bang("!DisableMeasureGroup AllMeasures")
		
		-- SKIN:Bang("!HideMeterGroup Body")
		
		
		--
		-- ICI 3/3 POUR LES ITERATIONS DE DOWNLOADS
		--		
		
		for i = 1, 300 do
		 	
				-- SKIN:Bang("!HideMeterGroup Torrent"..i)
				
				-- RENDRE INVISIBLE
				SKIN:Bang("!SetOption Meter"..i.."Icone Y \"-1r\"")
				SKIN:Bang("!HideMeter Meter"..i.."Icone")
				SKIN:Bang("!HideMeter Meter"..i.."DLSpeed")
				SKIN:Bang("!HideMeter Meter"..i.."Bar")
				SKIN:Bang("!HideMeter Meter"..i.."Status")
				SKIN:Bang("!HideMeter Meter"..i.."Name")
				SKIN:Bang("!HideMeter Meter"..i.."Size")
				SKIN:Bang("!HideMeter Meter"..i.."%")
		end	
		
	end	-- Test for uTorrent running

	return IsRunning
	
end -- function Update


Your were true. Looks like there is a problem with this syntax (if commented, works well without error but without line) :

Code: Select all

		SKIN:Bang('!SetOption', 'MeasureTailleTotale', 'Formula', TailleTotale
In my case, working syntax is :

Code: Select all

		SKIN:Bang("!SetOption MeterUPLOADText Text \""..TailleTotale.." Ko/s\"")

How can I make your syntax compatible ?
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change Measure with LUA

Post by balala »

krakoukas wrote: July 12th, 2019, 3:40 pm Your were true. Looks like there is a problem with this syntax (if commented, works well without error but without line) :

Code: Select all

		SKIN:Bang('!SetOption', 'MeasureTailleTotale', 'Formula', TailleTotale
This way this command definitely doesn't work, because there is missing a parenthesis. Add it back: SKIN:Bang('!SetOption', 'MeasureTailleTotale', 'Formula', TailleTotale)
krakoukas wrote: July 12th, 2019, 3:40 pm In my case, working syntax is :

Code: Select all

		SKIN:Bang("!SetOption MeterUPLOADText Text \""..TailleTotale.." Ko/s\"")

How can I make your syntax compatible ?
This commands sets the value of the TailleTotale variable to the Text option of the MeterUPLOADText meter, to show it into the meter.
Now there are two different cases, depending on where do you want to set it (to the meter, or to the measure):
  • To set it to the meter: SKIN:Bang('!SetOption', 'MeterUPLOADText', 'Text', TailleTotale..'Ko/s').
  • To set it to the measure: SKIN:Bang('!SetOption', 'MeasureTailleTotale', 'Formula', TailleTotale) (already posted).
Or you can add both commands, in which case the variable will be set to both, the [MeterUPLOADText] meter and [MeasureTailleTotale] measure.
krakoukas wrote: July 12th, 2019, 3:40 pm The whole widget is not working anymore with these changes

The INI skin (truncated because of 21.000 lines) :
Doesn't work, because there are some required files, which I don't have. But this way I can't get it to work.
As said, please pack the whole config (the first folder within the Skins folder, which contains somewhere both files - the .ini and the .lua files) and upload it here. This way all needed files will be included.
User avatar
krakoukas
Posts: 71
Joined: December 11th, 2018, 5:56 pm
Location: France
Contact:

Re: Change Measure with LUA

Post by krakoukas »

Caramba !

Your syntax was correct Balala with ")" !
I have now a LINE !

Code: Select all

SKIN:Bang('!SetOption', 'MeasureTailleTotale', 'Formula', TailleTotale)
Sorry for my stupid answer and my error, your code works fine !!!! Thank you Balala
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change Measure with LUA

Post by balala »

krakoukas wrote: July 12th, 2019, 4:21 pm Sorry for my stupid answer and my error, your code works fine !!!! Thank you Balala
Don't worry, it happens to all of us sometimes. I1m glad if you got it working well.
User avatar
krakoukas
Posts: 71
Joined: December 11th, 2018, 5:56 pm
Location: France
Contact:

Re: Change Measure with LUA

Post by krakoukas »

balala wrote: July 12th, 2019, 5:14 pm Don't worry, it happens to all of us sometimes. I1m glad if you got it working well.
You are so beautyful Balala. I love you so much :rosegift:

Image
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change Measure with LUA

Post by balala »

Post Reply