It is currently May 2nd, 2024, 7:59 am

Need help making random quote display

Get help with creating, editing & fixing problems with skins
Merlinone
Posts: 12
Joined: January 31st, 2011, 4:39 am

Need help making random quote display

Post by Merlinone »

Hi guys,

I'm looking to make a random quote generator from a list of quotes I have, that displays a new one every x amount of minutes, is there a basic code that I can modify to do this instead of doing it from scratch. I don't want anyone to think I'm trying to get them to write the whole code for me, just need help getting started.

Any help would be appreciated
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Need help making random quote display

Post by jsmorley »

Here are the barest of basics you need to do exactly what you want. You will need to play with the cosmetics of the string meter to get it positioned and looking as you like.

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]
Minutes=2

[MeasureQuote]
Measure=Plugin
Plugin=Plugins\QuotePlugin.dll
PathName=#CURRENTPATH#Quotes.txt
UpdateDivider=(#Minutes# * 60)

[MeterQuote]
Meter=String
MeasureName=MeasureQuote

http://rainmeter.net/cms/Plugins-Quote_beta
http://rainmeter.net/cms/Meters-GeneralSettings_beta
http://rainmeter.net/cms/Meters-String_beta
Merlinone
Posts: 12
Joined: January 31st, 2011, 4:39 am

Re: Need help making random quote display

Post by Merlinone »

Ok, I've got this so far, but nothing is coming up, played around with a few things but nothing seems to be fixing it. What am I doing wrong?

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]
Minutes=2

[MeasureQuote]
Measure=Plugin
Plugin=Plugins\QuotePlugin.dll
PathName="C:\Documents and Settings\New\My Documents\Listofquotes.txt"
UpdateDivider=("2" * 60)

[MeterQuote]
Meter=String
MeasureName=MeasureQuote
X=7
Y=40
W=660
H=300
StringStyle=Normal
FontColor=255,255,255,255
FontSize=14
FontFace=Tahoma
AntiAlias=1
ClipString=1
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Need help making random quote display

Post by jsmorley »

Let's get rid of that use of a formula in the UpdateDivider= statement. Aside from the fact that what you put won't work in any formula as you can't multiply a string times a number, apparently you can't use a formula in that statement at all. I shouldn't have assumed you could. You can in lots of other places, but I guess not in this instance.

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]
Seconds=120

[MeasureQuote]
Measure=Plugin
Plugin=Plugins\QuotePlugin.dll
PathName=#CURRENTPATH#Quotes.txt
UpdateDivider=#Seconds#

[MeterQuote]
Meter=String
FontSize=15
FontColor=255,255,255,255
MeasureName=MeasureQuote

Still, the invalid UpdateDivider= statement will not keep if from working. So if it isn't, there is something else going on.

Can you copy and paste in at least a part of your Listofquotes.txt file so I can see the format it is in? Also, are you quite certain that the path to it is right?
Merlinone
Posts: 12
Joined: January 31st, 2011, 4:39 am

Re: Need help making random quote display

Post by Merlinone »

This is an extract from the list of quotes;
  • - All warfare is based on deception. Thus when we are able to attack, we must seem unable.
    - The loudest one in the room is the weakest one in the room.
    - The clever fighter is one who not only wins, but excels in winning with ease.
    - The skilled fighter puts himself into a position which makes defeat impossible.
    - In respect of military method, we have first to characterize the terrain, second, estimate the dimensions of the battlefield, third, calculate the strength of the enemy, fourth, weigh the balance of chances, fifth, plot victory.
    - He will conquer who has learned the art of deviation
    - The truly wise man can perceive things before they have come to pass.
I'm pretty sure the path to it is right, I copied the path to the folder and then just added another backslash with the name of the file, except the file has spaces in it's name (does that need to be changed?). Also, with the update divider do I just need to enter a numerical value?

For reference here is the current code I am using

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]
Seconds=120

[MeasureQuote]
Measure=Plugin
Plugin=Plugins\QuotePlugin.dll
PathName="C:\Documents and Settings\New\My Documents\Listofquotes.txt"
UpdateDivider="10"

[MeterQuote]
Meter=String
FontSize=15
FontColor=255,255,255,255
MeasureName=MeasureQuote
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Need help making random quote display

Post by jsmorley »

What you need to do is stop fussing with UpdateDivider for now... ;-)

Since your skin updates at at rate of 1000 ms, (Update=1000) which is equal to one second, then what UpdateDivider does is slow down the rate of updates on THAT measure by modifying the rate it is updated to Update= TIMES UpdateDivider=. So if you put UpdateDivider=120, it means update the measure every 120 seconds (two minutes). I only put the 120 in a variable, so it would hopefully be obvious how you could easily change the amount of time between each quote by changing Seconds=120 to Seconds=60 or Seconds=240 or whatever you like. You make the change in that [Variable], and Rainmeter will use that variable wherever you put #Seconds#. Either that, or forget the variable and just put UpdateDivider=120 or whatever you want. Don't make it a string with quotes, it's a number.

UpdateDivider aside, I can't see any reason why what you have should not work. If your Listofquotes.txt file is a plain text file, with just a list of quotes one on each line, and the path and name in PathName="C:\Documents and Settings\New\My Documents\Listofquotes.txt" is correct, then it pretty much has to work.

I have a bad feeling we are not communicating here somehow. I asked you to copy and paste a section of your listofquotes.txt file into here, and you formatted it with the "list" bbcode instead. So now I'm not confident of the format of the text file. You say "except the file has spaces in its name" which listofquotes.txt doesn't. The path to the file does, if that is what you mean, and that is fine as long as you put the full path\name in quotes.

You might want to .zip up your skin and listofquotes.txt and attach them here. Then I can exactly duplicate what you have and see what is going on.
Merlinone
Posts: 12
Joined: January 31st, 2011, 4:39 am

Re: Need help making random quote display

Post by Merlinone »

Ok, here are the files, I hope I haven't done something extremely stupid, which is likely because I am so new to Rainmeter and frankly I don't know what the hell I'm doing with coding. I really appreciate you helping me and I know your time is precious so thanks for this.
Merlinone
Posts: 12
Joined: January 31st, 2011, 4:39 am

Re: Need help making random quote display

Post by Merlinone »

Whoops, forgot the txt file
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Need help making random quote display

Post by jsmorley »

Ok, this will be a tad long and involved, but if you read carefully and ask questions if you don't understand something, we will have you working in a sec.

The main issue was the format of the "list of quotes.txt" file. (well, and the fact that you were saying "Listofquotes.txt" when the file is "List of quotes.txt")

The way QuotePlugin works is that it first reads your text file. It then picks a random quote from the file and returns it in the measure, so you can display it with a string meter. What a "quote" is can be up to you. By default QuotePlugin assumes that each quote is on a single line, delimited with a carriage return / line feed. Like this:

If I had known I was going to live this long, I would have taken better care of myself.
Remember, it's the second mouse that gets the cheese.

However, you can tell QuotePlugin what to detect as the delimiter, (what defines the "end" of a quote) so you can have a single quote on more than one line in the file, or have multiple quotes on one line in the file.

Separator
A string that separates the text. The default value is \n (i.e. newline).


The way your quote text file was structured, it had each quote beginning with a dash and a tab. It was using the -tab at the beginning of each quote as the delimiter, then some of the quotes were on more than one line.

- If I had known I was going to live this long,
I would have taken better care of myself.
- Remember, it's the second
mouse that gets the cheese.


This raised a couple of issues. First, it is best to have the delimiter at the end of the quote, rather than the beginning. Otherwise in your example you really need to in effect use "newline-tab" as the delimiter, and it is difficult to ever get the first quote in the file. Second, Rainmeter and the TAB character don't really like each other much. It gets way complicated.

So I reformatted your quote text file a bit. I removed the -tab from the beginning of each quote, and added a string "//" to the end of each. Since "//" is not used anywhere in the actual quotes, it is safe to use as a delimiter.

I am vengeance, I am the night, I am Batman.//
And I, do not dare deny
The basic beast inside,
It
You do not have the required permissions to view the files attached to this post.
Merlinone
Posts: 12
Joined: January 31st, 2011, 4:39 am

Re: Need help making random quote display

Post by Merlinone »

Awesome, It's working, thank you so much for all your help your the man!