Definition
double,double,double GetLightDiffuse(string lightObjectName)
Description
This function returns the diffuse 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 diffuse 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 = GetLightDiffuse("light1") message = string.format("\nLight diffuse color is > (%.2f, %.2f, %.2f)" , red, green, blue) PrintConsole(message) end function Update() end
In this example, the GetLightDiffuse function returns the value of the red, green, and blue components of the diffuse color of light “light1”. Then these three values are displayed on the console by the PrintConsole function.
Example 2
--Script name is GetLightDiffuse2.lua red = 0.0 green = 0.0 blue = 0.0 function Init() red, green, blue = GetLightDiffuse("this") message = string.format("\nLight diffuse color is > (%.2f, %.2f, %.2f)" , red, green, blue) PrintConsole(message) end function Update() end
Assume that the above script named GetLightDiffuse2.lua is attached to the light object named “light1”. In this case, string “this” in the GetLightDiffuse function will be equal to “light1”. In our example, the function GetLightDiffuse returns three values of red, green and blue diffuse color of the light “light1”.
GetLightDiffuse