GetLightAmbient

Definition

double,double,double GetLightAmbient(string lightObjectName)

Description

This function returns the ambient color of lightObjectName light as three values of red, green and blue. Each value ranges from 0 to 1.

Parameters

lightObjectName
Specifies the name of the light object. You can also use the name “this” for this parameter. In this case, “this” refers to the light object name to which this script is attached.

Return Value

Returns the ambient color of lightObjectName light as three values of red, green and blue. Each value ranges from 0 to 1.

Example 1

red = 0.0
green = 0.0
blue = 0.0

function Init()
    red, green, blue = GetLightAmbient("light1")

    message = string.format("\nLight ambient color is > (%.2f, %.2f, %.2f)" , red, green, blue)
    PrintConsole(message)
end

function Update()

end
In this example, the GetLightAmbient function returns the value of the red, green, and blue components of the ambient color of light “light1”. Then these three values are displayed on the console by the PrintConsole function.

Example 2

--Script name is GetLightAmbient2.lua

red = 0.0
green = 0.0
blue = 0.0

function Init()
    red, green, blue = GetLightAmbient("this")

    message = string.format("\nLight ambient color is > (%.2f, %.2f, %.2f)" , red, green, blue)
    PrintConsole(message)
end

function Update()

end
Assume that the above script named GetLightAmbient2.lua is attached to the light object named “light1”. In this case, string “this”  in the GetLightAmbient function will be equal to “light1”. In our example, the function GetLightAmbient returns three values of red, green and blue ambient color of the light “light1”.
adminGetLightAmbient