GetColPolygonHeight: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Server client function}} | {{Server client function}} | ||
__NOTOC__ | __NOTOC__ | ||
{{ | {{Added feature/item|1.5.9|1.5.8|20807|This function is used to get the height of an existing [[createColPolygon|colshape polygon]]. | ||
By default, a colshape polygon is infinitely tall.}} | By default, a colshape polygon is infinitely tall.}} | ||
Line 11: | Line 11: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''shape:''' The [[colshape]] polygon | *'''shape:''' The [[colshape]] polygon. | ||
===Returns=== | ===Returns=== | ||
Line 17: | Line 17: | ||
==Example== | ==Example== | ||
<section name="Server" class="server" show="true"> | |||
This example creates a polygon colshape and show height of it with command 'getpolyheight'. | |||
<syntaxhighlight lang="lua"> | |||
-- Creates polygon colshape at 0, 0, 4 | |||
local colPoly = createColPolygon ( -1.08, -0.05, 2.92, -0.05, -1.08, -4.05, -5.08, -0.05, -1.08, 3.95 ) | |||
-- Set its height to 4 unit | |||
setColPolygonHeight ( colPoly, 2.32, 7.12 ) | |||
function showPolyHeight ( player, command ) | |||
-- Get element position | |||
local x, y = getElementPosition ( colPoly ) | |||
-- Get table floor and ceil of the colshape height and unpack it | |||
local z, z1 = unpack ( getColPolygonHeight ( colPoly ) ) | |||
local heights = z1 - z | |||
-- Output it in his chatbox | |||
outputChatBox( "The Polygon Colshape at "..x..", "..y.." height is "..heights, player, 255, 255, 0) | |||
end | |||
addCommandHandler ( "getpolyheight", showPolyHeight ) | |||
</syntaxhighlight> | |||
</section> | |||
==See Also== | ==See Also== | ||
{{Collision_shape_functions}} | {{Collision_shape_functions}} |
Latest revision as of 17:27, 7 November 2024
This function is used to get the height of an existing colshape polygon. By default, a colshape polygon is infinitely tall.
Syntax
float, float getColPolygonHeight ( colshape shape )
OOP Syntax Help! I don't understand this!
- Method: colshape:getHeight(...)
Required Arguments
- shape: The colshape polygon.
Returns
Returns two floats, indicating the floor and ceiling of the colshape height, false if invalid arguments were passed.
Example
Click to collapse [-]
ServerThis example creates a polygon colshape and show height of it with command 'getpolyheight'.
-- Creates polygon colshape at 0, 0, 4 local colPoly = createColPolygon ( -1.08, -0.05, 2.92, -0.05, -1.08, -4.05, -5.08, -0.05, -1.08, 3.95 ) -- Set its height to 4 unit setColPolygonHeight ( colPoly, 2.32, 7.12 ) function showPolyHeight ( player, command ) -- Get element position local x, y = getElementPosition ( colPoly ) -- Get table floor and ceil of the colshape height and unpack it local z, z1 = unpack ( getColPolygonHeight ( colPoly ) ) local heights = z1 - z -- Output it in his chatbox outputChatBox( "The Polygon Colshape at "..x..", "..y.." height is "..heights, player, 255, 255, 0) end addCommandHandler ( "getpolyheight", showPolyHeight )
See Also
- addColPolygonPoint
- createColCircle
- createColCuboid
- createColPolygon
- createColRectangle
- createColSphere
- createColTube
- getColPolygonHeight
- getColPolygonPoints
- getColPolygonPointPosition
- getColShapeType
- getColShapeRadius
- getColShapeSize
- getElementColShape
- getElementsWithinColShape
- isElementWithinColShape
- isInsideColShape
- removeColPolygonPoint
- setColPolygonHeight
- setColPolygonPointPosition
- setColShapeRadius
- setColShapeSize