Someone give me a rundown on effects

I can’t find a tutorial anywhere or a well-documented example on how to make effects, can someone go over the important hooks and functions? Links to tutorials and examples?

Effects are Garry’s Mod’s way of organizing different 3d effects for times where multiple occurrences of the same 3d effects are needed, but require different magnitudes, positions, and affect different entities. To make an effect, you must first create an EffectData table which allows you to set information about the upcoming effect like position, scale, etc. After you have created the EffectData table, the EffectData table is passed to the scripted effect, which reads data from the table and creates the effect depending on what was given. The most common use for scripted effects is for creating engine particles using Lua, because they usually require a position in which to start, and require the caller to give arguments such as scale for larger or smaller particle emitters. When the caller of an effect has passed a valid EffectData() table to util.Effect, util.Effect begins by calling the Effect:Init(data) of the requested effect name, passing the EffectData table as “data”. There the creator of the scripted effect may read values from the EffectData table using their “Get” functions instead of “Set” functions. Such functions look like CEffectData.GetScale v.s. CEffectData.SetScale. From there, particle effects may be created, which do not require further rendering from the effect, or another 3d effect could be rendered, from which the Effect:Render() function is called in order to render said effect.

A good example of a scripted effect that emits particles is the “Remover” tool’s effect, as seen here: http://luabin.foszor.com/code/gamemodes/sandbox/entities/effects/entity_remove/init.lua

A good example of a scripted effect that renders its own effect is the laser tracer when you use the toolgun, as seen here: http://luabin.foszor.com/code/gamemodes/sandbox/entities/effects/LaserTracer/init.lua

You can learn more about what to pass for the EffectData table here: http://wiki.garrysmod.com/?title=CEffectData

Good luck :keke:

That helps a ton, thanks