Tomato wrote:Amazing!! Didn't expect a response that quickly, especially not one that successful. Thanks a lot! One other thing I am interested in is having the quotation followed by the author name, but smaller than the quote, such as in
this example. The author name doesn't have to be on a separate line. I'd just like it to be smaller. I'd be willing to format my quotation document any which way in order to make this possible. Any suggestions or help on this? Thanks in advance.
That is an entirely different kettle of fish I"m afraid. The way Quote plugin works is that it returns one random "item" from a text file, where you can define what constitutes an "item" by using Separator= as an option to the plugin. The default is a new line, so normally each update of the measure would return one random line from the file. If you put for instance the quote and the author each on its own line, then you can tell Quote to use some "string" as the separator, for example you might have the quote file formatted as:
Getting older is no problem. You just have to live long enough.
Groucho Marx</end>
I don't care to belong to a club that accepts people like me as members.
Groucho Marx</end>
Then you would use Separator="</end>" on the Quote measure, and it would return both the quote and the author as the value of the measure, with the newline between them embedded.
However... That doesn't really help you with your specific need. Since a single value is returned, you can't really put the result in two meters, which is what is required to have different text formatting for the quote vs. the author.
In order to have both the random nature of Quote plugin, along with the ability to get both the quote and the author in two different measures, while keeping them logically connected, we are going to have to take a different approach.
We could use WebParser to get all the quotes and the authors into measures, using formatting of the text file to make it easy to parse. Then we could use a trick with a Calc measure returning a random number to force the string meter(s) to display a random "set" of quote and author. The trouble with this is that:
1) You would need a TON of WebParser measures to get all the quote and author lines into StringIndexes you could use. You can't tell WebParser to get a random line from a file, and since WebParser can't have a dynamic RegExp= line, you can't trick that by formatting the text file with embedded line numbers or something. You would just have to create a whole bunch of WebParser measures.
2) You would effectively be limited to 49 quotes. WebParser can only return 99 StringIndexes, and since you would need two for each set of quote and author, that would be the limit.
So I hate the WebParser approach. Instead I think the best thing is some Lua code.
First off, be sure that you have the latest beta version of Rainmeter from
http://rainmeter.net.
Now, format your Listofquotes.txt text file like this:
Code: Select all
<quote>Any sufficiently advanced incompetence is indistinguishable from malice.
<author>Jane One
<quote>I just thought of the best hyperbole.
This is the second line of the quote.
<author>Jane Two
<quote>For Sale: Parachute. Only used once, never opened, small stain.
<author>Jane Three
<quote>A computer lets you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and Tequila.
<author>Jane Four
<quote>A ship in the harbor is safe, but that is not what ships were made for.
<author>Jane Five
<quote>Never do your best card tricks for the group you play poker with.
<author>Jane Six
<quote>Age and Treachery Will Always Overcome Youth and Skill
<author>Jane Seven
<quote>If I had known I was going to live this long, I'd have taken better care of myself.
<author>Jane Eight
Now create a skin that looks like this. Make any changes to how the meters are formatted or laid out you like:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
[Variables]
Minutes=2
[MeasureQuote]
Measure=Script
ScriptFile=Test.Lua
UpdateDivider=(#Minutes# * 60)
[MeterQuote]
Meter=String
FontSize=13
FontColor=255,255,255,255
StringStyle=Bold
AntiAlias=1
[MeterAuthor]
Meter=String
Y=2R
FontSize=11
FontColor=255,255,255,255
StringStyle=BoldItalic
AntiAlias=1
Then create a text file, with the extension .lua in the same folder. I used "text.lua" in my example, be sure to change both the name of the file and the ScriptName= setting on the measure to have a name you like. Paste this code into that .lua file.
Code: Select all
function Initialize()
CURRENTPATH = SKIN:GetVariable('CURRENTPATH')
Quotes = {}
Authors = {}
i = 0
for line in io.lines(CURRENTPATH..'Listofquotes.txt') do
if string.sub(line, 1, 7) == '<quote>' then
i = i + 1
Quotes[i] = string.sub(line, 8)
elseif string.sub(line, 1, 8) == '<author>' then
Authors[i] = string.sub(line, 9)
else
Quotes[i] = Quotes[i]..'#CRLF#'..line
end
end
end -->Initialize
function Update()
rand = math.random(1, #Quotes)
SKIN:Bang('!SetOption', 'MeterQuote', 'Text', Quotes[rand])
SKIN:Bang('!SetOption', 'MeterAuthor', 'Text', Authors[rand])
return 'Quote number: '..rand
end -->Update
That's it. A very simple skin, with only one measure and one each of quote and author meters. The Lua script will read in the text file with the quotes, put the quotes and the authors into tables (like an array) and then select one based on a random number. Then it will use !SetOption bangs to set the value of the two meters and you are done.
I'm happy to explain anything you don't understand. The Lua can look daunting if you have not messed with it before, but it's not really hard.
Sorry this got kinda long...
I really wanted to explain a bit of why and how I ended up where I did.