GetWaterLightPosition

Definition

double,double,double GetWaterLightPosition(string waterName)

Description

This function receives the name of the water waterName and returns its light (sun) position as three values x, y and z.

Parameters

waterName
Specifies the name of the water. You can also use the name “this” for this parameter. In this case, “this” refers to the water that this script is attached to.

Return Value

This function returns the position of water light as three values x, y and z.

Example 1

posX = 0.0
posY = 0.0
posZ = 0.0

function Init()
    posX, posY, posZ = GetWaterLightPosition("water1")

    message = string.format("\nWater light position is > (%.2f, %.2f, %.2f)" , posX, posY, posZ)
    PrintConsole(message)
end

function Update()

end
First, GetWaterLightPosition function returns the light position of water “water1”. Then we display the water’s light position values in the console using the PrintConsole function.

Example 2

--Name of script is GetWaterLightPosition2.lua

posX = 0.0
posY = 0.0
posZ = 0.0

function Init()
    posX, posY, posZ = GetWaterLightPosition("this")

    message = string.format("\nWater light position is > (%.2f, %.2f, %.2f)" , posX, posY, posZ)
    PrintConsole(message)
end

function Update()

end
Assume that the above script named GetWaterLightPosition2.lua is attached to a water object named “water1”. In this case, string “this”  in the GetWaterLightPosition function will be equal to “water1”. In our example, the function GetWaterLightPosition returns the light position of current water, which is “water1”.
adminGetWaterLightPosition