TestLineAgainstWater: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (fix wrong wave's information) |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
==Syntax== | __NOTOC__ | ||
{{Client function}} | |||
This function checks to see if a line between two points collides with the water. This is similar to [[processLineOfSight]], but only collides with water. Waves are not taken into account when testing the line. | |||
==Syntax== | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool float float float testLineAgainstWater ( float startX, float startY, float startZ, float endX, float endY, float endZ ) | bool float float float testLineAgainstWater ( float startX, float startY, float startZ, float endX, float endY, float endZ ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Required Arguments=== | |||
*'''startX, startY, startZ:''' the position of the starting point of the line. | |||
*'''endX, endY, endZ:''' the position of the end point of the line. | |||
===Returns=== | |||
Returns ''true'' and the position of the intersection point of the line and the water surface if there is a collision, or ''false'' if there is no collision. | |||
==Example== | |||
This code snippet adds a /isanywaterbelowme command, which checks if there is water at 500 units below the ground at the position of the player who types it. | |||
<syntaxhighlight lang="lua"> | |||
function checkForWater() | |||
if isPedOnGround(localPlayer) then | |||
local px, py, pz = getElementPosition(localPlayer) | |||
if testLineAgainstWater(px, py, pz, px, py, pz - 500) then | |||
outputChatBox("Yes, there is water below you.") | |||
else | |||
outputChatBox("This place looks a bit dry.") | |||
end | |||
end | |||
end | |||
addCommandHandler("isanywaterbelowme", checkForWater) | |||
</syntaxhighlight> | |||
==See Also== | |||
{{Client world functions}} |
Latest revision as of 15:54, 19 April 2021
This function checks to see if a line between two points collides with the water. This is similar to processLineOfSight, but only collides with water. Waves are not taken into account when testing the line.
Syntax
bool float float float testLineAgainstWater ( float startX, float startY, float startZ, float endX, float endY, float endZ )
Required Arguments
- startX, startY, startZ: the position of the starting point of the line.
- endX, endY, endZ: the position of the end point of the line.
Returns
Returns true and the position of the intersection point of the line and the water surface if there is a collision, or false if there is no collision.
Example
This code snippet adds a /isanywaterbelowme command, which checks if there is water at 500 units below the ground at the position of the player who types it.
function checkForWater() if isPedOnGround(localPlayer) then local px, py, pz = getElementPosition(localPlayer) if testLineAgainstWater(px, py, pz, px, py, pz - 500) then outputChatBox("Yes, there is water below you.") else outputChatBox("This place looks a bit dry.") end end end addCommandHandler("isanywaterbelowme", checkForWater)
See Also
- createSWATRope
- getBirdsEnabled
- getCoronaReflectionsEnabled
- getGarageBoundingBox
- getGaragePosition
- getGarageSize
- getGroundPosition
- getInteriorFurnitureEnabled
- getNearClipDistance
- getPedsLODDistance
- getRoofPosition
- getScreenFromWorldPosition
- getVehiclesLODDistance
- getWorldFromScreenPosition
- isAmbientSoundEnabled
- isLineOfSightClear
- isWorldSoundEnabled
- processLineOfSight
- resetAmbientSounds
- resetBlurLevel
- resetColorFilter
- resetCoronaReflectionsEnabled
- resetNearClipDistance
- resetPedsLODDistance
- resetVehiclesLODDistance
- resetWorldSounds
- setAmbientSoundEnabled
- setBirdsEnabled
- setColorFilter
- setCoronaReflectionsEnabled
- setInteriorFurnitureEnabled
- setInteriorSoundsEnabled
- setNearClipDistance
- setPedsLODDistance
- setVehiclesLODDistance
- setWorldSoundEnabled
- testLineAgainstWater
- areTrafficLightsLocked
- getAircraftMaxHeight
- getAircraftMaxVelocity
- getCloudsEnabled
- getFarClipDistance
- getFogDistance
- getGameSpeed
- getGravity
- getHeatHaze
- getInteriorSoundsEnabled
- getJetpackMaxHeight
- getMinuteDuration
- getMoonSize
- getOcclusionsEnabled
- getRainLevel
- getSunColor
- getSunSize
- getTime
- getTrafficLightState
- getWeather
- getWindVelocity
- getSkyGradient
- getPlayerBlurLevel
- getZoneName
- isGarageOpen
- removeWorldModel
- resetFarClipDistance
- resetFogDistance
- resetHeatHaze
- resetMoonSize
- resetRainLevel
- resetSkyGradient
- resetSunColor
- resetSunSize
- resetWindVelocity
- restoreAllWorldModels
- restoreWorldModel
- setAircraftMaxHeight
- setAircraftMaxVelocity
- setCloudsEnabled
- setFarClipDistance
- setFogDistance
- setGameSpeed
- setGarageOpen
- setGravity
- setHeatHaze
- setInteriorSoundsEnabled
- setMinuteDuration
- setMoonSize
- setOcclusionsEnabled
- setRainLevel
- setSkyGradient
- setSunColor
- setSunSize
- setTime
- setTrafficLightState
- setTrafficLightsLocked
- setWeather
- setWeatherBlended
- setWindVelocity
- setJetpackMaxHeight
- setPlayerBlurLevel