Skip to content

Commit

Permalink
Merge pull request #1979 from TwistedTail/master
Browse files Browse the repository at this point in the history
Added e:getPlayerColor() and e:getWeaponColor()
  • Loading branch information
thegrb93 authored Sep 24, 2019
2 parents cfdadd9 + ceb5860 commit 28971c7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lua/entities/gmod_wire_expression2/core/color.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

local Clamp = math.Clamp
local floor = math.floor
local Round = math.Round

local function RGBClamp(r,g,b)
return Clamp(r,0,255),Clamp(g,0,255),Clamp(b,0,255)
Expand Down Expand Up @@ -84,6 +85,24 @@ e2function void entity:setRenderMode(mode)
duplicator.StoreEntityModifier(this, "colour", { RenderMode = mode })
end

e2function vector entity:getPlayerColor()
if not IsValid(this) then return {0, 0, 0} end
if not this:IsPlayer() then return {0, 0, 0} end

local c = this:GetPlayerColor()

return { RGBClamp(Round(c.r * 255), Round(c.g * 255), Round(c.b * 255)) }
end

e2function vector entity:getWeaponColor()
if not IsValid(this) then return {0, 0, 0} end
if not this:IsPlayer() then return {0, 0, 0} end

local c = this:GetWeaponColor()

return { RGBClamp(Round(c.r * 255), Round(c.g * 255), Round(c.b * 255)) }
end

--- HSV

--- Converts <hsv> from the [http://en.wikipedia.org/wiki/HSV_color_space HSV color space] to the [http://en.wikipedia.org/wiki/RGB_color_space RGB color space]
Expand Down
2 changes: 2 additions & 0 deletions lua/wire/client/e2descriptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,8 @@ E2Helper.Descriptions["setSkin(e:n)"] = "Sets the skin of an entity"
E2Helper.Descriptions["getSkin(e:)"] = "Gets Es current skin number"
E2Helper.Descriptions["getSkinCount(e:)"] = "Gets Es number of skins"
E2Helper.Descriptions["setRenderMode(e:n)"] = "Sets the render mode of the entity (0 = Normal, 1 = TransColor, 2 = TransTexture, 3 = Glow, 4 = TransAlpha, 5 = TransAdd, 6 = Enviromental, 7 = TransAddFrameBlend, 8 = TransAlphaAdd, 9 = WorldGlow, 10 = None)"
E2Helper.Descriptions["getPlayerColor(e:)"] = "Returns the player's model color as a vector (R,G,B)"
E2Helper.Descriptions["getWeaponColor(e:)"] = "Returns the player's weapon color as a vector (R,G,B)"
E2Helper.Descriptions["hsl2rgb(v)"] = "Converts V from the HSL color space to the RGB color space"
E2Helper.Descriptions["hsl2rgb(nnn)"] = "Converts N,N,N from the HSL color space to the RGB color space"
E2Helper.Descriptions["hsv2rgb(v)"] = "Converts V from the HSV color space to the RGB color space"
Expand Down

0 comments on commit 28971c7

Please sign in to comment.