Hello,
I saw this video and i was wondering... How did they do the roundedbox part?
When the health takes down it's not a rounding but just a straight line. Is this a roundedbox or something else?
And as soon as the health takes down the color changed from black to white? How did they do that?
Here is the video:
[URL="http://www.youtube.com/watch?v=Nub43EF2spc&t=1m5s"]http://www.youtube.com/watch?v=Nub43EF2spc&t=1m5s[/URL]
Kind regards,
Most posted man in the forum.
It's not [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/draw/RoundedBox]draw.RoundedBox[/url] specifically, but [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/draw/RoundedBoxEx]draw.RoundedBoxEx[/url]. That one allows some corners to be straight and some to be rounded.
[QUOTE=MPan1;52643209]It's not [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/draw/RoundedBox]draw.RoundedBox[/url] specifically, but [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/draw/RoundedBoxEx]draw.RoundedBoxEx[/url]. That one allows some corners to be straight and some to be rounded.[/QUOTE]
Did i do something wrong?
[code] draw.RoundedBoxEx( 30, 770, ScrH() - 110, 380, 60, Color( 255, 255, 255, 160, boolean roundBottomRight=false ) [/code]
[code]
[ERROR] lua/autorun/client/rebornhud_loader.lua:65: ')' expected near 'roundBottomRight'
1. unknown - lua/autorun/client/rebornhud_loader.lua:0
[/code]
If it errors then obviously you did something wrong??
Color does not take a fifth argument, you forgot a parenthesis, i have no idea what you're trying to accomplish by doing "boolean roundBottomRight=false", it literally just takes a [url="https://en.wikipedia.org/wiki/Boolean"]boolean[/url]. Please read this again [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/draw/RoundedBoxEx]draw.RoundedBoxEx[/url]
[QUOTE=Invule;52643294]If it errors then obviously you did something wrong??
Color does not take a fifth argument, you forgot a parenthesis, i have no idea what you're trying to accomplish by doing "boolean roundBottomRight=false", it literally just takes a [url="https://en.wikipedia.org/wiki/Boolean"]boolean[/url]. Please read this again [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/draw/RoundedBoxEx]draw.RoundedBoxEx[/url][/QUOTE]
How then?
[code] draw.RoundedBoxEx( 30, 770, ScrH(()- 110, 380, 60, Color(255, 255, 255), boolean roundTopLeft=true, boolean roundTopRight=true, boolean roundBottomLeft=true, boolean roundBottomRight=true ) [/code]
Remove the boolean roundTopLeft= and etc, and just put bools there (aka either true or false)
[QUOTE=geferon;52643359]Remove the boolean roundTopLeft= and etc, and just put bools there (aka either true or false)[/QUOTE]
[code] draw.RoundedBoxEx( 30, 770, ScrH() - 110, 380, 60, Color(255, 255, 255), roundTopLeft=true, roundTopRight=true, roundBottomLeft=true, roundBottomRight=true) [/code]
Now i get this error:
[code]
[ERROR] lua/autorun/client/rebornhud_loader.lua:65: ')' expected near '='
1. unknown - lua/autorun/client/rebornhud_loader.lua:0
[/code]
Solved it!
[editline]3rd September 2017[/editline]
[QUOTE=MPan1;52643209]It's not [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/draw/RoundedBox]draw.RoundedBox[/url] specifically, but [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/draw/RoundedBoxEx]draw.RoundedBoxEx[/url]. That one allows some corners to be straight and some to be rounded.[/QUOTE]
Hey, i got it but as shown in the video in the beginning the RoundedBoxEx is rounded and when its gaining damage it's getting straight? How did they do that?
[QUOTE=Scepto;52643369][code] draw.RoundedBoxEx( 30, 770, ScrH() - 110, 380, 60, Color(255, 255, 255), roundTopLeft=true, roundTopRight=true, roundBottomLeft=true, roundBottomRight=true) [/code]
Now i get this error:
[code]
[ERROR] lua/autorun/client/rebornhud_loader.lua:65: ')' expected near '='
1. unknown - lua/autorun/client/rebornhud_loader.lua:0
[/code]
Solved it!
[editline]3rd September 2017[/editline]
Hey, i got it but as shown in the video in the beginning the RoundedBoxEx is rounded and when its gaining damage it's getting straight? How did they do that?[/QUOTE]
How round a box this function produces is determined by its first argument, an integer in pixels. Instead of using a constant value, but instead used a value representative of say how much damage is gained, then you can animate the roundedness if you will of the box.
[QUOTE=James xX;52643647]How round a box this function produces is determined by its first argument, an integer in pixels. Instead of using a constant value, but instead used a value representative of say how much damage is gained, then you can animate the roundedness if you will of the box.[/QUOTE]
Wow, what? So what should i do then? Don't really understand you.
[QUOTE=James xX;52643647]How round a box this function produces is determined by its first argument, an integer in pixels. Instead of using a constant value, but instead used a value representative of say how much damage is gained, then you can animate the roundedness if you will of the box.[/QUOTE]
He's talking about partially-filled circles:
[img]https://i.imgur.com/E651q2i.png[/img]
You could use materials if you don't want to scale by resolution, but it looks like the original HUD used stencils anyway:
[img]https://i.imgur.com/knrwHTe.png[/img]
[QUOTE=Luni;52643697]He's talking about partially-filled circles:
[img]https://i.imgur.com/E651q2i.png[/img]
You could use materials if you don't want to scale by resolution, but it looks like the original HUD used stencils anyway:
[img]https://i.imgur.com/knrwHTe.png[/img][/QUOTE]
Could you give me a example? Im still learning at this part of huds.
Thank you!
[QUOTE=Scepto;52644104]Could you give me a example? Im still learning at this part of huds.
Thank you![/QUOTE]
Someone??
[QUOTE=Scepto;52647334]Someone??[/QUOTE]
Stencils are going to be way too advanced for you. Anything we say would just go over your head.
[QUOTE=txike;52647361]Stencils are going to be way too advanced for you. Anything we say would just go over your head.[/QUOTE]
Well sh*t... i need it so bad :disgust:
[QUOTE=Scepto;52647467]Well sh*t... i need it so bad :disgust:[/QUOTE]
Hmm. I forgot [url=http://wiki.garrysmod.com/page/render/SetScissorRect]render.SetScissorRect()[/url] was a thing.
[img]https://i.imgur.com/qYWUlBE.png[/img]
[lua]
hook.Add("HUDPaint", "HealthBar", function()
local hp = LocalPlayer():Health()
local width = hp/100*380
render.SetScissorRect(50, 50, 50 + width, 50 + 32, true)
draw.RoundedBox(16, 50, 50, 380, 32, Color(255, 255, 255))
draw.SimpleText(hp, "CloseCaption_Bold", 50 + 380 - 20, 50 + 32/2, Color(0, 0, 0), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
render.SetScissorRect(50 + width, 50, 50 + 380, 50 + 32, true)
draw.RoundedBox(16, 50, 50, 380, 32, Color(0, 0, 0, 150))
draw.SimpleText(hp, "CloseCaption_Bold", 50 + 380 - 20, 50 + 32/2, Color(255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
render.SetScissorRect(0, 0, 0, 0, false)
end)
[/lua]
You'll probably need to make your own quarter- or half-circle textures, though, since the ones used by draw.RoundedBox() are only 16x16 and look awful at 32x32. Shouldn't take long to throw some transparent PNGs together in GIMP or Paint.net.
[QUOTE=Luni;52648266]Hmm. I forgot [url=http://wiki.garrysmod.com/page/render/SetScissorRect]render.SetScissorRect()[/url] was a thing.
[img]https://i.imgur.com/qYWUlBE.png[/img]
[lua]
hook.Add("HUDPaint", "HealthBar", function()
local hp = LocalPlayer():Health()
local width = hp/100*380
render.SetScissorRect(50, 50, 50 + width, 50 + 32, true)
draw.RoundedBox(16, 50, 50, 380, 32, Color(255, 255, 255))
draw.SimpleText(hp, "CloseCaption_Bold", 50 + 380 - 20, 50 + 32/2, Color(0, 0, 0), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
render.SetScissorRect(50 + width, 50, 50 + 380, 50 + 32, true)
draw.RoundedBox(16, 50, 50, 380, 32, Color(0, 0, 0, 150))
draw.SimpleText(hp, "CloseCaption_Bold", 50 + 380 - 20, 50 + 32/2, Color(255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
render.SetScissorRect(0, 0, 0, 0, false)
end)
[/lua]
You'll probably need to make your own quarter- or half-circle textures, though, since the ones used by draw.RoundedBox() are only 16x16 and look awful at 32x32. Shouldn't take long to throw some transparent PNGs together in GIMP or Paint.net.[/QUOTE]
Yes, perfect! One more thing tho. Im new to these render stuff... How would i put this in the middel bottom? Tryed it but didn't work.
The x and y of your health bar need to be based on the screen size. In this case,
[Lua]
x = ScrW()/2 - width/2
y = ScrH() - 32 - 10 --10 is the gap from the bottom, 32 is the height of the bar.
[/Lua]
[QUOTE=bobbleheadbob;52650356]The x and y of your health bar need to be based on the screen size. In this case,
[Lua]
x = ScrW()/2 - width/2
y = ScrH() - 32 - 10 --10 is the gap from the bottom, 32 is the height of the bar.
[/Lua][/QUOTE]
Thank you!
[QUOTE=bobbleheadbob;52650356]The x and y of your health bar need to be based on the screen size. In this case,
[Lua]
x = ScrW()/2 - width/2
y = ScrH() - 32 - 10 --10 is the gap from the bottom, 32 is the height of the bar.
[/Lua][/QUOTE]
Where should i place that in the code? Im still frustrated. Can't get it to work....
Help me please!
[code] local hp = LocalPlayer():Health()
local width = hp/100*380
render.SetScissorRect(50, 50, 50 + width, 50 + 32, true)
draw.RoundedBox(16, 50, 50, 380, 32, Color(255, 255, 255))
draw.SimpleText(hp, "Health", 50 + 380 - 20, 50 + 32/2, Color(0, 0, 0), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
render.SetScissorRect(50 + width, 50, 50 + 380, 50 + 32, true)
draw.RoundedBox(16, 50, 50, 380, 32, Color(0, 0, 0, 150))
draw.SimpleText(hp, "Health", 50 + 380 - 20, 50 + 32/2, Color(255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
render.SetScissorRect(0, 0, 0, 0, false) [/code]
You'd put it in the coordinate arguments.
[QUOTE=txike;52653649]You'd put it in the coordinate arguments.[/QUOTE]
Yes, i get that... But where exactly.. Can you maybe point them? But thank you for the reply!
[QUOTE=Scepto;52653674]Yes, i get that... But where exactly.. Can you maybe point them? But thank you for the reply![/QUOTE]
The coordinate arguments for [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/draw/RoundedBox]draw.RoundedBox[/url] are the second and third arguments and for [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/render/SetScissorRect]render.SetScissorRect[/url] they're the first four.
[QUOTE=txike;52653687]The coordinate arguments for [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/draw/RoundedBox]draw.RoundedBox[/url] are the second and third arguments and for [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/render/SetScissorRect]render.SetScissorRect[/url] they're the first four.[/QUOTE]
I did it for the roundedboxes but they just dissapear. And for the SetScissorRect is just giving errors:
[code] local hp = LocalPlayer():Health()
local width = hp/100*380
render.SetScissorRect(ScrW()/2 - width/2, ScrH() - 32 - 10 + 32, true)
draw.RoundedBox(16, ScrW()/2 - width/2, ScrH() - 32 - 10, 380, 32, Color(255, 255, 255))
draw.SimpleText(hp, "Health", 50 + 380 - 20, 50 + 32/2, Color(0, 0, 0), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
render.SetScissorRect(ScrW()/2 - width/2, ScrH() - 32 - 10 + 380, 50 + 32, true)
draw.RoundedBox(16, ScrW()/2 - width/2, ScrH() - 32 - 10, 380, 32, Color(0, 0, 0, 150))
draw.SimpleText(hp, "Health", 50 + 380 - 20, 50 + 32/2, Color(255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
render.SetScissorRect(0, 0, 0, 0, false)
end)
[/code]
Im not a high-tech devolper. Im just making jobs, but a guy doesn't know how to fix it so im trying to help him.
[QUOTE=Scepto;52653721]Im not a high-tech devolper. Im just making jobs, but a guy doesn't know how to fix it so im trying to help him.[/QUOTE]
If you're just going to post their questions here then link them to the Developer Discussion so they can ask themself.
[editline]6th September 2017[/editline]
This is the last time I'm spoonfeeding you code.
[code]hook.Add("HUDPaint", "Meme", function()
local width, height = 380, 32
local client = LocalPlayer()
local health = client:Health()
local maxHealth = client:GetMaxHealth()
local x, y = ScrW() * .5 - width * .5, ScrH() - height - 10
draw.RoundedBox(height * .5, x, y, width, height, color_black) -- you shouldn't call Color if it's going to be constant
draw.SimpleText(health, "DermaDefault", x + width - 20, y + height * .5, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
render.SetScissorRect(x, y, x + (health / maxHealth * width), y + height, true) -- This was erroring because you were only passing 4 out of the 5 arguments.
draw.RoundedBox(height * .5, x, y, width, height, color_white) -- again, don't call Color every frame if it's constant. Cache it in the main chunk.
draw.SimpleText(health, "DermaDefault", x + width - 20, y + height * .5, color_black, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
render.SetScissorRect(0, 0, 0, 0, false)
end)
[/code]
Learn from your mistakes and fix your own code instead of getting us to spoonfeed you.
Sorry, you need to Log In to post a reply to this thread.