Definition
double GetWaterTransparency(string waterName)
Description
This function returns the transparency of water object waterName.
Parameters
waterName
Specifies the water name. You can also use the name “this” for this parameter. In this case, “this” string refers to the name of the water to which this script is attached.
Return Value
Transparency of water object.
Example 1
transparency = 0.0 function Init() transparency = GetWaterTransparency("water1") message = string.format("\nWater transparency is > %.2f", transparency) PrintConsole(message) end function Update() end
First, we get the transparency of water “water1”. Then we display the water transparency in the console using the PrintConsole function.
Example 2
--Name of script is GetWaterTransparency2.lua transparency = 0.0 function Init() transparency = GetWaterTransparency("this") message = string.format("\nWater transparency is > %.2f", transparency) PrintConsole(message) end function Update() end
Assume that the above script named GetWaterTransparency2.lua is attached to a water object named “water1”. In this case, string “this” in the GetWaterTransparency function will be equal to “water1”. In our example, the function GetWaterTransparency returns the transparency of current water, which is “water1”.
GetWaterTransparency