It is currently March 28th, 2024, 5:16 pm

Do While possible?

Discuss the use of Lua in Script measures.
Post Reply
Matth
Posts: 54
Joined: May 17th, 2017, 8:43 am

Do While possible?

Post by Matth »

Hi

Please excuse my ignorance. I have (so far) no clue about Lua and was wondering if this would help me make skins easier to maintain.

I just found out about rainmeter and think there will be a lot of possibilities, although I am a bit frustrated at the lack of a do while loop in the .ini files. If you want to display some data, where you don't know how many records there are (coming from a JSON), or simply with a lot of records, it's quite cumbersome to have to list all the measures and all the meters one by one.

Is it possible to create the meters and measures in Lua with a do while loop? If yes, then I will definitely start learning this to create more skins.

And does Lua have a possibility to access databases, like via ODBC?

Thanks in advance for your help.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Do While possible?

Post by jsmorley »

Matth wrote:Hi

Please excuse my ignorance. I have (so far) no clue about Lua and was wondering if this would help me make skins easier to maintain.

I just found out about rainmeter and think there will be a lot of possibilities, although I am a bit frustrated at the lack of a do while loop in the .ini files. If you want to display some data, where you don't know how many records there are (coming from a JSON), or simply with a lot of records, it's quite cumbersome to have to list all the measures and all the meters one by one.

Is it possible to create the meters and measures in Lua with a do while loop? If yes, then I will definitely start learning this to create more skins.

And does Lua have a possibility to access databases, like via ODBC?

Thanks in advance for your help.
No, it's just not what Rainmeter is about. I understand that if you bring the viewpoint of a procedural programming language to Rainmeter, it's a struggle. Rainmeter at its core is really simple. It runs in a big loop, the skin update cycle, and in each iteration of the loop it updates all the values asked for in measures, and displays results in meters. All measures and meters must be defined up front. It just doesn't have the ability to dynamically create meters based on a numeric for / next loop or a conditional do / while loop. There really are no "loops" of any kind that can run inside the skin update cycle. That would be "blocking", and everything else, including all other skins you might be running, would have to sit and patiently wait for the loop to be done.

It's just not possible with the "foundation" of Rainmeter. Rainmeter was not designed originally to do more than "measure something and display it once every XX milliseconds". While we have stretched it quite a bit, and there will be more cleverness to come, at the end of the day the core structure, the DNA of Rainmeter, won't allow it to be a procedural programming language unless we throw most of it out and start over.

Rainmeter has a lot of capabilities and is very powerful at what it does. Lua adds the ability to do procedural programming, but keep in mind that it is still within the context of the single skin update cycle. If you are expecting the behavior and capabilities C++ or Python or Javascript or even Powershell or VBS, you are going down a rabbit hole that won't lead anywhere. Rainmeter just is NOT an application development environment.

So the short answer to any question like "can I go get some undefined and variable number of data elements, and display all of them in meters?" is no. Specifically, I have no idea if Lua can be made to read an ODBC database using just the native Lua libraries included in our implementation. Maybe, maybe not. (my guess is "not" as I think it would take an external compiled C-language library for Lua, and we don't support that) It's also possible that Rainmeter could execute some external program that could extract elements and capture them in RunCommand or read them with WebParser. However in any case the best you would ever be able to do is say "read the first XX entries, and display them in the XX meters I have designed in my skin."
Matth
Posts: 54
Joined: May 17th, 2017, 8:43 am

Re: Do While possible?

Post by Matth »

Thanks for the detailed reply. Although it's not what I wanted to hear, it's good to know. So I don't have to try and violate the product.

It's a pity though.
Post Reply