GetElementBoundingBox: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (List of args)
 
(11 intermediate revisions by 9 users not shown)
Line 1: Line 1:
__NOTOC__  
{{Client function}}
This function returns the minimum and maximum x,y,z coords of an element's bounding box.
__NOTOC__
This function returns the minimum and maximum coordinates of an element's bounding box.


==Syntax==  
It should be noted that the values returned are relative to the position of the element, and as such if you wish to get world coordinates for drawing, etc., you should retrieve the position of the element and add the returned values onto that.
{{Note|The element must be streamed in for this function to work.}}
 
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
float float float float float float getElementBoundingBox ( element theElement )
float, float, float, float, float, float getElementBoundingBox ( element theElement )
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP||[[element]]:getBoundingBox}}


===Required Arguments===  
===Required Arguments===
*'''theElement:''' the element whose bounding box we want to get.
* '''theElement:''' the element whose bounding box we want to get.


===Returns===
===Returns===
*Returns ''min x, min y, min z, max x, max y, max z'' if the passed element is valid, ''false'' otherwise.
*Returns ''min x, min y, min z, max x, max y, max z'' if the passed element is valid and streamed in, ''false'' otherwise.


==Example==  
==Example==  
This example outputs to chatbox the minimum and the maximum coordinates of an element.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
function minMaxOutput( theElement )
blabhalbalhb --abababa
    local x0, y0, z0, x1, y1, z1 = getElementBoundingBox( theElement )
--This line does this...
 
mooo
    if ( x0 ) then
        outputChatBox( "The coords are: " .. x0 .. ", " .. y0 .. ", " .. z0 .. ", " .. x1 .. ", " .. y1 .. ", " .. z1 )
    else
        outputChatBox( "Failed to retrieve bounding box" )
    end
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Client element functions}}
{{Client element functions}}
[[Category:Incomplete]]

Latest revision as of 14:08, 29 April 2021

This function returns the minimum and maximum coordinates of an element's bounding box.

It should be noted that the values returned are relative to the position of the element, and as such if you wish to get world coordinates for drawing, etc., you should retrieve the position of the element and add the returned values onto that.

[[{{{image}}}|link=|]] Note: The element must be streamed in for this function to work.

Syntax

float, float, float, float, float, float getElementBoundingBox ( element theElement )

OOP Syntax Help! I don't understand this!

Method: element:getBoundingBox(...)


Required Arguments

  • theElement: the element whose bounding box we want to get.

Returns

  • Returns min x, min y, min z, max x, max y, max z if the passed element is valid and streamed in, false otherwise.

Example

This example outputs to chatbox the minimum and the maximum coordinates of an element.

function minMaxOutput( theElement )
    local x0, y0, z0, x1, y1, z1 = getElementBoundingBox( theElement )

    if ( x0 ) then
        outputChatBox( "The coords are: " .. x0 .. ", " .. y0 .. ", " .. z0 .. ", " .. x1 .. ", " .. y1 .. ", " .. z1 )
    else
        outputChatBox( "Failed to retrieve bounding box" )
    end
end

See Also