• Entity:SetColor(r,g,b,a) sets objects purple serverside?
    20 replies, posted
Why does Entity:SetColor(r,g,b,a) turn entities purple instead of the set color when this is run on the server?
Try Entity:SetColor( Color( t, g, b, a ) )
Still doesn't work, I just tried it on sandbox as well. Spawned some props, and put in the console: [lua]lua_run for k, v in pairs( ents.GetAll() ) do v:SetColor( Color(255, 255, 255, 10) ) end[/lua] And none of the props alpha went down.
So what is your problem - that they turn purple or that their alpha doesn't change?
[QUOTE=garry;39874636]So what is your problem - that they turn purple or that their alpha doesn't change?[/QUOTE] The alpha doesn't change is my real problem.
You need to change the render mode to change the alpha. Does the colour tool work? Yes? Then maybe look into why the colour tool works but your code doesn't?
[QUOTE=garry;39874654]You need to change the render mode to change the alpha. Does the colour tool work? Yes? Then maybe look into why the colour tool works but your code doesn't?[/QUOTE] Alright thank youu
Does this button work for you guys? [img]http://puu.sh/2fQ1T[/img] [editline]11th March 2013[/editline] Is it visible for you?
Wait so the alpha of custom made entities can only be 0 or 255? Or is there some kind of setting they need? Because if it is set between 0 and 255 it just turns the entity purple and leaves the alpha full. Take the fog editor in sandbox for example, I tried changing the alpha half way with the color tool and it just turned the fog editor purple with full alpha. And yea it's visible.
I had this problem too with the model of npc_turret_floor, if you need to reproduce this bug..
[QUOTE=Nalo;39875023]I had this problem too with the model of npc_turret_floor, if you need to reproduce this bug..[/QUOTE] It's not just a model bug, it's all custom made entities. They can't have an alpha besides 0 or 255 without turning purple. Even the correct render modes won't fix this problem otherwise the color tool should have worked on the fog editor, sun editor, or any of those entities.
Is it in the transparent render group? [editline]11th March 2013[/editline] ENT.RenderGroup = RENDERGROUP_TRANSLUCENT
[QUOTE=garry;39875072]Is it in the transparent render group?[/QUOTE] I was using the Transparent Color render group since that is what the color tool was using. But after it still did not work on my entity I tried every other render group with no success. It would only work on transparent render groups if it was [I]fully[/I] transparent(0). [lua] hook.Add( "PhysgunPickup", "ChangeSolid", function( pl, ent ) if IsValid(ent) then ent:SetRenderMode(RENDERMODE_TRANSCOLOR) ent:SetKeyValue( "renderfx", 0 ) ent:SetColor(Color(255,255,255,55)) end end ) [/lua] [editline]11th March 2013[/editline] [QUOTE=garry;39875072]Is it in the transparent render group? [editline]11th March 2013[/editline] ENT.RenderGroup = RENDERGROUP_TRANSLUCENT[/QUOTE] That just turns my entity completely invisible all the time, then I tried RENDERGROUP_BOTH, set the rendermode to RENDERMODE_TRANSCOLOR, then the color to Color(255,255,255,200) still with no luck. The entity does not turn purple anymore however when the alpha is between 0 and 255, although anything below 255 and it just turns completely invisible.
RENDERMODE_TRANSALPHA
It's weird because the shadow follows what the alpha should really be. Alpha set to 55, weak shadow under invisible model. Alpha set to 200, strong shadow under invisible model. Or, if the render group is set to BOTH or OPAQUE the same situation happens except you can see the model full alpha while the alpha of the shadow only changes. [editline]11th March 2013[/editline] [QUOTE=TweaK2007;39875203]RENDERMODE_TRANSALPHA[/QUOTE] I tried that, along with every other render mode. I feel like no one understands what I am saying... All I know is if you try to change the alpha of a custom made entity, such as the fog editor, it will not work. [editline]11th March 2013[/editline] Not that I care if the fog editors alpha color can be changed... but that's just an example. What I want is to change my entities alpha color to 180 but something outside of the render group/mode and setcolor function is hindering this. The alpha color of the shadow looks proper.. But the model is not following the right rules.
Paste your code
This is all a custom entity. shared.lua [lua] DEFINE_BASECLASS( "base_gmodentity" ) ENT.Base = "base_entity" ENT.Type = "anim" ENT.Spawnable = false ENT.AdminSpawnable = false ENT.RenderGroup = RENDERGROUP_BOTH --Tried TRANSLUCENT hook.Add( "PhysgunPickup", "ChangeSolid", function( pl, ent ) if IsValid(ent) then ent:SetRenderMode(RENDERMODE_TRANSCOLOR) --Tried TRANSALPHA ent:SetKeyValue( "renderfx", 0 ) --Tried with/without this. ent:SetColor(Color(255,255,255,180)) end end ) hook.Add( "PhysgunDrop", "ResetSolid", function( pl, ent ) if IsValid(ent) then ent:SetRenderMode(RENDERMODE_TRANSCOLOR) ent:SetColor(Color(255,255,255,255)) end end ) [/lua] init.lua [lua] AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include('shared.lua') function ENT:Initialize() self:SetModel( "models/props_combine/combine_monitorbay.mdl" ) self:PhysicsInit( SOLID_VPHYSICS ) self:SetMoveType( MOVETYPE_VPHYSICS ) self:SetSolid( SOLID_VPHYSICS ) self:SetUseType(SIMPLE_USE) self:GetPhysicsObject():Sleep() end function ENT:Use( pl, caller ) end function ENT:AcceptInput( name, activator, caller, data ) return false end function ENT:UpdateTransmitState() return TRANSMIT_PVS end [/lua] cl_init.lua [lua] include('shared.lua') function ENT:Draw() self:DrawModel() end [/lua]
Did you try adding ENT.RenderGroup = RENDERGROUP_TRANSLUCENT to your shared.lua
[QUOTE=garry;39875328]Did you try adding ENT.RenderGroup = RENDERGROUP_TRANSLUCENT to your shared.lua[/QUOTE] Yep, that just made the entity completely invisible.
My hunch is that it's DrawModel that's fucking us. I'll do some experiments and see if I can get it fixed in the next update.
[QUOTE=garry;39875367]My hunch is that it's DrawModel that's fucking us. I'll do some experiments and see if I can get it fixed in the next update.[/QUOTE] The only thing I noticed that might help with debugging is the shadow always follows the alpha color like it should but the model refuses to be anything but completely invisible or opaque. Picture example: [lua] //ENT.RenderGroup = RENDERGROUP_TRANSLUCENT hook.Add( "PhysgunPickup", "ChangeSolid", function( pl, ent ) if IsValid(ent) then //ent:SetRenderMode(RENDERMODE_TRANSCOLOR) //ent:SetKeyValue( "renderfx", 0 ) ent:SetColor(Color(255,255,255,200)) end end ) hook.Add( "PhysgunDrop", "ResetSolid", function( pl, ent ) if IsValid(ent) then //ent:SetRenderMode(RENDERMODE_TRANSCOLOR) ent:SetColor(Color(255,255,255,100)) end end ) [/lua] [IMG]https://dl.dropbox.com/u/30778198/wgwergwe.png[/IMG]
Sorry, you need to Log In to post a reply to this thread.