"There's a mask for that"
A greyscale texture map of the distance from the source (along the surface) of the lightning would be handy, but if that's too hard...
Place a camera at the origin point of the lightning and connect a distance shader. Near colour =1 at distance = 0, far colour =0 at maximum distance of the lightning (or slightly further).
Add a colour adjust shader (can't have a mask without one).
Initial values black =1.01, white=1.01 (no lightning)
Final values black -0.01, white -0.01 (complete object)
Use this for the opacity function, and multiply it by a scalar (your luminosity value) for the luminosity function
You could also use this to pulse the luminosity of the lightning.
That will give the appearance of the lightning radiating from the source point, It's not as ideal as masking by length along the object but is very easy to set up..