• Color Flicker?
    19 replies, posted
Hello, i'm trying to make a flicker color thing, like flicker on "light" on hammer something like that this doesn't work [CODE] Color(0, 255, 0, math.random( 255, 230 ))[/CODE] How do I get that it work or something like that.
Well, in your example I think [CODE] math.random( 255, 230 ) [/CODE] should be [CODE] math.random( 230, 255 ) [/CODE] instead. You could also try doing some gradual number changes based on the RealFrameTime (but I have no clue how to)
Are you doing this in a function or hook that is called repeatedly, or just once?
[QUOTE=NiandraLades;49219964]Are you doing this in a function or hook that is called repeatedly, or just once?[/QUOTE] only once
[QUOTE=FiBzY;49222038]only once[/QUOTE] If you want the color to change it needs to be attached to a function that is constantly being updated. If it's a swep, set the color through it's think function.
Well, that'll be why then :v: math.random won't be called constantly while it's in that color, unless color itself is being frequently used Something like this would constantly change it: [code] local variable = nil hook.Add("Think", "asd", function() variable = math.random(230,255) end) [/code]
[CODE]local speed = 5 local glow = math.random(speed*CurTime()) * 1 + 128 local Flicker = Color(0,255,0,glow)[/CODE] I coded this I guess this is the best I can get, is there away I can make it higher then (0,0,0,255) like 300 doesn't work how can I make it glow more?
[QUOTE=FiBzY;49224128]is there away I can make it higher then (0,0,0,255) like 300 doesn't work how can I make it glow more?[/QUOTE] You don't.
[QUOTE=Kevlon;49224155]You don't.[/QUOTE] Uh well how can I make it glow?
[QUOTE=FiBzY;49224173]Uh well how can I make it glow?[/QUOTE] For a start, make it white
[QUOTE=Kevlon;49224185]For a start, make it white[/QUOTE] ?
By glow do you mean glow like the light/lamp does when you look at it, or have a lot of bloom when looking at it?
[QUOTE=Z0mb1n3;49224196]By glow do you mean glow like the light/lamp does when you look at it, or have a lot of bloom when looking at it?[/QUOTE] Yea..
There were two questions there... which one is that a yes to?
[QUOTE=Z0mb1n3;49224205]There were two questions there... which one is that a yes to?[/QUOTE] Like glow meaning have some bloom from it
Well this probably isn't the best way, but you can look into using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/halo/Add]halo.Add[/url] to mimic the effect of bloom.
[QUOTE=Z0mb1n3;49224218]Well this probably isn't the best way, but you can look into using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/halo/Add]halo.Add[/url] to mimic the effect of bloom.[/QUOTE] thats kinda what I want but I don't see how I can add that to my code. [editline]2nd December 2015[/editline] I also looked up CreateMaterial() , ["$additive"] = 1 might be what I want
Add a hook in a clientside file and do something like [code] hook.Add("PreDrawHalos", "glowingstuff", function() halo.Add(ents.FindByClass("your_entity's_class_name_here"), YourColorHere) end) [/code]
[CODE]local glow = math.random(190, 255) local Rb = Color(0,glow,0) print(Rb)[/CODE] How do I add a create.timer on to this?
[QUOTE=FiBzY;49224400]How do I add a create.timer on to this?[/QUOTE] You could just use a hook rather than a timer - e.g. [CODE] hook.Add( 'Think', 'DoGlowUpdate', function() local glow = math.random(190, 255) local Rb = Color(0,glow,0) end ) [/CODE] What are you going to use the variable in/for? Is it already in a hook or something? [editline]3rd December 2015[/editline] Also, you could make it get closer to white rather than closer to bright green by doing something like [CODE] local MoreThanZero = math.random( 0, 20 ) local Rb = Color(MoreThanZero,glow,MoreThanZero) [/CODE] That'd make the red and blue channels go above zero, meaning it'd be closer to white, and probably look brighter. The math.random( 0, 20 ) was just an example though, change 20 and 0 to whatever you want, but keep it close to 0 to keep the color looking green-ish.
Sorry, you need to Log In to post a reply to this thread.