A bit more detail would be helpful. What do you intend to do with the separate values? It matters, since if they are going to be used in separate meters in the skin, some thought needs to be given to the variable length of the number.
Breaking the number up in Lua can be done several ways and is pretty easy, but which way you go can depend on what you are going to be using it for.
Thanks for your reply. Looking back on what I wrote, I realised that it is actually confusing even to myself. Hopefully I'll make it more understandable this time
The length of the number itself will always be three digits, a decimal point and another digit. So the length will always be four digits (five including the decimal point, but I'm guessing that wouldn't come into it). It's the individual digits that will change.
With those digits, I am hoping to turn them into bars so the length of each bar will be dependant on the digit. For example, with the number 526.4, 5 would be 50 pixels high, the 2 would be 20 pixels high, and so on.
FoxyXII wrote:Thanks for your reply. Looking back on what I wrote, I realised that it is actually confusing even to myself. Hopefully I'll make it more understandable this time
The length of the number itself will always be three digits, a decimal point and another digit. So the length will always be four digits (five including the decimal point, but I'm guessing that wouldn't come into it). It's the individual digits that will change.
With those digits, I am hoping to turn them into bars so the length of each bar will be dependant on the digit. For example, with the number 526.4, 5 would be 50 pixels high, the 2 would be 20 pixels high, and so on.
Hope that helps.
Not sure I see any great advantage to Lua, assuming you aren't going to be doing this with a boatload of numbers in the skin, where a "for/next" or "called function" approach might reduce some code. With just one number, I think it's just as easy to do it in native Rainmeter. Keep in mind that this method entirely depends on there being exactly that format \d\d\d.\d.
Then you can use the string value of those measures however you like. Just be sure if you use them in a formula, that you use [MeasureDig1] as a [SectionVariable], so the substituted string value and not the number value is used, and set DynamicVariables=1 wherever you use them.
Having said that, if you have other value-added processing you need to do in Lua with the digits, and want to split them in Lua instead of Rainmeter, let me know. It's certainly not hard.
You do not have the required permissions to view the files attached to this post.
function SplitNum(numArg, posArg)
return string.sub(numArg, posArg, posArg)
end
posArg should be one of 1, 2, 3 or 5 in this case...
Lua is very dynamically "typed", so treating something that looks like a number as either a number or string value is completely transparent. Lua doesn't care, and leaves it up to you.
But at the end of the day, you are going to need four Calc measures in any case, to provide a percentage value to use with MeasureName in the Bar meters. So the advantage to Lua in this case is that you would really need eight measures to do this natively in Rainmeter, (four to use Substitute to split the string value, and four to turn that into a percentage number value) but only four if you get the value as a number instead of a string from Lua.