It is currently October 15th, 2024, 12:25 am

Return tuple(?) in lua Update function

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

Return tuple(?) in lua Update function

Post by death.crafter »

I have a suggestion, that enables Update to return both number and string value, and that while maintaining backwards compatibility.

So, along with returning a number, or a string, Update can return a two-element table. The first element will be the number value, and the second will be the string value.

For example,
Screenshot 2022-09-02 224852.png
Now the example above is a lua script, and I have already made the said changes. Now, it's about what you guys think about it. I will be more than happy to have this feature. I mean

Code: Select all

[SomeSection]
SomeOption = "num = [Script:], str = [Script]"
is a lot better than

Code: Select all

[SomeSection]
SomeOption = "num = [Script], str = [&Script:GetStringValue()]"
You do not have the required permissions to view the files attached to this post.
from the Realm of Death
User avatar
Brian
Developer
Posts: 2738
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Return tuple(?) in lua Update function

Post by Brian »

death.crafter wrote: September 2nd, 2022, 5:26 pm I have a suggestion, that enables Update to return both number and string value, and that while maintaining backwards compatibility.

So, along with returning a number, or a string, Update can return a two-element table. The first element will be the number value, and the second will be the string value.

For example,
Screenshot 2022-09-02 224852.png
Now the example above is a lua script, and I have already made the said changes. Now, it's about what you guys think about it. I will be more than happy to have this feature. I mean

Code: Select all

[SomeSection]
SomeOption = "num = [Script:], str = [Script]"
is a lot better than

Code: Select all

[SomeSection]
SomeOption = "num = [Script], str = [&Script:GetStringValue()]"
I am fine with that, but the development team will probably want to discuss this internally. I suggest submitting a PR with the changes.

One note, you could probably verify the "type" of each element and assign it accordingly to the string/number values. This way, "order" wouldn't matter. You could probably accept nil and boolean values as well. nil having a number value of 0, and a empty string value. Boolean values having number values of 0 for false, 1 for true - and string values of "false" and "true";

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

Re: Return tuple(?) in lua Update function

Post by death.crafter »

Actually, enforcong the order will make things a little better.

Like returning {"24", "Twenty-Four"}, will give you the correct results. The number value can support numbers, string numbers, nil and booleans. The string part can support string and nil. You get the gist.
from the Realm of Death