GetWaterPosition

Definition

double,double,double GetWaterPosition(string waterName)

Description

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

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 name that this script is attached to.

Return Value

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

Example 1

posX = 0.0
posY = 0.0
posZ = 0.0

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

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

function Update()

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

Example 2

--Name of script is GetWaterPosition2.lua

posX = 0.0
posY = 0.0
posZ = 0.0

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

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

function Update()

end
Assume that the above script named GetWaterPosition2.lua is attached to a water object named “water1”. In this case, string “this”  in the GetWaterPosition function will be equal to “water1”. In our example, the function GetWaterPosition returns the position of current water, which is “water1”. Then we display the position values in the console using the PrintConsole function.
adminGetWaterPosition