Pivity

How would I make this.

Last read Never
#1

I'm quite new to lua and want to try and make this within gmod.

https://gyazo.com/a2cd50ea9df01fbb0160aa720f58446d

I'm trying to make a small bar that will pop up with red on either side gradually turning into green as it gets to the centre. A vertical bar will be moving side to side within the bar. The user will be able to press a key and the bar will stop and return a value and then start again (looping). I'm trying to make it so if the user stops it when its in the red it will be a lower value than if they stopped it in the green. I'm also trying to think about how I can get it to be a low values in the red, and best values in the green with a gradual increase in the yellow.

Example: https://gyazo.com/a97f70b7891ef0fe91c18b207d07ff8a

I have no clue how to start this. I've seen tutorials on lua for the basics and this will be my first project. Can someone send me in the right direction.


Btw apologise for the awful explanation. I have no clue what the bar is called so I tried to explain it to my best ability.

#3

For the actual coloured bar I would use an image/texture and slap it on a textured rect.

Alternatively, you can also use the DHTML panel and put an image address in the OpenURL.

eg:

local html = vgui.Create( "DHTML" )
html:OpenURL( IMAGE ADDRESS HERE )

(This method also saves having to put the image/texture into a content pack)

Confused x 1Winner x 1
#4

No need, you can draw it with the VGUI gradient materials built into Gmod, I'm pretty sure they are "vgui/gradient-r" and "vgui/gradient-l" but I can't remember off the top of my head. For the bar's position sliding around, you can alter its position based on CurTime() with the modulo operator to make it cycle back and forth. As for changing the bar's color as it gets closer, use Lerp with color values to interpolate the colors based on how close the bar is to the center.

Users viewing this thread
Nobody