Hello, I have looked for Smurfier and have been told he is unavailable.
I am trying to add a skin bang that shows a tooltip but being visible in a string meter instead.
It is for the holiday event table xls. Formatting the xls was described in detail and that is not an issue, rather using SKIN:Bang('!SetOption', 'MeterSpecial', 'Text', event.description) which works but is not able to iterate on its own for any given month, so everything is skipped and only the last holiday event shows.
This is my entire modified skin - The lua calendar is built into the main ini, so a lot of other code is there. The lua calendar starts at line 269 in the main ini.
I hope someone can help me do this, since the lua is dubbed 'too complex' in a different rm forum in the lua list.
So the main idea is to switch the tooltiptext to a string meter in the skin (MeterSpecial).
It is currently September 8th, 2024, 12:55 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, 10:07 am, edited 2 times in total.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
-
- 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
I don't think starting another post on the same topic is too helpful. Your line of code is not going to do anything, as you noticed, except set the text to whatever the last event of the month is. You need a function that executes on mouseover to do this, I think.CodeCode wrote: ↑September 14th, 2023, 12:47 am Hello, I have looked for Smurfier and have been told he is unavailable.
I am trying to add a skin bang that shows a tooltip but being visible in a string meter instead.
It is for the holiday event table xls. Formatting the xls was described in detail and that is not an issue, rather using SKIN:Bang('!SetOption', 'MeterSpecial', 'Text', event.description) which works but is not able to iterate on its own for any given month, so everything is skipped and only the last holiday event shows.
This is my entire modified skin - The lua calendar is built into the main ini, so a lot of other code is there. The lua calendar starts at line 269 in the main ini.
I hope someone can help me do this, since the lua is dubbed 'too complex' in a different rm forum in the lua list.
So the main idea is to switch the tooltiptext to a string meter in the skin (MeterSpecial).
I already gave you one approach here. Did you try it?
Attempting to change Smurfier's code is a mistake in my opinion. Add separate functions to it maybe, but don't change it. The only code you should change is the stylesheet that controls the appearance; this is the point of Smurfier's skin.
-
- 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
I subscribe to what SilverAzide said, folks checking this forum regularly probably read your other post anyway (I know I did), so it won't help with the visibility or with bumping the other thread. Also, the MouseOver / MouseLeave approach described by SilverAzide is likely to be the way to go if you want to display whatever is in the tooltip in a meter instead.
Anyway, if you want to redirect the tooltip contents to a specific meter you already have (like it appears to be), a brief visual examination of the original Lua code you posted in the other thread seems to indicate that searching for TooltipText in the file might give you an indication of what exactly goes in the tooltip. Maybe you can use the value set in that bang to set it into your specific meter too, and then either comment out whatever relevant tooltip options exist in the stylesheet / template skin (sorry, not familiar with Smurfier's calendar, and the code length is sending shivers down my spine, lol), or disable tooltips entirely via the corresponding Rainmeter option.
Anyway, if you want to redirect the tooltip contents to a specific meter you already have (like it appears to be), a brief visual examination of the original Lua code you posted in the other thread seems to indicate that searching for TooltipText in the file might give you an indication of what exactly goes in the tooltip. Maybe you can use the value set in that bang to set it into your specific meter too, and then either comment out whatever relevant tooltip options exist in the stylesheet / template skin (sorry, not familiar with Smurfier's calendar, and the code length is sending shivers down my spine, lol), or disable tooltips entirely via the corresponding Rainmeter option.
-
- 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
I would also quote SilverAzide to reply, rather I will say that I have 'tried' but I either don't understand the concept correctly, or it doesnt work.Yincognito wrote: ↑September 14th, 2023, 2:47 am ...the MouseOver / MouseLeave approach described by SilverAzide is likely to be the way to go if you want to display whatever is in the tooltip in a meter instead.
... or disable tooltips entirely via the corresponding Rainmeter option.
Searching for tooltip in the lua reveals nothing useful. It is declared a variable in single quotes, but that does not seem useful to me since I do not know how to use rainmeter bangs or which bangs to use as add ins (rather than altering existing code). The one thing I got working is the tooltip content "indicator" 'event.description' and used in a skin setoption bang, which locks me tidally to the last holiday in a month.
The tooltip baffles me, there are so few mentions of that or 'tooltiptext' that trying to jam a screwdriver into into any of those code positions breaks everything.
I actually managed to get an iterator happening but it was completely mental. I moved month to month until there were multiple holiday events - December - by continuing to click the month (remember this is not good) the holiday were read but not in any way that I could leverage.
The code is mostly checks to prevent the lua from breaking if the xml was edited incorrectly.
So jumping back to SilverAzide's suggestion to 'hotwire' the lua with a skinbang in the lua to pass to my text meter. I tried what I thought SilverAzide was suggesting but, either nothing happens, or I break it, or back to ground zero tidally locked to the last event in any given month.
The only thing in the rainmeter script that could be used as a springboard was mouseupaction was by inserting a skin bang to the holiday indicator style "HolidayStyle. So in that mind is where is was trying to send the mouseover event to and use the event.description variable as the meter value. But - the mouseover doesnt work. I tried to use a few skin bang calls like enable/force SkinBang!EnableMouseAction... and skinbang !update, and round and round I went. With no working result - and remember again this is what I was trying to do to try SilverAzide's suggestion/ idea.
I dont think I actually get the suggestion correctly. I seriously believe that the right of skinbangs and meter or even string measure for the HolidayStyle be used as the measure for the string meter... ?? kinds stuck there. Since me the complete novice found the event.description and got it to populate the string meter means that variable just needs to be the value for 'something' with the proper skinbang.??
![Confused :confused:](./images/smilies/bn.gif)
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
-
- 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
To elaborate a little, (one of) the main points of Smurfier's skin was to create a skin that was controlled entirely by a stylesheet. The mechanics of how to display the months, incorporate events, etc., is all behind Lua script which shouldn't be altered. The only thing you want to change is the stylesheet he has provided, along with whatever variables that control the size and placement of a date "cell", etc. As you found, there is a "holiday style" that handles holidays, there are more styles for the background, weekdays, etc.CodeCode wrote: ↑September 14th, 2023, 8:01 am I dont think I actually get the suggestion correctly. I seriously believe that the right of skinbangs and meter or even string measure for the HolidayStyle be used as the measure for the string meter... ?? kinds stuck there. Since me the complete novice found the event.description and got it to populate the string meter means that variable just needs to be the value for 'something' with the proper skinbang.??![]()
That does not mean you can't add more meters (or measures). You'd add them to the style sheet, NOT the main calendar skin. This is where your special "tooltip meter" would go.
So, what you need to do, I think, is A) turn off the standard tooltips globally to prevent them from appearing, and B) change the "holiday style" style meter to react to a set of mouseover/mouseleave events that you create. The Smurfier's Lua code will apply the style to the appropriate day meter.
In your mouseover, add a bang to execute a script function, something like:
Code: Select all
MouseOverAction=[!CommandMeasure YourLuaScript "YourFunction('#CURRENTSECTION#')"]
Your function will take the name of the meter that you moused-over as a parameter. You can then use GetMeter and GetOption functions to pluck the ToolTipText value from this meter (if it exists). If text does not exist, just return silently. Otherwise, stuff the text into your own measure, dynamically move it (if needed), and show it. All your mouseleave event needs to do is hide your tooltip.
-
- 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
Just to explore the alternative, in the Lua code, there is:CodeCode wrote: ↑September 14th, 2023, 8:01 am Searching for tooltip in the lua reveals nothing useful. It is declared a variable in single quotes, but that does not seem useful to me since I do not know how to use rainmeter bangs or which bangs to use as add ins (rather than altering existing code).
Code: Select all
-- Define meter properties
local MeterName = Meters.Days.Name(MeterNumber)
local MeterProperties = {
Text = LeadingZero(day),
MeterStyle = table.concat(Styles, '|'),
[Settings.EventText or 'ToolTipText'] = EventText or '',
[Settings.EventColor or 'FontColor'] = EventColor or '',
}
for Option, Value in pairs(MeterProperties) do
SKIN:Bang('!SetOption', MeterName, Option, Value)
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
Ok that seems a fair bit clearer to me. I hit another snag in writing a lua script file - or add into Smurifer's lua - I will try the latter first - even though I will likely be trying to write a function in lua for the first time. But alas, I have banged around in Smurfier's lua and have a better understanding since trying this idea was percolating, but I am not very confident it wont take a while.SilverAzide wrote: ↑September 14th, 2023, 10:48 am To elaborate a little, (one of) the main points of Smurfier's skin was to create a skin that was controlled entirely by a stylesheet. The mechanics of how to display the months, incorporate events, etc., is all behind Lua script which shouldn't be altered. The only thing you want to change is the stylesheet he has provided, along with whatever variables that control the size and placement of a date "cell", etc. As you found, there is a "holiday style" that handles holidays, there are more styles for the background, weekdays, etc.
That does not mean you can't add more meters (or measures). You'd add them to the style sheet, NOT the main calendar skin. This is where your special "tooltip meter" would go.
So, what you need to do, I think, is A) turn off the standard tooltips globally to prevent them from appearing, and B) change the "holiday style" style meter to react to a set of mouseover/mouseleave events that you create. The Smurfier's Lua code will apply the style to the appropriate day meter.
In your mouseover, add a bang to execute a script function, something like:This implies you need your own script measure (YourLuaScript), but you can tack your code into Smurfier's if you want to leverage his existing code.Code: Select all
MouseOverAction=[!CommandMeasure YourLuaScript "YourFunction('#CURRENTSECTION#')"]
Your function will take the name of the meter that you moused-over as a parameter. You can then use GetMeter and GetOption functions to pluck the ToolTipText value from this meter (if it exists). If text does not exist, just return silently. Otherwise, stuff the text into your own measure, dynamically move it (if needed), and show it. All your mouseleave event needs to do is hide your tooltip.
Thanks for going through that for me, again.
![Thumbs Up :thumbup:](./images/smilies/ay.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
That is one of those places where almost everything I tried broke the calendar. But to be certain it is not due to overlapping or incorrectly defined additions to that for loop, I would ask for a leg up, please to get how to add skin:bangs in a fore loop. But before I fall off the edge of my learning curve - curly brackets would ensure the added tooltip grabbing bang/s - Yes? Well I will also try this during the hours the western world is awake and peeps are busy with RL.Yincognito wrote: ↑September 14th, 2023, 11:51 am Just to explore the alternative, in the Lua code, there is:This seems to set the values in the relevant meters. You could try adding an if condition in the for loop, testing whether Option is the ToolTipText string, and if so, use a similar bang to set the value of your specific meter to Value as well. This assumes you already have your meter set up and behaving as desired in your plain Rainmeter code.Code: Select all
-- Define meter properties local MeterName = Meters.Days.Name(MeterNumber) local MeterProperties = { Text = LeadingZero(day), MeterStyle = table.concat(Styles, '|'), [Settings.EventText or 'ToolTipText'] = EventText or '', [Settings.EventColor or 'FontColor'] = EventColor or '', } for Option, Value in pairs(MeterProperties) do SKIN:Bang('!SetOption', MeterName, Option, Value) end
Is this correct - I admit I am asking a lot and not looking things up on my own more - I always keep saying I am going to tackle the fundamentals of lua - well, now I finally am. And what would be a better working example than slicing around in a lua script as detailed as Smurfiers?
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
-
- 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
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.
Code: Select all
function MyFunction()
print("hello world")
end
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.
-
- 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
Curly brackets in Lua:CodeCode wrote: ↑September 14th, 2023, 4:01 pm That is one of those places where almost everything I tried broke the calendar. But to be certain it is not due to overlapping or incorrectly defined additions to that for loop, I would ask for a leg up, please to get how to add skin:bangs in a fore loop. But before I fall off the edge of my learning curve - curly brackets would ensure the added tooltip grabbing bang/s - Yes? Well I will also try this during the hours the western world is awake and peeps are busy with RL.
Is this correct - I admit I am asking a lot and not looking things up on my own more - I always keep saying I am going to tackle the fundamentals of lua - well, now I finally am. And what would be a better working example than slicing around in a lua script as detailed as Smurfiers?
As an aside, I corrected a fairly hiding in plain sight series of errors - so time away from lua well spent - more rainmeter lol
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.