It is currently March 28th, 2024, 10:17 am

Convert time to number

Get help with creating, editing & fixing problems with skins
Post Reply
User avatar
deXxterlab97
Posts: 93
Joined: February 5th, 2017, 4:50 am
Contact:

Convert time to number

Post by deXxterlab97 »

I want to make a simple time bar but having trouble.
Basically that bar looks like this

Code: Select all

[Bar Background]
Meter=Image
X=-15
Y=30
H=3
W=285
SolidColor=255,255,255,60

[MeterBar]
Meter=BAR
MeasureName=MeasureSec
X=-15
Y=30
H=3
W=285
BarColor=255,255,255,240
BarOrientation=Horizontal
I want the bar to gets filled up as seconds passed
So 0 sec the bar is empty, 30 secs the bar is half full (yes not half empty) and 59 the bar is filled
and then goes back again

But from my understanding is that
[MeasureSec]
Measure=Time
Format=%S
Return in text not number? What do I do?
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Convert time to number

Post by CyberTheWorm »

You will need something like this as the bar only use 0-1 for the length, then you can use the MeasureSec for the information for the bar.

Code: Select all

[MeasureTime]
Measure=Time
Format=%S

[MeasureSec]
Measure=Calc
Formula=MeasureTime / 59
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Convert time to number

Post by balala »

deXxterlab97 wrote:I want the bar to gets filled up as seconds passed
So 0 sec the bar is empty, 30 secs the bar is half full (yes not half empty) and 59 the bar is filled
and then goes back again

But from my understanding is that

Return in text not number? What do I do?
CyberTheWorm's solution will work and can be used, however a simpler solution exists. The initial problem is that the MeasureName option of a bar meter (in this case [MeterBar]), requires a measure which returns percentual values. But [MeasureSec] doesn't do this, it simply returns numbers. The [MeasureSec] measure posted by CyberTheWorm, does returns percentual values, but there is, as I said, a simpler solution. According to this, you just have to add a MinValue and a MaxValue option to your initial [MeasureSec] measure:

Code: Select all

[MeasureSec]
Measure=Time
Format=%S
MinValue=0
MaxValue=60
Nothing else isn't required.
A few more tips:
  • Usually it's not a good idea to use spaces in the names of different sections. You've used one in the name of the [Bar Background] meter. I'd remove it, naming that meter [BarBackground]. On long terms, you'll have a lot of problems if you not get used to not use spaces.
  • The [Bar Background] (or [BarBackground], if you rename it as I said above) meter is useless. Instead, you could move the SolidColor=255,255,255,60 option directly to the [MeterBar] meter, avoiding a plus section in your code. You'll see the same result.
  • Are you sure about these two colors?

    Code: Select all

    [Bar Background]
    ...
    SolidColor=255,255,255,60
    
    [MeterBar]
    ...
    BarColor=255,255,255,240
    Because I can't easily see a difference between them, they are almost the same. I'd replace one of them with a slightly different color.
  • Do you have any reason why are you using negative X values? These negative values are pushing the meters partially outside of the skin, to left. There is no possibility to make them entirely visible.
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Convert time to number

Post by CyberTheWorm »

balala wrote:

Code: Select all

[MeasureSec]
Measure=Time
Format=%S
MinValue=0
MaxValue=60
Nice balala, never thought of doing that, but the

Code: Select all

MaxValue=60 should be 59
:thumbup:
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Convert time to number

Post by balala »

CyberTheWorm wrote:Nice balala, never thought of doing that, but the

Code: Select all

MaxValue=60 should be 59
:thumbup:
It depends. If you set MaxValue=60 the bar will never fill up entirely, because 60 seconds is never reached. If you set MaxValue=59,on the last step, the bar will fill up completely. Depends what you (he) prefer.
User avatar
deXxterlab97
Posts: 93
Joined: February 5th, 2017, 4:50 am
Contact:

Re: Convert time to number

Post by deXxterlab97 »

balala wrote:It depends. If you set MaxValue=60 the bar will never fill up entirely, because 60 seconds is never reached. If you set MaxValue=59,on the last step, the bar will fill up completely. Depends what you (he) prefer.
Thanks guys I figured it myself later lol
[MeasureSec]
Measure=Time
Format=%S
DynamicVariables=1
MinValue=0
MaxValue=59

[Bar Background]
Meter=Image
X=-15
Y=30
H=3
W=285
SolidColor=255,255,255,60

[MeterBar]
Meter=BAR
MeasureName=MeasureSec
X=-15
Y=30
H=3
W=285
BarColor=255,255,255,240
BarOrientation=Horizontal
Post Reply