Skin:
Code: Select all
;;___________________________________________________________
;;___________________________________________________________
[Rainmeter]
Update=1000
Author=TehGreyFawkz
;;[MEASURES]
[MeasureRandomText]
Measure=Plugin
Plugin=QuotePlugin
PathName=#CURRENTPATH#c
UpdateDivider=10
OnChangeAction=[!UpdateMeasure MeasureLuaScript]
[MeasureLuaScript]
Measure=Script
ScriptFile=#CURRENTPATH#LuaTextFile.lua
FileToRead=[MeasureRandomText]
DynamicVariables=1
UpdateDivider=-1
;;[METERS]
[Background]
Meter=IMAGE
SolidColor=0,0,0,1
X=0
Y=1
W=200
H=30
[Title]
Meter=STRING
Text=C++
X=20
Y=1
H=15
W=150
StringStyle=Normal
FontColor=0,0,0
FontSize=40
FontFace=Disparador stencil
StringEffect=BORDER
FontEffectColor=255,255,255
AntiAlias=1
[Notes]
Meter=STRING
MeasureName=MeasureLuaScript
X=2
Y=32
W=400
H=570
FontColor=200,200,200
FontFace=Arial
FontSize=9
StringEffect=BORDER
FontEffectColor=0,0,0
StringAlign=LEFT
StringStyle=NORMAL
AntiAlias=1
ClipString=1
LuaTextFile.lua:
Code: Select all
function Update()
sFileToRead = SELF:GetOption('FileToRead')
hReadingFile = io.open(sFileToRead)
if not hReadingFile then
print('LuaTextFile: unable to open file at ' .. sFileToRead)
return
end
sAllText = hReadingFile:read("*all")
sAllText = string.gsub(sAllText, "\t", " ")
io.close(hReadingFile)
return tostring(sAllText)
end
So the biggest issue was in the Lua, where you are getting the value of FileToRead from SELF: in the Initialize() function of the script. The problem is, when the skin / script is first initialized, the Quote plugin hasn't yet done its work, so there is no value yet for FileToRead. Plus, don't forget that FileToRead is going to periodically change. If you move that into the Update() function of the script then all is well.
That was really the only problem all along...
The only other thing that I changed is the "timing" of when the file is opened and read. You only want to do that when the Quote plugin has a "different" file name returned, and certainly not on every update of the skin. That is just going to thrash your hard drive for no good reason.
So I set Update in Rainmeter to the default 1000 (you seldom want to increase that from the default, control timing with UpdateDivider on measures) and added an UpdateDivider of 10 to the Quote plugin measure, so it gets a new file every 10 seconds. Use that UpdateDivider to make that timing what you want.
Then I added UpdateDivider=-1 to the Lua script measure, as you don't really ever (other than the very first update of the skin) want that to update on its own. You want it to update when the value of the Quote plugin measure changes. You want the Quote plugin measure to "drive" the Lua script measure...
So I added an OnChangeAction to the Quote plugin measure, which will force an update of the Lua script measure.
Other than that, you pretty much had it right. Good job! I did change the fully qualified fixed paths to stuff in the skin to use built-in variables, which is both shorter, and would allow you to distribute the skin to other users.
I don't have your font, so it looks like crap for me, but should work fine for you.
1.jpg
This was never about spaces in paths or files names, while we don't recommend that, it's fine.
This was never about "quotes", you almost never need them in Rainmeter except in bangs.
This was never about "\" being treated as an escape. While that can be an issue in Lua, it wasn't in this case.
You do not have the required permissions to view the files attached to this post.