GMod - What are you working on? November 2017 (#75)

Highlights from the previous thread

1 Like

Those are some great quality highlights! Can’t wait to see what else gets shown off this month ^.^,

1 Like

I’m still tweaking the MOTD I’m making.
I think the colors are good now. It also highlights the tab you choose now. I should mention that I know next to nothing about glua so this is all a learning experience for me.

1 Like

Messing with FFT or something (maybe loud):

1 Like

How do you get those sound waves? Are they completely random?

1 Like


1 Like

Turns out you need to call the Tick hook for gm_bromsock to work.

1 Like

Currently working on a complete implementation of the Color class.

  • The constructor now takes hex strings ("#RGB", “#RGBA”, “#RRGGBB”, and “#RRGGBBAA”) as well as tables (i.e. {r = 1-255, g = 1-255, b = 1-255})
  • You can also use Color.FromHSL() and Color.FromHSV()
  • New functions so far:

- Color:GetHue()
- Color:GetSaturation()
- Color:GetLightness()
- Color:GetValue()
- Color:GetHSL()
- Color:GetHSV()
- Color:GetHSLV()
- Color:SetHue()
- Color:SetSaturation()
- Color:SetLightness()
- Color:SetValue()
- Color:SetHSL()
- Color:SetHSV()

Planned functions:

Color:Blend(color, frac)

1 Like

Reminds me of the old pull request I did for HSL support back in 2016. Never heard from the devs tho.

HSV is the superior color format over HSL, however HSL is outright easier/better when you need a human to set and/or understand a color value (e.g. HUD’s).
Nothing beats LAB tho

1 Like

Surely invert wouldn’t take very long to implement?

function Invert(color)
    return Color( 255 - color.r, 255 - color.g, 255 - color.b, color.a )

I guess it might take longer if you have a separate color system for each type, e.g. hex colors might be harder, but you could just convert everything to RGB

1 Like

You might find some of my old functions useful (I’ve cut the functions you already made):

-- Get Luma amount
	function ColorToLuminance(_color)
		return 0.2126 * _color.r + 0.7152 * _color.g + 0.0722 * _color.b

	function COLOR:ToLuminance()
		return ColorToLuminance(self)

-- Color manipulation
	function COLOR:Lighten(num)
		local h,s,l = ColorToHSL(self)
		return HSLToColor(h,s,l + num)

	function COLOR:Darken(num)
		return self.lighten(-num)

	function COLOR:Invert()
		return Color(255 - self.r,255 - self.g,255 - self.b)

	function COLOR:ToGrayscale()
		local H,S,L = self:ToHSL()
		return HSLToColor(H,0,L)

-- Color functions
	function COLOR:IsBright()
		return ColorToLuminance(self) >= 127.5

	function COLOR:IsDark()
		return not self:IsBright()

Luma is useful to determent what text-color should be used.

1 Like

Should it be ‘return not self:IsBright()’ or did you leave something out?

1 Like

Ups … kinda renamed it without noting it. Fixed it now.

1 Like

I’ve lost count of how many times I’ve made Source shit itself while trying to get this to work, but I finally did it.

Since stencil code examples are very hard to find here’s my code:

It’s not finished though, I have to recalculate the lighting and figure out a way to make the muzzleflash show up in front of the stencils. Anyone who knows these dark secrets please share :pyramid:

1 Like

If you use

render.ClearBuffersObeyStencil instead of cam.IgnoreZ I think the muzzle should work.

1 Like

THANK YOU FOR INCLUDING THE CODE! I don’t know how to use stencils so I can’t help with the muzzleflash but I’ll give you what I know! Make sure the ENT:Initialize function is server side only by putting this inside of it before anything else:
if CLIENT then return end
It will make the physgun follow the thing when you move it around, I know it’s not much but it’s just a little thing to make it look nicer :slight_smile:

1 Like

Worked like a charm! Thank you!

To be honest I half assed that entity, and it wasn’t really meant to be moveable to begin with as I wanted it to be placed in walls, but thank you anyway ^^

1 Like

Jesus Christ

So here are the functions that are for sure available:

function Color:new() -- can be called by just Color, and with '#RGB', '#RGBA', '#RRGGBB', '#RRGGBBA', a table with the keys 'r', 'g', 'b', and 'a', and your normal 3-4 argument method
function Color:__tostring() -- prints to one line
function Color.__add(leftHand, rightHand) -- adds colors together
function Color.__sub(leftHand, rightHand) -- subtracts colors together
function Color.__mul(leftHand, rightHand) -- multiply by number, table, or color
function Color:GetIntermediateValues() -- used to cache things shared by a lot of the computation ('get') functions - pass the results to the other functions
function Color.GetHue(arg)
function Color.GetSaturation(arg)
function Color.GetLightness(arg)
function Color.GetLuminance(arg)
function Color.GetHSL(arg)
function Color.GetHSV(arg)
function Color.FromHSL(hue, saturation, lightness, alpha) -- creates a new color
function Color.FromHSV(hue, saturation, value) -- creates a new color
function Color:SetHue(newHue) -- Sets the hue to a specific number
function Color:SetSaturation(newSaturation, fallbackHue) -- Sets the saturation to a specific number. fallbackHue is when you set it so low that it no longer has a hue
function Color:SetValue(newValue, fallbackHue) -- same for value
function Color:SetLightness(newLightness, fallbackHue) -- same for lightness
function Color:RotateHue(addHue) - this adds to the hue itself
function Color:Invert() -- this inverts all channels exactly
function Color:Blend(target, frac) -- basically lerp for colors

Also did an override on type() to simulate custom types

1 Like

Why is the reference value 43? If you set it to 1 you could probably be able to set the write and test masks to 1 as well.
Also, it’s faster to cache materials, such as Material( “models/misc/dirtfloor001a” ) in your case, outside a render loop.

Also, there’s some really good reference code I used for a stencil thing here.
Just replace these lines with whatever you use to draw the mask, and these lines with whatever you use to draw something in the mask.

1 Like

As beta cuck always looking to receive society’s approval because I think so little of myself (joke), I’m proud of the improvement I had made in my gamemode’s UI. Some of the people who are a part of this thread’s discussion have also commented on the original thread but I’m here just to showboat a little.

Old menu system:

New System:

The old iteration of menu was the third one I had ever created, and the new one is officially my 4th ever. As someone who was always

I’m quite happy with myself.

1 Like