These both are great leads. I was trying similar but not setting one step or the other, correctly.
It's almost that hour of the night that becomes morning soon.
Today is tomorrow's yesterday.
It is currently September 8th, 2024, 12:52 am
[solved] Finding correct variable in a lua script to use in skin bang function
-
- Posts: 1383
- Joined: September 7th, 2020, 2:24 pm
- Location: QLD, Australia
[solved] Finding correct variable in a lua script to use in skin bang function
Last edited by CodeCode on September 15th, 2023, 7:37 am, edited 1 time in total.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
-
- Posts: 1383
- Joined: September 7th, 2020, 2:24 pm
- Location: QLD, Australia
Re: Topic Revisited finding correct correct variable in a lua sript to use in skin bang function
Good news. The mouseover test worked as hoped.SilverAzide wrote: ↑September 14th, 2023, 4:41 pm I think you are overthinking things. There's no looping involved; Smurfier's code can be left untouched so it can do all the hard work for you. To be clear: if you are looking at his code, you are doing it wrong, LOL.
Start with the very simplest thing. Don't try to eat the elephant all in one bite... Create your own function that simply writes an entry into the log.Next, add the MouseOverAction to the [HolidayStyle] style meter in the Styles.inc file (or whichever styles file your skin is using).Code: Select all
function MyFunction() print("hello world") end
The code assumes you have added a script measure named MyLuaScript, so add that into the Styles.inc file if you have not done so already.Code: Select all
[HolidayStyle] ... MouseOverAction=[!CommandMeasure MyLuaScript "MyFunction()"]
When you refresh the skin, you should see "hello world" show up in the Rainmeter log every time you mouse over a holiday. If that works, then simply expand the function to include the logic needed for your tooltip, as I described above.
![Thumbs Up :thumbup:](./images/smilies/ay.gif)
Just missing some of the bits to find and show the event name in Smurfier's lua in the new lua. But first I will try a skin:bang !setoption, and will pop back in to let you know further details on progress.
![Great :great:](./images/smilies/dn.gif)
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
-
- Posts: 1383
- Joined: September 7th, 2020, 2:24 pm
- Location: QLD, Australia
Re: Topic Revisited finding correct correct variable in a lua sript to use in skin bang function
This did not work. It broke the skin. I probably am using the wrong thing for 'value'.Yincognito wrote: ↑September 14th, 2023, 5:08 pm Curly brackets in Lua:
https://stackoverflow.com/questions/686931/are-curly-brackets-used-in-lua
So, they are not used as code block begin and end markers, as explained above. Just add the suggested 'if' before the 'end' of the for loop, and remember to close it with an 'end' as well. You don't have to look elsewhere for info, the script has plenty of 'if's to serve as your inspiration. This won't break the script at all, since you wouldn't change anything in the existing code, just insert your bit there.
I'm on my phone, but something like:
if (Option == 'ToolTipText') then SKIN:Bang('!SetOption', 'YourMeterNameHere', 'Text', Value) end
in a new line inserted before the 'end' of the 'for' loop should do. This obviously is checking the Option in a case sensitive fashion and assumes the meter where you want to set stuff is a String one, but can be adjusted further if needed.
Take into account that the fact that this is the place where you can get what value goes into the tooltip is just my assumption after briefly looking at the code you posted in the other thread, it isn't tested. However, if this works, then you got away easy with Lua, you just need to set stuff properly in plain Rainmeter, as SilverAzide mentioned as well.
Naturally, you can test both suggestions, see which one works and you prefer, and then settle on it accordingly.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
-
- Rainmeter Sage
- Posts: 2734
- Joined: March 23rd, 2015, 5:26 pm
Re: Topic Revisited finding correct correct variable in a lua sript to use in skin bang function
Good deal! Now you are ready to move ahead...
Now alter the function to add a parameter to pass the name of the meter you are mousing over:
Code: Select all
MouseOverAction=[!CommandMeasure MyLuaScript "MyFunction('#CURRENTSECTION#')"]
Next, alter your function to accept a string parameter, like this:
Code: Select all
function MyFunction(sMeterName)
-- "sMeterName" is a variable that must contain the name of the meter that called this function
-- create a local variable that contains an instance of the meter (this should be the meter showing an event or holiday)
local holidayDayMeter = SKIN:GetMeter(sMeterName)
-- create a local variable that contains the tooltip text from the meter (if any)
local sText = holidayDayMeter:GetOption('ToolTipText')
if (sText == '') then
print('No tooltip text found.')
else
print('Event = ' .. sText)
end
end
-
- Posts: 1383
- Joined: September 7th, 2020, 2:24 pm
- Location: QLD, Australia
Re: Topic Revisited finding correct correct variable in a lua sript to use in skin bang function
This first real look at lua has really actually been productive, in that I have experimented a lot of lua code and gotten a range of results, that if not working - were doing 'something'.SilverAzide wrote: ↑September 14th, 2023, 11:54 pm Good deal! Now you are ready to move ahead...
Now alter the function to add a parameter to pass the name of the meter you are mousing over:I don't know if you need to add DynamicVariables=1 to the style meter; try it without it first, then add it if it doesn't work.Code: Select all
MouseOverAction=[!CommandMeasure MyLuaScript "MyFunction('#CURRENTSECTION#')"]
Next, alter your function to accept a string parameter, like this:
Now when you mouseover the holiday, you should see the event name in the log. Now you have the basics you need to load everything into your tooltip meter.Code: Select all
function MyFunction(sMeterName) -- "sMeterName" is a variable that must contain the name of the meter that called this function -- create a local variable that contains an instance of the meter (this should be the meter showing an event or holiday) local holidayDayMeter = SKIN:GetMeter(sMeterName) -- create a local variable that contains the tooltip text from the meter (if any) local sText = holidayDayMeter:GetOption('ToolTipText') if (sText == '') then print('No tooltip text found.') else print('Event = ' .. sText) end end
Thanks to You Guys!
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
-
- Rainmeter Sage
- Posts: 8030
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Topic Revisited finding correct correct variable in a lua sript to use in skin bang function
Actually, it did work, in terms of values, and you can see that if you replace the suggested 'if' with printing Option and Value:
print(Option .. ':' .. Value)
and look at the log. The issue is probably the fact that in the initially suggested code, this sets the Option on that meter very fast, iterating through all tooltips for every displayed day. It doesn't react the mouse over yet either, as this is done a single time.
In theory, these values and MeterName should instead be added to a newly created and emptied table, and on mouse over the meter name should be passed to lua so it can pick the right tooltip value for the meter you're on in a short function you can add to lua as well. Except for not doing this using the styles, this is more or less what SilverAzide suggested as well, and which you already got working.
![Wink ;-)](./images/smilies/innuendo.gif)
-
- Posts: 1383
- Joined: September 7th, 2020, 2:24 pm
- Location: QLD, Australia
Re: [solved] Finding correct variable in a lua script to use in skin bang function
Oh ya, by the way - this skin as a working example of my task tracker variant frankensteined from many scripts I have found or made from/in these forums.
Happy to share. This was mostly for my own needs, so likely not being released in DevArt or elsewhere for the time being.
Happy to share. This was mostly for my own needs, so likely not being released in DevArt or elsewhere for the time being.
Last edited by CodeCode on September 15th, 2023, 8:11 am, edited 2 times in total.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
-
- Posts: 1383
- Joined: September 7th, 2020, 2:24 pm
- Location: QLD, Australia
Re: Topic Revisited finding correct correct variable in a lua sript to use in skin bang function
Yep. Like I said - I probably missed something obvious to lua coders, vs my being a neophyte to lua.Yincognito wrote: ↑September 15th, 2023, 7:47 am Actually, it did work, in terms of values, and you can see that if you replace the suggested 'if' with printing Option and Value:
print(Option .. ':' .. Value)
and look at the log. The issue is probably the fact that in the initially suggested code, this sets the Option on that meter very fast, iterating through all tooltips for every displayed day. It doesn't react the mouse over yet either, as this is done a single time.
In theory, these values and MeterName should instead be added to a newly created and emptied table, and on mouse over the meter name should be passed to lua so it can pick the right tooltip value for the meter you're on in a short function you can add to lua as well. Except for not doing this using the styles, this is more or less what SilverAzide suggested as well, and which you already got working.![]()
But I do thank you since it takes time to scour through other people's code for rainmeter aside from an advanced lua script designed by a dev.
![Thumbs Up :thumbup:](./images/smilies/ay.gif)
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
-
- Rainmeter Sage
- Posts: 8030
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Topic Revisited finding correct correct variable in a lua sript to use in skin bang function
Nah, it wasn't your mistake, it was mine. In more complex cases, suggesting things by actually testing the code works better than offering a suggestion after a quick look at the code.
![Wink ;-)](./images/smilies/innuendo.gif)