Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -962,6 +962,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