It is currently April 18th, 2024, 8:01 pm

Converting RGB to HEX with lua

Get help with creating, editing & fixing problems with skins
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Converting RGB to HEX with lua

Post by jsmorley »

I would, and have, create a Toolkit.lua file, that has as many clever little functions in it that you might ever use. It could have functions to convert text "case" in different ways, format numbers with commas, convert colors between rgb/hex/hsb, convert numbers to text, autoscale numbers, pretty much anything you want. Then you just stick that file in any @Resource folders for skins you might need any of them, and call them as needed, anywhere and as many times as you like in the skin(s), using just one "host" Script measure in the skin.

This file can have hundreds of little functions if you want. None of them are used or expend any resources unless they are "called" in the skin.

Sorry, but I'm just not going to "reinvent the wheel" in every skin I need some function like that, and figure out how to use them multiple times in the same skin without bulking up the code.

This is the beauty of Inline Lua. It's one of the best things we ever did.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Converting RGB to HEX with lua

Post by balala »

jsmorley wrote: March 16th, 2019, 3:03 pm I would, and have, create a Toolkit.lua file, that has as many clever little functions in it that you might ever use. It could have functions to convert text "case" in different ways, format numbers with commas, convert colors between rgb/hex/hsb, convert numbers to text, autoscale numbers, pretty much anything you want. Then you just stick that file in any @Resource folders for skins you might need any of them, and call them as needed, anywhere and as many times as you like in the skin(s), using just one "host" Script measure in the skin.

This file can have hundreds of little functions if you want. None of them are used or expend any resources unless they are "called" in the skin.

Sorry, but I'm just not going to "reinvent the wheel" in every skin I need some function like that, and figure out how to use them multiple times in the same skin without bulking up the code.
Yes, Inline lua probably has great advantage in front of a "classic" code, which doesn't use a lua code.
But where Toolkit.lua is accessible?
User avatar
StArL0rd84
Posts: 424
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Converting RGB to HEX with lua

Post by StArL0rd84 »

jsmorley wrote: March 16th, 2019, 3:03 pm I would, and have, create a Toolkit.lua file, that has as many clever little functions in it that you might ever use. It could have functions to convert text "case" in different ways, format numbers with commas, convert colors between rgb/hex/hsb, convert numbers to text, autoscale numbers, pretty much anything you want. Then you just stick that file in any @Resource folders for skins you might need any of them, and call them as needed, anywhere and as many times as you like in the skin(s), using just one "host" Script measure in the skin.

This file can have hundreds of little functions if you want. None of them are used or expend any resources unless they are "called" in the skin.

Sorry, but I'm just not going to "reinvent the wheel" in every skin I need some function like that, and figure out how to use them multiple times in the same skin without bulking up the code.
Sounds very interesting.
([mWorkTime] = 1 ? #Work# : ([mEnergyLoss:%] >= 70% ? #Chillmode# : </>))
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Converting RGB to HEX with lua

Post by jsmorley »

balala wrote: March 16th, 2019, 3:14 pm Yes, Inline lua probably has great advantage in front of a "classic" code, which doesn't use a lua code.
But where Toolkit.lua is accessible?
I've never posted mine anywhere. Let me clean it up and add a few other things to it and I will do so in another thread.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Converting RGB to HEX with lua

Post by balala »

jsmorley wrote: March 16th, 2019, 3:16 pm I've never posted mine anywhere. Let me clean it up and add a few other things to it and I will do so in another thread.
Ok, I wait it.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5391
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Converting RGB to HEX with lua

Post by eclectic-tech »

jsmorley wrote: March 16th, 2019, 3:16 pm I've never posted mine anywhere. Let me clean it up and add a few other things to it and I will do so in another thread.
:HamseterDancer
Excited to see that release!