It is currently September 29th, 2024, 3:23 pm

Dynamic meter/measure creation with Lua and other thoughts.

General topics related to Rainmeter.
greatwolf
Posts: 8
Joined: May 15th, 2012, 3:11 am

Dynamic meter/measure creation with Lua and other thoughts.

Post by greatwolf »

I'm looking to create a skin that can display worker and stats for a bitcoin mining pool. Something I'm running into is that there seems to be no way to create a measure/meter dynamically using say a lua script. From what I can tell all modifications done on a skin and its components must exist ahead of time.

Here's the problem and use case I'm thinking of: a miner can have a variable number of workers setup. For each worker it will have various statistical info included with it in json format. Info can include but not limited to: worker name, valid shares submitted and estimated hashrate.

Right now I'm creating one measure and one meter for each worker that I happen to have setup. Someone else might have less workers created and others still could have more. The problem is you can only determine at runtime how many workers there actually are after you retrieve the json info file. Since the number of meters and measures can't be changed without going back to the ini file and editing it manually, this creates usage inconvenience as well as being error-prone.

What's the best way to deal with this issue? Are there any thoughts on doing away with .ini file completely and replace it with a lua file instead? There's a chapter in the Lua programming book on how lua files can take the role of a typical config/ini file. I think it would solve the dynamic creation problem since now the ini file is itself a Lua script.

Atm, my skin just has a hardcoded number of meters and measures at least enough for my current scenario. Since this is static in nature, if I add or remove a worker in the future, I would need to re-edit this ini file to make meter/measures match as explained earlier.

Thanks
User avatar
KreAch3R
Posts: 608
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Dynamic meter/measure creation with Lua and other though

Post by KreAch3R »

You can certainly have .lua hide or un-hide meters based on the number of workers, possibly included in the .json file as a separate entry, or by being calculated by the number of entries.
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
greatwolf
Posts: 8
Joined: May 15th, 2012, 3:11 am

Re: Dynamic meter/measure creation with Lua and other though

Post by greatwolf »

But the problem is that all those meters and measures will still exist whether they're hidden or not. It also results in a lot of code duplication in the ini.

It also seems like hidden meters takes up physical space in the skin -- I can't seem to find a way to adjust the skin dimension to fit just for the meters that are visible.
User avatar
KreAch3R
Posts: 608
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Dynamic meter/measure creation with Lua and other though

Post by KreAch3R »

Yes, they will exist, but the measures can be disabled and the meters can be hidden. Except for a really long file (depending on correct coding), I haven't come up to a change in performance, due to that.

As for "physical space"; that is not true. If you assing relative X,Y positions to your meters, only the visible ones will be counted (I presume), thus making the meters allign themselves. Take a look at one of my skins:
Image

EDIT: Also, you may need DynamicWindowSize=1 in your [Rainmeter] Section.
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
greatwolf
Posts: 8
Joined: May 15th, 2012, 3:11 am

Re: Dynamic meter/measure creation with Lua and other though

Post by greatwolf »

Thanks I'll check that out :)
greatwolf
Posts: 8
Joined: May 15th, 2012, 3:11 am

Re: Dynamic meter/measure creation with Lua and other though

Post by greatwolf »

Can you provide a link to that skin you're referring to? I'm having trouble locating it.
greatwolf
Posts: 8
Joined: May 15th, 2012, 3:11 am

Re: Dynamic meter/measure creation with Lua and other though

Post by greatwolf »

After looking through the rainmeter manual again, I still don't see any straightforward way to 'fill in' the empty space left behind from a hidden meter. But the screenshot you showed is clearly accomplishing it in someway. It would have been more helpful if you posted the link to the code for that plugin so I could actually look at it.
greatwolf
Posts: 8
Joined: May 15th, 2012, 3:11 am

Re: Dynamic meter/measure creation with Lua and other though

Post by greatwolf »

I'm controlling meters from the lua script btw. Is there anyway to set meter position using relative values similar to using Y=r like in the ini?
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Dynamic meter/measure creation with Lua and other thoughts.

Post by smurfier »

A hidden meter has no defined height and width and retains its x and y position. What this means is that any meter that uses relative positioning will use the x and y of the previous meter regardless of weather it is visible or hidden.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
greatwolf
Posts: 8
Joined: May 15th, 2012, 3:11 am

Re: Dynamic meter/measure creation with Lua and other though

Post by greatwolf »

smurfier wrote:A hidden meter has no defined height and width and retains its x and y position. What this means is that any meter that uses relative positioning will use the x and y of the previous meter regardless of weather it is visible or hidden.
Thanks for the response. Does that still hold true when positioning is modified from a lua script? From my limited experimenting the string meter text end up on top of each other unless I specify an absolute position. I've tried this with the bang option !MoveMeter as well as the SetY.

Code: Select all

SKIN:Bang('!MoveMeter 10 60 meterStatLeft2')
SKIN:Bang('!MoveMeter 290 60 meterStatRight2')
--SKIN:GetMeter('meterStatLeft2'):SetY(60)
--SKIN:GetMeter('meterStatRight2'):SetY(60)
Those are absolute coordinates and it displays correctly. However if I did this instead:

Code: Select all

SKIN:Bang('!MoveMeter 10 20r meterStatLeft2')
SKIN:Bang('!MoveMeter 290 20r meterStatRight2')
then the text for the meters just overlap each other. But those are the same values I used in my ini file and that displays correctly.