It is currently April 27th, 2024, 5:15 pm

Quotes plugin

Get help with installing and using Rainmeter.
Cahartez
Posts: 1
Joined: September 29th, 2012, 6:06 am

Quotes plugin

Post by Cahartez »

I got a simple quotation skin from online. It works perfectly well but I am trying to customize it such that it could show chinese quotes as well. If the quote is in chinese, it would not appear or show anything. I want to customize both the chinese and english font.


Here's the code

quotes.ini

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]
Seconds=5
Font=Gabriola
CharsPerLine=48
HeightPerLine=56
MeterHeight=56

[MeasureLuaScript]
Measure=Script
ScriptFile=quotes.lua
QuoteFile=%path%quotes.txt
UpdateDivider=1


[QuotationStyle]
FontColor=255,255,255,255
FontSize=30
StringAlign=Left
FontFace=Gabriola
Antialias=1
ClipString=1
Prefix="
Postfix="

[AuthorStyle]
FontColor=0,0,0,204
FontSize=15
StringAlign=Left
StringStyle=BOLD
StringCase=UPPER
StringEffect=SHADOW
FontEffectColor=255,255,255,128
FontFace=Gabriola
Antialias=1
Prefix=—

[QuotationText]
Meter=String
MeterStyle=QuotationStyle
X=0
Y=0
W=800
H=56
DynamicVariables=1

[QuotationAuthor]
Meter=String
MeterStyle=AuthorStyle
X=50
Y=R

quotes.lua

Code: Select all

PROPERTIES =
{
   QuoteFile= "";
}

function Initialize()
   
   iCharsPerLine = SKIN:GetVariable('CharsPerLine')
   iHeightPerLine = SKIN:GetVariable('HeightPerLine')
   
   tFileLines = {}
   for line in io.lines(PROPERTIES.QuoteFile) do
      table.insert(tFileLines, line)
   end
   
   iTotal = table.maxn(tFileLines)
   
end -- function Initialize

function Update()

   iNewLine = math.random(iTotal)
   sText, sAuthor = string.match(tFileLines[iNewLine], '(.*) %-(.*)')
   
   iLen = string.len(sText) + 2
   iLines = math.ceil(iLen / iCharsPerLine)
   iHeight = iLines * iHeightPerLine
   
   SKIN:Bang('!SetOption QuotationText Text \"'..sText..'\"')
   SKIN:Bang('!SetOption QuotationAuthor Text \"'..sAuthor..'\"')
   SKIN:Bang('!SetVariable MeterHeight '..iHeight)
   
   return sText..' -'..sAuthor
   
end -- function Update
Thanks in advance :)
User avatar
Brian
Developer
Posts: 2686
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Quotes plugin

Post by Brian »

Unfortunately, Lua does not support string operations for Unicode at this time. You should look into using the Quote plugin instead.

-Brian