Skip to content
NotAKidoS edited this page Apr 4, 2021 · 16 revisions
Page on how to use this tool with LUA. Setting and getting proxy colors as well as some other neat functions. Might be too much for such simple stuff...

All functions are available on the CLIENT and SERVER

ProxyColor can be checked to see if the addon is installed.
ent:GetProxyColor() returns the entity's applied proxy colors.
ent:SetProxyColor(ctable) sets the entity's applied proxy colors.

ProxyColor.Random(ent, bool) sets random proxy colors onto the entity.
ProxyColor.RandFromTable(ent, ctable, bool) picks a random entry in a list of proxy colors to apply.


Examples:

Checking if the addon exists

--proxy color check
if ProxyColor then
   print("proxy color is installed!")
end
--If proxy color isnt installed, dont continue
print("did some stuff")
if !ProxyColor then return end
print("this code only runs if proxycolor is true!")

Getting an entity's proxy colors

--print the entity's color table in console
if ProxyColor then
   local CTable = ent:GetProxyColors()
   PrintTable(CTable)
end
--check if the entity has proxy colors
if ProxyColor then
   if ent:GetProxyColors() then
      print("this model has proxy colors")
   end
end

Set an entity's proxy colors

--set the proxy colors from a complete table
if ProxyColor then
   local ColorTable = {
      Color(100,100,100),
      Color(234,213,45),
      Color(23,4,67),
      Color(213,56,85), 
      Color(34,65,75),
      Color(214,124,245),
      Color(0,0,0), 
   }
   ent:SetProxyColor(ColorTable)
end
--set the proxy colors from an incomplete table
if ProxyColor then
   local ColorTable = {
      Color(100,100,100),
      Color(234,213,45),
   }
   ent:SetProxyColor(ColorTable)
end
--set the proxy colors from an incomplete table
if ProxyColor then
   local ColorTable = {
      Color(100,100,100),
      Color(234,213,45),
      nil,
      Color(213,56,85), 
      nil,
      Color(214,124,245),
      nil,
   }
   ent:SetProxyColor(ColorTable)
end
--set the proxy colors from another entity
if ProxyColor then
   local pxyclrs = ent:GetProxyColors()
   ent2:SetProxyColor(pxyclrs)
end

Set an entity's proxy colors randomly

--set the proxy colors from another entity
if ProxyColor then
   --if the second argument is true, the entity will not set new colors if colors already exist
   --this is for if you set the color in a spawn function
   ProxyColor.Random(ent, true)
end

Set an entity's proxy colors from a random table

--set the proxy colors from a random table in a table
if ProxyColor then
   local ColorCols = {
      {Color(100,100,100),Color(100,100,100),Color(100,100,100),Color(100,100,100),Color(100,100,100),Color(100,100,100),Color(100,100,100)},
      {Color(234,213,45),Color(234,213,45),Color(234,213,45),Color(234,213,45),Color(234,213,45),Color(234,213,45),Color(234,213,45)},
      {Color(23,4,67),Color(23,4,67),Color(23,4,67),Color(23,4,67),Color(23,4,67),Color(23,4,67),Color(23,4,67)},
      {Color(213,56,85),Color(213,56,85),Color(213,56,85),Color(213,56,85),Color(213,56,85),Color(213,56,85),Color(213,56,85)},
      {Color(34,65,75),Color(34,65,75),Color(34,65,75),Color(34,65,75),Color(34,65,75),Color(34,65,75),Color(34,65,75)},
      {Color(214,124,245),Color(214,124,245),Color(214,124,245),Color(214,124,245),Color(214,124,245),Color(214,124,245),Color(214,124,245)},
      {Color(0,0,0),Color(0,0,0),Color(0,0,0),Color(0,0,0),Color(0,0,0),Color(0,0,0),Color(0,0,0)},
   }
   ProxyColor.RandFromTable(ent, ColorCols, false) --bool same as above
end
--set the proxy colors from a random table in a table
if ProxyColor then
   local ColorCols = { --table with the color tables to choose
      {Color(100,100,100), Color(100,100,100)}, --color table 1
      {Color(234,213,45), Color(234,213,45)}, --color table 2
      {Color(23,4,67), Color(23,4,67)}, --color table 3
   }
   --picks a random color table from the above table
   ProxyColor.RandFromTable(ent, ColorCols, false)
end

I can imagine this being used on vehicles or entity's that have a random set of colors they spawn with, pulled randomly from a master list.


Always check if ProxyColor exists. Not everyone will have the addon installed. You can use SetColor() as a fallback.

--set the proxy colors if proxy color is installed, otherwise normal colors
if ProxyColor then
   local ColorTable = {
      Color(100,100,100),
      Color(234,213,45),
   }
   ent:SetProxyColor(ColorTable)
else
   ent:SetColor( Color(100,100,100) )
   print("install Proxy Color Tool for proper colors on this entity")
end

It even works in model previews!

showcase of proxy colors working in a clientside only menu