GetObjectMass: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Needs_Example}} __NOTOC__ {{client_function}} {{New feature/item|3.0140|1.4|5170| This function returns the mass of a specified object. }} ==Syntax== <syntaxhighlight lang="lua"> float getOb...")
 
(→‎Returns: this return -1 if object was never streamed in by client)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Needs_Example}}
__NOTOC__
__NOTOC__
{{client_function}}
{{Client_function}}
{{New feature/item|3.0140|1.4|5170|
{{New feature/item|3.0132|1.3.2|5170|
This function returns the mass of a specified object.
This function returns the mass of a specified object.
}}
}}
Line 10: Line 9:
float getObjectMass ( object theObject )
float getObjectMass ( object theObject )
</syntaxhighlight>
</syntaxhighlight>
 
{{OOP||[[object]]:getMass|mass|setObjectMass}}
===Required Arguments===
===Required Arguments===
*'''theObject:''' The object whose mass you want to get.
*'''theObject:''' the object whose mass you want to get.


===Returns===
===Returns===
Returns a [[float]] representing the mass of the object, ''false'' if invalid arguments were passed.
* A [[float]] representing the mass of the object.
* ''false'' if invalid arguments were passed.
* ''-1'' if object was never streamed in.


==Example==
==Example==
 
This script basically creates an object then get's the mass and set's its mass 300 more than it's original mass, then tell the client the old and new mass of the object.
<syntaxhighlight lang="lua">local object = createObject(1337,0,0,3)
local oldMass = getObjectMass(object)
local newMass = oldMass+300.0
setObjectMass(object,newMass)
outputChatBox("Object Old Mass: "..oldMass..", New Mass: "..newMass)</syntaxhighlight>
==See Also==
==See Also==
{{Client_object_functions}}
{{Client_object_functions}}

Latest revision as of 16:52, 19 March 2016

This function returns the mass of a specified object.

Syntax

float getObjectMass ( object theObject )

OOP Syntax Help! I don't understand this!

Method: object:getMass(...)
Variable: .mass
Counterpart: setObjectMass


Required Arguments

  • theObject: the object whose mass you want to get.

Returns

  • A float representing the mass of the object.
  • false if invalid arguments were passed.
  • -1 if object was never streamed in.

Example

This script basically creates an object then get's the mass and set's its mass 300 more than it's original mass, then tell the client the old and new mass of the object.

local object = createObject(1337,0,0,3)
local oldMass = getObjectMass(object)
local newMass = oldMass+300.0
setObjectMass(object,newMass)
outputChatBox("Object Old Mass: "..oldMass..", New Mass: "..newMass)

See Also