It is currently October 15th, 2019, 8:02 pm

Converting RGB to HEX with lua

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

Re: Converting RGB to HEX with lua

jsmorley » 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.

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

Re: Converting RGB to HEX with lua

balala » March 16th, 2019, 3:14 pm

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: 336
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Converting RGB to HEX with lua

StArL0rd84 » March 16th, 2019, 3:15 pm

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.
(#WorkTime# = 1 ? #Work# : ([mEnergyLoss:%] > 100 ? #SleepMode# : #Rainmeter#))
User avatar
jsmorley
Developer
Posts: 19558
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Converting RGB to HEX with lua

jsmorley » March 16th, 2019, 3:16 pm

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: 8823
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Converting RGB to HEX with lua

balala » March 16th, 2019, 4:29 pm

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: 3568
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Converting RGB to HEX with lua

eclectic-tech » March 17th, 2019, 4:16 pm

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!