GetElementDistanceFromCentreOfMassToBaseOfModel: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Removed precalculated outputs, incorrect.)
(Added OOP syntax)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
This function is used to retrieve the distance between a element's centre of mass to the base of the model. This can be used to calculate the position the element has to be set to, to have it on ground level.
This function is used to retrieve the distance between a [[element]]'s centre of mass to the base of the model. This can be used to calculate the position the [[element]] has to be set to, to have it on ground level.
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
float getElementDistanceFromCentreOfMassToBaseOfModel ( element theElement )
float getElementDistanceFromCentreOfMassToBaseOfModel ( element theElement )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[element]]:getDistanceFromCentreOfMassToBaseOfModel}}
===Required Parameters===
===Required Parameters===
'''theElement:''' The element you want to retrieve the value of.
'''theElement:''' The element you want to retrieve the value of.
===Returns===
===Returns===
Returns a ''float'' with the distance, or ''false'' if the element is invalid.
Returns a ''float'' with the distance, or ''false'' if the element is invalid.
==Example==
==Example==
This example outputs the value for the local player.
This example outputs the value for the local player.
Line 17: Line 21:
outputChatBox(tostring(distance))
outputChatBox(tostring(distance))
</syntaxhighlight>
</syntaxhighlight>
==See Also==
==See Also==
{{Client element functions}}
{{Client element functions}}

Revision as of 16:58, 26 November 2014

This function is used to retrieve the distance between a element's centre of mass to the base of the model. This can be used to calculate the position the element has to be set to, to have it on ground level.

Syntax

float getElementDistanceFromCentreOfMassToBaseOfModel ( element theElement )

OOP Syntax Help! I don't understand this!

Method: element:getDistanceFromCentreOfMassToBaseOfModel(...)


Required Parameters

theElement: The element you want to retrieve the value of.

Returns

Returns a float with the distance, or false if the element is invalid.

Example

This example outputs the value for the local player.

local localPlayer = getLocalPlayer()
local distance = getElementDistanceFromCentreOfMassToBaseOfModel(localPlayer)
outputChatBox(tostring(distance))

See Also