It is currently April 20th, 2024, 8:09 am

QuotePlugin sequence

General topics related to Rainmeter.
User avatar
nickzlapeor
Posts: 16
Joined: December 28th, 2012, 5:22 pm
Location: Mumbai, India

QuotePlugin sequence

Post by nickzlapeor »

Hi I am trying to use QuotePlugin to show some quotes. But it only shows them randomly and not in the sequence as they appear in the text file. Is it possible to show the quotes in a sequence?

Besides how is it possible to also show the quotes in the text file appear in a sequence in the ToolTipText function?
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: QuotePlugin sequence

Post by jsmorley »

nickzlapeor wrote:Hi I am trying to use QuotePlugin to show some quotes. But it only shows them randomly and not in the sequence as they appear in the text file. Is it possible to show the quotes in a sequence?

Besides how is it possible to also show the quotes in the text file appear in a sequence in the ToolTipText function?
No, the Quote plugin by design obtains a random item. (line from file or image from folder or whatever you point to) In order to have similar functionality sequentially, you would need to use a Lua script, open the file, read it, and use bangs from the script to display the line you want.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: QuotePlugin sequence

Post by smurfier »

Quote.lua

Code: Select all

function Initialize()
	local Text, Pos = {}, 1
	local hFile = io.open(SKIN:MakePathAbsolute(SELF:GetOption('File')), 'r')
	for word in hFile:lines() do table.insert(Text, word) end
	hFile:close()
end -- Initialize

function Update()
	local rtext = ''
	if #Text > 0 then
		rtext = #Text[Pos]
		Pos = Pos % #Text + 1
	end
	return rtext
end -- Update
Skin.ini

Code: Select all

[Quote]
Measure=Script
ScriptFile=Quote.lua
File=QuoteFile.txt

[String]
Meter=String
MeasureName=Quote
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 . . .
User avatar
nickzlapeor
Posts: 16
Joined: December 28th, 2012, 5:22 pm
Location: Mumbai, India

Re: QuotePlugin sequence

Post by nickzlapeor »

Hello Thank you for the guidance provided. My skin only shows 0 and not text from the file.

I only changed font values in the skin:
[Rainmeter]
Update=1000

[MyQuote]
Measure=Script
ScriptFile=quotes.lua
File=quotes.txt

[String]
Meter=String
MeasureName=MyQuote
FontSize=20
FontFace=Segoe UI
X=0
Y=0
The lua file is as it is. I went through the Lua scripting manual, but I couldn't understand a single thing what needs to be done.

The quotes:
Today is Saturday.
Tomorrow is Sunday.
New Year is on Monday.
Thank you for replying.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: QuotePlugin sequence

Post by smurfier »

This test skin works fine on my system. I did rewrite the Lua script a little. Not because there were errors, just because I thought of a slightly better method.
You do not have the required permissions to view the files attached to this post.
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 . . .
User avatar
nickzlapeor
Posts: 16
Joined: December 28th, 2012, 5:22 pm
Location: Mumbai, India

Re: QuotePlugin sequence

Post by nickzlapeor »

Thank you for all the hardwork. This works now. You're a great person!

Edit: No Unicode support?
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: QuotePlugin sequence

Post by smurfier »

nickzlapeor wrote:Thank you for all the hardwork. This works now. You're a great person!

Edit: No Unicode support?
Sorry, Lua doesn't (correctly) support Unicode.
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 . . .
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: QuotePlugin sequence

Post by jsmorley »

An alternative, that doesn't use the Quote plugin or Lua (which does not do Unicode well) is:

Skin:

Code: Select all

[Rainmeter]
Update=1000

[Variables]
@Include=#CURRENTPATH#Test.txt

[MeasureCount]
Measure=Calc
Formula=(MeasureCount % 4) + 1
UpdateDivider=-1

[MeasureUpdate]
Measure=Calc
Formula=(MeasureUpdate % 10) + 1
IfEqualValue=1
IfEqualAction=[!SetOption MeterQuote Text "#Item[MeasureCount]#"][!UpdateMeter MeterQuote][!Redraw][!UpdateMeasure MeasureCount]
DynamicVariables=1

[MeterQuote]
Meter=String
FontSize=13
FontColor=255,255,255,255
StringStyle=Bold
Antialias=1
Test.txt:

Code: Select all

[Variables]
Item1=Today is Saturday.
Item2=Tomorrow is Sunday.
Item3=New Year is on Monday.
Item4=في اليوم التالي هو يوم الثلاثاء
What we are doing is:

Saving the "quotes" in a text file with the file encoding set to UCS-2 Little Endian in your text editor. That way you can save the Unicode characters, and Rainmeter will read them. The file is configured as an "include" file and contains [Variables] set to the value of your quotes. We then @Include this file in the Rainmeter skin.

Setting up a "counter" measure [MeasureCount] to count in a loop from 1 to 4 (the four items in the text file). It is set with UpdateDivider=-1 so it never updates on its own, but will start with "1" and wait for us to manually update it.

Setting up another "counter" measure [MeasureUpdate] to provide the amount of time you want between "changes" of the quote. In this case, I have it set to every 10 seconds (the counter value times the Update=1000 in the [Rainmeter] section.)

When this counter hits "1", it will set the text of the meter to the value of the variable #ItemN# where "N" is the [MeasureCount] counter value from 1 to 4.

After setting the meter text, we update the [MeasureCount] measure, so it changes to the next value from 1 to 4.

This will display each of your quotes, in sequential order, every 10 seconds.
User avatar
nickzlapeor
Posts: 16
Joined: December 28th, 2012, 5:22 pm
Location: Mumbai, India

Re: QuotePlugin sequence

Post by nickzlapeor »

It does! Thank you jsmorley for the skin. Thanks a lot!
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: QuotePlugin sequence

Post by jsmorley »

nickzlapeor wrote:It does! Thank you jsmorley for the skin. Thanks a lot!
Glad to help.