Welcome, Guest. Please login or register.
Did you miss your activation email?
November 10, 2024, 07:00:36 AM
Home Help Login Register
News: Zombie Master 2 discussion

Zombie Master  |  Other  |  Trouble in Terrorist Town  |  Topic: Smooth Increment
Pages: [1]
Author Topic: Smooth Increment  (Read 3354 times)
Manmax75
Poster

Posts: 254


Programming Guy


« on: September 11, 2010, 03:48:02 AM »

Hello I have made this TTTprogressbar, HUD thing, for one of my SWEPS and what I want it to do is smoothly increment the bar value from 0% to %100 percent over a 10 second time span. I currently have the maximum value set to 1000 and minimum to 0. The code that I currently have to increment the code is placed in a think function which runs on every client tick:

bar:SetValue(math.min(1000, 50*CurTime())


Ride Forward and Thrust Your Pelvis In The Dark Void. The One Induced By Pleasure Yet Cast By The Bigger Picture.
Bad King Urgrain
Administrator
*****
Posts: 12276



« Reply #1 on: September 11, 2010, 08:52:05 AM »

What you should do is take the CurTime at the start of your 10 seconds, add 10 to it, and then make the progress bar show the fraction that the current CurTime value is of your computed time.

-- This says: the bar should be at 100% when we reach the time that is 10 seconds from now.
self.end_time = CurTime() + 10
...
-- In your Think stuff:
bar:SetValue( math.min(CurTime() / self.end_time, 1) * 1000)
Manmax75
Poster

Posts: 254


Programming Guy


« Reply #2 on: September 11, 2010, 10:23:58 AM »

Thanks, also is their anyway to start at 0 % because as time goes on it starts higher and higher and just increments slower, so its all synced. But I was just wondering if I could always get it to start at 0%

Ride Forward and Thrust Your Pelvis In The Dark Void. The One Induced By Pleasure Yet Cast By The Bigger Picture.
Manmax75
Poster

Posts: 254


Programming Guy


« Reply #3 on: September 18, 2010, 09:12:53 AM »

Is this possible? I think I have to divide it by 100, but i am not sure :S

Ride Forward and Thrust Your Pelvis In The Dark Void. The One Induced By Pleasure Yet Cast By The Bigger Picture.
Pages: [1]
Zombie Master  |  Other  |  Trouble in Terrorist Town  |  Topic: Smooth Increment « previous next »
Jump to:  


Login with username, password and session length

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines
Page created in 0.01 seconds with 17 queries.