• Expodential Functions and math.Clamp
    4 replies, posted
I'm new to Lua coding in Garry's Mod and I am currently trying to create a Speed Bar for my BHOP HUD which uses Exponential Fucntions as I don't want it to reach the end of the bar as speed on BHOP is unlimited. How would I apply this method to achieve this?
-snoop-
I think you mean exponential functions. [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index0814.html[/url]
[QUOTE=HumbleTH;45836293]I think you mean exponential functions. [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index0814.html[/url][/QUOTE] Thank you for the link, I've already visited this page but I'm still unsure on how to do it. Please before I say this, I am not requesting you to code for me just to get me started. Can someone kindly provide me with an example of how to achieve this, in my case setting the width. Here is the code I'm using for my HUD: [code]function DrawHUD() local ply = LocalPlayer() local velocity = math.Round(ply:GetVelocity():Length2D()) // TIMER draw.RoundedBox(4, 9, ScrH()- 101, 262, 92, Color(255,255,255)) draw.RoundedBox(4, 10, ScrH()- 100, 260, 90, Color(150,150,150)) draw.RoundedBox(4, 10, ScrH()- 100, 260, 30, Color(130,130,130)) draw.SimpleText("NORMAL TIMER", "TimerStyle", 140, ScrH() - 85, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) draw.SimpleText("Current Time: ", "TimesFont", 20, ScrH() - 65, Color(255,255,255)) draw.SimpleText("Personal Best: ", "TimesFont", 20, ScrH() - 40, Color(255,255,255)) draw.SimpleText("00:00:00.00", "TimesFont", 150, ScrH() - 65, Color(255,255,255), TEXT_ALIGN_LEFT) draw.SimpleText("00:00:00.00", "TimesFont", 150, ScrH() - 40, Color(255,255,255), TEXT_ALIGN_LEFT) //SPEED draw.RoundedBox(4, 284, ScrH()- 101, 262, 92, Color(255,255,255)) draw.RoundedBox(4, 285, ScrH()- 100, 260, 90, Color(150,150,150)) draw.RoundedBox(4, 285, ScrH()- 100, 260, 30, Color(130,130,130)) draw.SimpleText("SPEED", "TimerStyle", 417, ScrH() - 85, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) draw.RoundedBox(4, 294, ScrH()- 61, 242, 42, Color(0,0,0, 150)) draw.RoundedBox(4, 295, ScrH()- 60, 240, 40, Color(130,130,130)) draw.RoundedBox(0, 295, ScrH()- 60, math.Clamp(velocity, 0, 240), 40, Color(100,100,100)) draw.SimpleText(velocity, "SpeedFont", 417, ScrH() - 40, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) end[/code]
[video=youtube;VTAglJa0Aoc]https://www.youtube.com/watch?v=VTAglJa0Aoc&list=UUDmorMjJmiml0SD_ziHdjVA[/video]
Sorry, you need to Log In to post a reply to this thread.