First create LuaQuotes.ini in a folder called LuaQuotes in My Documents\Skins\
Code: Select all
[Rainmeter]
Author=Jeffrey Morley
Update=1000
DynamicWindowSize=1
[MeasureLuaScript]
Measure=Script
ScriptFile=#CURRENTPATH#LuaQuotes.lua
TableName=LuaQuotes
FileToRead=#CURRENTPATH#Quotes.txt
UpdateDivider=10
[MeterQuote]
Meter=String
X=0
Y=0
W=200
H=90
FontFace=Segoe UI
FontColor=255,255,255,255
FontSize=12
StringStyle=Bold
ClipString=1
AntiAlias=1
Code: Select all
PROPERTIES =
{
FileToRead = "";
}
function Initialize()
hQuoteFile = io.input(PROPERTIES.FileToRead)
iCount = 1
while true do
local sLine = io.read()
if sLine == nil then break end
iCount = iCount + 1
end
io.flush(hQuoteFile)
MeterQuote = tolua.cast(SKIN:GetMeter("MeterQuote"), "CMeterString")
end -- function Initialize
function Update()
hQuoteFile = io.input(PROPERTIES.FileToRead)
sLineNumber = math.random(iCount -1)
TO.LuaLog(tostring(sLineNumber))
for i = 1, sLineNumber -1 do
io.read()
end
sLineToReturn = io.read()
MeterQuote:SetText(tostring(sLineToReturn))
io.flush(hQuoteFile)
end -- function Update
function GetStringValue()
return "Line "..tostring(sLineNumber).." Returned"
end -- function GetStringValue
This code assumes you have a file called Quotes.txt that is just lines of text like:
I totally take back all those times I didn't want to nap when I was younger.
Nothing sucks more than that moment during an argument when you realize you're wrong.
A closed mouth gathers no foot.
A crisis is when you can't say "Let's forget the whole thing."
If the format is different I might need to tweak the lua just a tad, but it will be able to handle pretty much anything you throw at it.