Limiting the range of a light source in python via properties

I have a point light source that I want to limit its distance via python. But when I set the values to 0 in the interface, set a property like distance to just 3, the whole lights range is seemingly global. How to limit the range of a light source in python via a game property?

I know there are distance and factor attributes, but they either make it worse or just result in the same thing if set to zero via game properties. I want to achieve the old 2.79 range, which was where you would set it via checking the Sphere box and play around with the range, and simulate that via Python. Im having trouble with this, as I am trying to make a flower that emits a shroud of darkness, but restrict the inverted light to affect only the radius around the flower.

Not sure if this solves your problem or if I understand the problem correctly, but you could use negative power and the distance value. I tested it unsing drivers so this may be an option too (if you want to have a adjustable box for this - sorry if I did not get you right).

1 Like

That sounds odd… could you share a blend or a few screenshots?

Basically the Radius option is the old fashion Sphere option, but with an additional tweakable input value.

You can strictly “drive” them as you’re already doing so, but add Python limits to them.
e.g.

if bpy.data.lights[self.owner.scene.lights[0]].shadow_soft_size > 3:
  bpy.data.lights[self.owner.scene.lights[0]].shadow_soft_size = 3

You could also use some math functions to literal restrict your game property’s value.