Do While possible?

Discuss the use of Lua in Script measures.

Do While possible?

May 19th, 2017, 4:41 am
Matth
   [13 posts]

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

Re: Do While possible?

May 19th, 2017, 9:57 pm
jsmorley
Developer   [15575 posts]

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."

Re: Do While possible?

May 21st, 2017, 9:02 am
Matth
   [13 posts]

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.

Return to “Lua Scripting”



Who is online

Users browsing this forum: No registered users and 1 guest