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.)
It is currently September 8th, 2024, 12:47 am
Add ReplaceMeasures to Lua :GetOption()
-
- Rainmeter Sage
- Posts: 1398
- Joined: April 24th, 2021, 8:13 pm
Add ReplaceMeasures to Lua :GetOption()
from the Realm of Death
-
- Rainmeter Sage
- Posts: 8030
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Add ReplaceMeasures to Lua :GetOption()
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: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.)
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
Source: here.
Anyway, I'm sure you already knew that, it was more of a side / related topic.
-
- Rainmeter Sage
- Posts: 1398
- Joined: April 24th, 2021, 8:13 pm
Re: Add ReplaceMeasures to Lua :GetOption()
Unfortunately, Lua doesn't read UTF-16 encoded files.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.
from the Realm of Death
-
- Rainmeter Sage
- Posts: 8030
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Add ReplaceMeasures to Lua :GetOption()
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.death.crafter wrote: ↑February 15th, 2022, 4:25 pm Unfortunately, Lua doesn't read UTF-16 encoded files.
-
- Rainmeter Sage
- Posts: 1398
- Joined: April 24th, 2021, 8:13 pm
-
- Developer
- Posts: 2725
- Joined: November 24th, 2011, 1:42 am
- Location: Utah
Re: Add ReplaceMeasures to Lua :GetOption()
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
So, if added, it would only effect section variables [MeasureName], and nested variables [#Some[#Var]].
-Brian
-
- Developer
- Posts: 2725
- Joined: November 24th, 2011, 1:42 am
- Location: Utah
Re: Add ReplaceMeasures to Lua :GetOption()
I added this for the next release.
-Brian
-Brian
-
- Rainmeter Sage
- Posts: 1398
- Joined: April 24th, 2021, 8:13 pm