Definition
bool IsWaterVisible(string waterName)
Description
This function determines whether the water waterName is visible or not.
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
If water waterName is visible, it returns true, otherwise it returns false.
Example 1
water_visible = false message = "" function Init() water_visible = IsWaterVisible("water1") if water_visible then message = string.format("\nWater is visible") else message = string.format("\nWater is invisible") end PrintConsole(message) end function Update() end
First, we determines whether the water “water1” is visible or not. Then we display its result in the console using the PrintConsole function.
Example 2
--Name of script is IsWaterVisible2.lua water_visible = false message = "" function Init() water_visible = IsWaterVisible("this") if water_visible then message = string.format("\nWater is visible") else message = string.format("\nWater is invisible") end PrintConsole(message) end function Update() end
Assume that the above script named IsWaterVisible2.lua is attached to a water object named “water1”. In this case, string “this” in the IsWaterVisible function will be equal to “water1”. In our example, the function IsWaterVisible determines whether the current water, which is water “water1”, is visible or not. then we display its result in the console using the PrintConsole function.
IsWaterVisible