GetWaterLevel: Difference between revisions
Jump to navigation
Jump to search
Line 20: | Line 20: | ||
===Optional Arguments=== | ===Optional Arguments=== | ||
*'''bCheckWaves''' ask arc_ (Prediction: true if the water is close to the ground(It changes whether the water | *'''bCheckWaves''' ask arc_ (Prediction: true if the water is close to the ground (It changes whether the water is visible or not)) | ||
===Returns=== | ===Returns=== |
Revision as of 06:41, 9 September 2012
This article needs checking. | |
Reason(s): Explain bCheckWaves. --Winky- 20:32, 10 August 2012 (UTC) |
This function allows you to retrieve the water level from a certain location. The water level is 0 in most places though it can vary (e.g. it's higher near the dam).
Syntax
float getWaterLevel ( float posX, float posY, float posZ [ , bool bCheckWaves = false ] ) float getWaterLevel ( water theWater )
Required Arguments
- x: The X axis position
- y: The Y axis position
- z: The Z axis position
or:
- theWater: the water element
Optional Arguments
- bCheckWaves ask arc_ (Prediction: true if the water is close to the ground (It changes whether the water is visible or not))
Returns
Returns false if there's no water in that location or the water level as an integer if you're near the water (-3 to 20 on the Z coordinate).
Example
This example will tell you what's the water level where the specified player is located.
function scriptGetLevel ( command, playername ) --when getlevel is called local thePlayer = getPlayerFromName ( playername ) --get the player from nickname if ( thePlayer ~= false ) then --if there is a player from the nickname local x, y, z = getElementPosition ( thePlayer ) -- get his position local level = getWaterLevel ( x, y, z ) if level then -- if it's not false level = z - level -- calculate how far away is he from the water outputChatBox( "You are " .. level .. " units away from the water!", source ) else outputChatBox ( "There's no sign of water" ) end else outputChatBox ( "Player does not exist" ) end end addCommandHandler( "getlevel", scriptGetLevel ) -- add a command "getloc" which
See Also
- getWaterLevel
- isWaterDrawnLast
- setWaterDrawnLast
- Shared
- createWater
- getWaterColor
- getWaterVertexPosition
- getWaveHeight
- resetWaterColor
- resetWaterLevel
- setWaterColor
- setWaterLevel
- setWaterVertexPosition
- setWaveHeight