It is currently June 1st, 2024, 5:22 pm

LUA GetOption() - How to preserve variable references?

Discuss the use of Lua in Script measures.
User avatar
balala
Rainmeter Sage
Posts: 16289
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: LUA GetOption() - How to preserve variable references?

Post by balala »

Even if a little bit late, could you raiguard please pack the whole config and upload it? I'd like to check the exact skin as you have it right now, because I think I have a tip...
User avatar
raiguard
Posts: 660
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA

Re: LUA GetOption() - How to preserve variable references?

Post by raiguard »

You mean the skin where I implemented the workaround? Download the latest version of ModernGadgets and have a look at any of the settings skins which have color customization in them.
”We are pretty sure that r2922 resolves the regression in resolution caused by a reversion to a revision.” - jsmorley, 2017
User avatar
balala
Rainmeter Sage
Posts: 16289
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: LUA GetOption() - How to preserve variable references?

Post by balala »

raiguard wrote: June 3rd, 2019, 2:41 am Download the latest version of ModernGadgets and have a look at any of the settings skins which have color customization in them.
Like which one? Because the only one where I think a such setting exists is the Global Settings, where a Color Customization can be found, but if I click any of those elements (like Main Font Color), nothing is happening.
Am I doing something wrong?
User avatar
raiguard
Posts: 660
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA

Re: LUA GetOption() - How to preserve variable references?

Post by raiguard »

balala wrote: June 3rd, 2019, 4:12 pm Like which one? Because the only one where I think a such setting exists is the Global Settings, where a Color Customization can be found, but if I click any of those elements (like Main Font Color), nothing is happening.
Am I doing something wrong?
CPU Meter settings has the most color customization in it. When you click it my ColorPickerPlus skin should show up to let you change the color.
”We are pretty sure that r2922 resolves the regression in resolution caused by a reversion to a revision.” - jsmorley, 2017
User avatar
balala
Rainmeter Sage
Posts: 16289
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: LUA GetOption() - How to preserve variable references?

Post by balala »

Ok, it does seem to be working alright now. Does it?
User avatar
raiguard
Posts: 660
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA

Re: LUA GetOption() - How to preserve variable references?

Post by raiguard »

balala wrote: June 4th, 2019, 6:50 am Ok, it does seem to be working alright now. Does it?
Yeah. I implemented a dirty workaround, but I would still like to find out how I could solve my original problem if possible.
”We are pretty sure that r2922 resolves the regression in resolution caused by a reversion to a revision.” - jsmorley, 2017
User avatar
balala
Rainmeter Sage
Posts: 16289
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: LUA GetOption() - How to preserve variable references?

Post by balala »

raiguard wrote: June 6th, 2019, 4:21 am but I would still like to find out how I could solve my original problem if possible.
Isn't it solved? If the color setting is working, I think it is. Or am I missing something?
Crest
Posts: 131
Joined: August 16th, 2013, 12:47 pm

Re: LUA GetOption() - How to preserve variable references?

Post by Crest »

Yeah such a function would help a great deal in certain scenarios.

Edit: I think the workaround will actually also work for my nested var swap scenario on reflection.
User avatar
Jeff
Posts: 335
Joined: September 3rd, 2018, 11:18 am

Re: LUA GetOption() - How to preserve variable references?

Post by Jeff »

https://docs.rainmeter.net/manual/lua-scripting/#GetOption
There slightly is a tool that would have helped with this, GetOption used to have an undocumented function that was documented recently on the page.
To quote it directly, "If the optional boolean parameter bReplaceMeasures is provided, when set to false it will not replace any section variables before retrieving that option."
That being said, it will not work here, since normal/new/nested variables when dealt with inside Rainmeter, they are already replaced in memory and RM has no idea what they were before-hand, you could technically just write

Code: Select all

[MyVariable]
Measure=String
String=255,0,5
and just use Section Variables for variables, bReplaceMeasure just works here, but you may be losing some benefits from normal variables (I can't think of any right now though).
Crest
Posts: 131
Joined: August 16th, 2013, 12:47 pm

Re: LUA GetOption() - How to preserve variable references?

Post by Crest »

Jeff wrote: May 21st, 2024, 11:47 am https://docs.rainmeter.net/manual/lua-scripting/#GetOption
There slightly is a tool that would have helped with this, GetOption used to have an undocumented function that was documented recently on the page.
I tried this with a string measure but wasn't sure what you meant in terms of your comment about storing the variables as section variables. As-is with that boolean enabled the best I'm finding it can do with disabling parsing is just regular section vars like :W and such (expectedly, given the description), while the rest get parsed (including variables that themselves reference section vars).

What I ended up doing for different scenario I ran into following my post was reproducing an entire (necessarily lengthy) variable with hash-escaped strings (using balala's suggestion). Obviously non-ideal since it adds more redundant code but at least the variables get preserved for subsequent swapping via Lua.

Since, for some context, any dynamic changes (size, etc) don't get updated the moment a pre-parsed `GetOption` is swapped in as a replacement meter value, so the raw variables are needed.

So I'm using both workarounds from this thread: for simpler single variable names using a custom meter option, while for variables containing multiple variable names using an escaped copy under a different variable name and retrieved using Lua.