It is currently April 19th, 2024, 5:25 pm

LuaTailFile - A skin to read logs, todo lists, etc.

Skins that control functions in Windows or Rainmeter
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by poiru »

Yggdrasil wrote:I work with Lua since 2004, so I can say I'm experienced :D Lua is an easy-to-learn language, and that's what make it the best (imho).
Great to have a Lua expert on board!
Yggdrasil wrote:By the way, what about LuaJIT?
I've taken a brief look, but haven't actually tried to implement it into Rainmeter. I'll take a closer look in a few days once I'm done with a few other things.
User avatar
Jkon
Posts: 185
Joined: December 4th, 2009, 2:05 am

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by Jkon »

Downloaded this last night and am using it to view rainmeters log file,works great. I was wondering if there is any way to point tooltiptext to the string value the lua file is sending to each meter.Perhaps in some future version of rainmeter,tooltiptext could be coded to automatically show the string value sent to the meter from a lua file (or some built in var like Tooltiptext=#LuaValue#).As i have no idea how lua and rainmeter interact I apologise if this is a daft idea.
Image
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by jsmorley »

Jkon wrote:Downloaded this last night and am using it to view rainmeters log file,works great. I was wondering if there is any way to point tooltiptext to the string value the lua file is sending to each meter.Perhaps in some future version of rainmeter,tooltiptext could be coded to automatically show the string value sent to the meter from a lua file (or some built in var like Tooltiptext=#LuaValue#).As i have no idea how lua and rainmeter interact I apologise if this is a daft idea.
It's not daft at all, but not something that would be simple to do (I suspect) in the current code. The problem is that there is no "return value" from a meter, only from measures. So within Rainmeter itself, there is currently no way to in effect say ToolTipText=[Meter1], only ToolTipText=[Measure1]. In other words, Rainmeter today can't ask "Hey Meter1, what is your value right now?".

However, you can come at this a different way today.

First, you need to know one rule:

If you use SetText() to force the value of a meter from Lua, then you can't use DynamicVariables on that meter.

So, if you use SetText() to set a meter with a line from a log file, like in my skin, then you can't do the obvious thing with the ToolTipText, which would be:

[Variables]
Meter1TipText="N/A"

[Meter1]
Meter=String
ToolTipText=#Meter1TipText#
DyanmicVariables=1

Then have the Lua set the output of [Meter1] to the line from the log file using SetText(), and set the value of the variable Meter1TipText using a !SetVariable bang from Lua. It won't work as ToolTipText then can't be dynamic and will just stay as "N/A".

However, you could do this:

[Variables]
Meter1TipText="N/A"
Meter1Text="N/A"

[Meter1]
Meter=String
ToolTipText=#Meter1TipText#
Text=#Meter1Text#
DyanmicVariables=1

and instead of using SetText() in the Lua, just use !SetVariable to set both of those above to what you want. Since [Meter1] is set to be dynamic, and SetText() is not used, the new values will display just fine.
User avatar
Jkon
Posts: 185
Joined: December 4th, 2009, 2:05 am

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by Jkon »

You have an uncanny knack for making things sound so simple.So much so that tonight I will don my tin hat and bayonet,quit putting off the inevitable and go to war with lua.Should I be found curled up and drooling in a pile of my own hair in the morning,I shall hold you responsible :D
Image
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by jsmorley »

Jkon wrote:You have an uncanny knack for making things sound so simple.So much so that tonight I will don my tin hat and bayonet,quit putting off the inevitable and go to war with lua.Should I be found curled up and drooling in a pile of my own hair in the morning,I shall hold you responsible :D
Let me know if I can help with anything. Changing that LuaTail file to use this approach would not be terribly difficult at all, just need to add a bunch of [Variables] to the skin, for example

[Variables]
TextVarName1=""
TextVarName2=""
TipVarName1=""
TipVarName2=""
...
etc.

Then in the Lua code, instead of

tMeters:SetText(tAllLines[iCount-i])

You would need something like

SKIN:Bang("!SetVariable TextVarName"..i tAllLines[iCount-i])
SKIN:Bang("!SetVariable TipVarName"..i tAllLines[iCount-i])

I'd have to test a bit to be sure that is exactly it, but it would be something like that.
User avatar
Jkon
Posts: 185
Joined: December 4th, 2009, 2:05 am

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by Jkon »

As I want the string and the tooltip to show the same value I only need the one variable per meter(for only 10 meters) but perhaps for instances where people are using a lua file and tooltip for alot of meters or perhaps in a meterstyle shared among skins,the built in variable might not be a bad idea.Thanks for your help again.i'm gonna delve into that now.
Image
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by jsmorley »

Jkon wrote:As I want the string and the tooltip to show the same value I only need the one variable per meter(for only 10 meters) but perhaps for instances where people are using a lua file and tooltip for alot of meters or perhaps in a meterstyle shared among skins,the built in variable might not be a bad idea.Thanks for your help again.i'm gonna delve into that now.
DOH! Of course you are right! You just need one variable per meter...

Meter1Value=""

and one SKIN:Bang() per loop through iCount
User avatar
Jkon
Posts: 185
Joined: December 4th, 2009, 2:05 am

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by Jkon »

I'm affraid this is getting the better of me. :?

SKIN:Bang("!SetVariable LogVariable"..i tAllLines[iCount-i])

Keeps expecting a ')' near tAllLines.I have tried that and multiple variations of closing brackets to no avail,with it always referring to an expected token or unexpected token.The only way I dont get an error is by moving the 2nd double quote to the closing bracket,but then the variables wont change.
I have at this point read through the first 15 chapters of the tutorial directory and have managed to figure out what is going on in nearly every line of code.The one other line I am having trouble with some of is

tMeters = tolua.cast(SKIN:GetMeter(sMeterPrefix..i), "CMeterString")

as i have yet to figure out exactly what .cast is doing(presumed to be fetching info),nor can i find referance to CMeterString which i am presuming is explicit to how rainmeter and lua interact.

I think,should i be able to get the bang to work,that the above line of code and all referances to the variable meterprefix can be removed along with the meters table block under function initialize.But as I said, thats if I can get the bang to work and I could really do with some more help there.
Image
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by jsmorley »

SKIN:Bang("!SetVariable LogVariable"..i tAllLines[iCount-i])

The problem (which I caused you) is that what you are doing is building one big "string" that you are sending as the bang. What I didn't account for is the "space" that is needed between LogVariableX and the final "value" parameter.

SKIN:Bang("!SetVariable LogVariable"..i.." "..tAllLines[iCount-i])

Try that. I'm not in a position to test just now, but that should stick a space in the right place in the string.
User avatar
Jkon
Posts: 185
Joined: December 4th, 2009, 2:05 am

Re: LuaTailFile - A skin to read logs, todo lists, etc.

Post by Jkon »

no joy,but i see what you are doing,i'll try some variations on the amending.
Image