How change omniligths energy programmatically from gdscript file?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gerardo Gonzalez
:warning: Old Version Published before Godot 3 was released.
:bust_in_silhouette: Reply From: GlaDOSik

Read the docs: The light is attenuated through the distance and this attenuation can be configured by changing the energy, radius and attenuation parameters of Light.

So you need to call function from Light class set_parameter( int variable, float value ). Variable is constant PARAM_ENERGY = 3. Value is the value of energy.

Thanks a lot. My code after read documentation was and your comments:

var main_lamp = get_node("/root/main/OmniLight")

var energy = main_lamp.get_parameter(3)
energy += 0.5

main_lamp.set_parameter(3, energy)

Gerardo Gonzalez | 2016-06-29 15:31

That looks fine. You can even write main_lamp.set_parameter(main_lamp.PARAM_ENERGY, energy).

GlaDOSik | 2016-06-29 20:16