It is currently April 25th, 2024, 1:42 pm

[Solved] Update Plugin Measure from LUA

Discuss the use of Lua in Script measures.
prince1142003
Posts: 56
Joined: December 27th, 2011, 12:32 pm

[Solved] Update Plugin Measure from LUA

Post by prince1142003 »

I'm a long time user of Rainmeter and really love the program. I've recently been developing my own skins and ran into a little issue.

I can't get the UpdateMeasure bang to work on a Webparser measure from within LUA. I've attached a test skin along with the LUA I'm using.

Any help is appreciated!
You do not have the required permissions to view the files attached to this post.
Last edited by prince1142003 on April 5th, 2012, 5:57 am, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Update Plugin Measure from LUA

Post by jsmorley »

The problem is that the WebParser measure has an UpdateDivider of -1, which is all well and good. (I understand that you want to control its update with the script and not on each update of the skin in any way) However, since you don't have any UpdateRate on the WebParser measure, it will only "go out to the internet" and thus only run "FinishAction" every 10 minutes, which is the default for UpdateRate.

I made it:

Code: Select all

[MeasureWebParser]
Measure=Plugin
Plugin=WebParser
UpdateDivider=-1
UpdateRate=1
Url=http://slashdot.org/slashdot.rdf
Download=1
ForceReload=1
FinishAction=!CommandMeasure "MeasureScript" "Two()"
Which if I am not mistaken, will still only update the measure in general by the !UpdateMeasure in the script, but when the measure IS updated, it will actually go out and get another copy of the .rdf and run the FinishAction.

You might want to play around and ensure that it is doing exactly what you want, but I think that is the key.
User avatar
Brian
Developer
Posts: 2681
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Update Plugin Measure from LUA

Post by Brian »

I think the problem might be that you have no UpdateRate. If UpdateRate is not defined, it defaults to 600 or 10 minutes. So even though you update the measure, it really wont download the page for 10 minutes.

You might want to use EnableMeasure/DisableMeasure instead of UpdateMeasure.

Your .ini file:

Code: Select all

[MeasureWebParser]
Measure=Plugin
Plugin=WebParser
Url=http://slashdot.org/slashdot.rdf
Download=1
ForceReload=1
FinishAction=!Execute [!CommandMeasure "MeasureScript" "Two()"][!DisableMeasure MeasureWebParser]
Disabled=1
Then your .lua file:

Code: Select all

function Update()
	local t = os.time()
	local freq = 30
	if t >= tonumber(SKIN:GetVariable('One')) then
		print(tonumber(SKIN:GetVariable('One')))
		SKIN:Bang('!Execute [!EnableMeasure "MeasureWebParser"][!Redraw]')
		SKIN:Bang('!SetVariable "One" "'..round(t+freq-(t%freq)+1)..'"')
	end
end
This should work, but haven't tested it yet.....(not at my computer)

-Brian
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Update Plugin Measure from LUA

Post by smurfier »

Brian wrote:I think the problem might be that you have no UpdateRate. If UpdateRate is not defined, it defaults to 600 or 10 minutes. So even though you update the measure, it really wont download the page for 10 minutes.

You might want to use EnableMeasure/DisableMeasure instead of UpdateMeasure.

Your .ini file:

Code: Select all

[MeasureWebParser]
Measure=Plugin
Plugin=WebParser
Url=http://slashdot.org/slashdot.rdf
Download=1
ForceReload=1
FinishAction=!Execute [!CommandMeasure "MeasureScript" "Two()"][!DisableMeasure MeasureWebParser]
Disabled=1
Then your .lua file:

Code: Select all

function Update()
	local t = os.time()
	local freq = 30
	if t >= tonumber(SKIN:GetVariable('One')) then
		print(tonumber(SKIN:GetVariable('One')))
		SKIN:Bang('!Execute [!EnableMeasure "MeasureWebParser"][!Redraw]')
		SKIN:Bang('!SetVariable "One" "'..round(t+freq-(t%freq)+1)..'"')
	end
end
This should work, but haven't tested it yet.....(not at my computer)

-Brian
Unless you set UpdateRate=1 in MeasureWebParser, it would not pull the website until 600 updates later.
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 . . .
prince1142003
Posts: 56
Joined: December 27th, 2011, 12:32 pm

Re: Update Plugin Measure from LUA

Post by prince1142003 »

Code: Select all

[MeasureWebParser]
Measure=Plugin
Plugin=WebParser
UpdateDivider=-1
UpdateRate=1
Url=http://slashdot.org/slashdot.rdf
Download=1
ForceReload=1
FinishAction=!CommandMeasure "MeasureScript" "Two()"
That did the trick. Thanks!
User avatar
Brian
Developer
Posts: 2681
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Update Plugin Measure from LUA

Post by Brian »

smurfier wrote:Unless you set UpdateRate=1 in MeasureWebParser, it would not pull the website until 600 updates later.
I knew I forgot something. :)
prince1142003 wrote:That did the trick. Thanks!
Glad to see you got it working.

-Brian