It is currently August 12th, 2022, 6:36 pm

Add ReplaceMeasures to Lua :GetOption()

Report bugs with the Rainmeter application and suggest features.
User avatar
death.crafter
Rainmeter Sage
Posts: 1370
Joined: April 24th, 2021, 8:13 pm

Add ReplaceMeasures to Lua :GetOption()

Post by death.crafter »

There is a replacemeasures parameter to ReadString. It would be helpful if that was implemented in lua.

For example, if we wanted to get the initial value of an option, we can get the actual string, and not the value, e.g if Text=#SomeVariable#, then we'd get #SomeVariable# instead if it's actual value.

This can be an useful addition, without much changes (I guess.)
from the Realm of Death
User avatar
Yincognito
Rainmeter Sage
Posts: 4778
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Add ReplaceMeasures to Lua :GetOption()

Post by Yincognito »

death.crafter wrote: February 15th, 2022, 9:01 am There is a replacemeasures parameter to ReadString. It would be helpful if that was implemented in lua.

For example, if we wanted to get the initial value of an option, we can get the actual string, and not the value, e.g if Text=#SomeVariable#, then we'd get #SomeVariable# instead if it's actual value.

This can be an useful addition, without much changes (I guess.)
I'll let the devs answer this, but just cause it's related, you could parse the skin INI yourself and get the needed string. For example, this gets the current skin in a variable called contents (it opens and displays UCS2 LE BOM files as well - I have no idea if this was already possible or described somewhere on the forum, since a quick test of the ReadIni snippet from the manual couldn't open my skin), which you can then parse to get sections, options or keys:

Code: Select all

function Initialize()
  contents = ''
end

function Update()
  local file = assert(io.open(SKIN:MakePathAbsolute(SKIN:ReplaceVariables('#CURRENTFILE#')), 'r'), 'Unable to load ' .. SKIN:MakePathAbsolute(SKIN:ReplaceVariables('#CURRENTFILE#')))
  contents = file:read('*a'):sub(3):gsub('%z', '')
  file:close()
end

function Function()
  print(contents)
  return true
end
There must be something odd about the code though, cause using return contents in Function() hangs Rainmeter.

Source: here.

Anyway, I'm sure you already knew that, it was more of a side / related topic.
User avatar
death.crafter
Rainmeter Sage
Posts: 1370
Joined: April 24th, 2021, 8:13 pm

Re: Add ReplaceMeasures to Lua :GetOption()

Post by death.crafter »

Yincognito wrote: February 15th, 2022, 3:18 pm I'll let the devs answer this, but just cause it's related, you could parse the skin INI yourself and get the needed string.
Unfortunately, Lua doesn't read UTF-16 encoded files.
from the Realm of Death
User avatar
Yincognito
Rainmeter Sage
Posts: 4778
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Add ReplaceMeasures to Lua :GetOption()

Post by Yincognito »

death.crafter wrote: February 15th, 2022, 4:25 pm Unfortunately, Lua doesn't read UTF-16 encoded files.
Oh, ok. I've seen some coding / decoding of UTF-16 in Lua, but don't know if that can be aplied to files indeed.
User avatar
death.crafter
Rainmeter Sage
Posts: 1370
Joined: April 24th, 2021, 8:13 pm

Re: Add ReplaceMeasures to Lua :GetOption()

Post by death.crafter »

Bump! Bump! Bump!
from the Realm of Death
User avatar
Brian
Developer
Posts: 2436
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Add ReplaceMeasures to Lua :GetOption()

Post by Brian »

Just to be clear, the "ReplaceMeasures" parameter to "ReadString" has no effect on regular #variables#.

So, if added, it would only effect section variables [MeasureName], and nested variables [#Some[#Var]].

-Brian
User avatar
Brian
Developer
Posts: 2436
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Add ReplaceMeasures to Lua :GetOption()

Post by Brian »

I added this for the next release.

-Brian
User avatar
death.crafter
Rainmeter Sage
Posts: 1370
Joined: April 24th, 2021, 8:13 pm

Re: Add ReplaceMeasures to Lua :GetOption()

Post by death.crafter »

Brian wrote: March 2nd, 2022, 12:03 am I added this for the next release.

-Brian
Thanks a lot Brian! :rosegift:
from the Realm of Death