Definition
double,double,double GetWaterUnderwaterColor(string waterName)
Description
This function returns the underwater color of water waterName as three values of red, green and blue. Each value ranges from 0 to 1.
Parameters
waterName
Specifies the name of the water object. You can also use the name “this” for this parameter. In this case, “this” refers to the water object name to which this script is attached.
Return Value
Returns the underwater color of water waterName 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 = GetWaterUnderwaterColor("water1") message = string.format("\nUnderwater color of water is > (%.2f, %.2f, %.2f)" , red, green, blue) PrintConsole(message) end function Update() end
In this example, the GetWaterUnderwaterColor function returns the value of the red, green, and blue components of the underwater color of water “water1”. Then these three values are displayed on the console by the PrintConsole function.
Example 2
--Name of script is GetWaterUnderwaterColor2.lua red = 0.0 green = 0.0 blue = 0.0 function Init() red, green, blue = GetWaterUnderwaterColor("this") message = string.format("\nUnderwater color of water is > (%.2f, %.2f, %.2f)" , red, green, blue) PrintConsole(message) end function Update() end
Assume that the above script named GetWaterUnderwaterColor2.lua is attached to a water object named “water1”. In this case, string “this” in the GetWaterUnderwaterColor function will be equal to “water1”. In our example, the function GetWaterUnderwaterColor returns three values of red, green and blue underwater color of the water “water1”.
GetWaterUnderwaterColor