IsObjectMoving: Difference between revisions
Jump to navigation
Jump to search
(Add missing OOP info) |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
{{ | {{Added feature/item|3.0159|1.5.9|1.5.8|20811|This function checks if an [[object]] is moving.}} | ||
==Syntax== | ==Syntax== | ||
Line 7: | Line 7: | ||
{{OOP||[[object]]:isMoving|moving}} | {{OOP||[[object]]:isMoving|moving}} | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theObject:''' The [[object]] | *'''theObject:''' The [[object]] [[element]]. | ||
===Returns=== | ===Returns=== | ||
* ''true'' if the object is moving | * Returns ''true'' if the [[object]] is moving, ''false'' otherwise. | ||
==Example== | ==Example== | ||
This example creates an object when the resource starts and checks if the object is moving | This example creates an object when the resource starts and checks if the object is moving: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
addEventHandler("onClientResourceStart", resourceRoot, | addEventHandler ("onClientResourceStart", resourceRoot, | ||
function() | function () | ||
local x, y, z = getElementPosition(localPlayer) | local x, y, z = getElementPosition (localPlayer) | ||
object = createObject(1239, x, y, z) | object = createObject (1239, x, y, z) | ||
moveObject(object, 5000, x, y, z + 5) | moveObject (object, 5000, x, y, z + 5) | ||
end | end | ||
) | ) | ||
addCommandHandler("getmoving", | addCommandHandler ("getmoving", | ||
function( | function (commandName) | ||
outputChatBox("Is object "..(isObjectMoving(object) and "moving" or "not moving")) | outputChatBox ("Is object "..(isObjectMoving(object) and "moving" or "not moving")) | ||
end | end | ||
) | ) |
Revision as of 10:30, 20 September 2021
20811
Syntax
bool isObjectMoving ( object theObject )
OOP Syntax Help! I don't understand this!
- Method: object:isMoving(...)
- Variable: .moving
Required Arguments
Returns
- Returns true if the object is moving, false otherwise.
Example
This example creates an object when the resource starts and checks if the object is moving:
addEventHandler ("onClientResourceStart", resourceRoot, function () local x, y, z = getElementPosition (localPlayer) object = createObject (1239, x, y, z) moveObject (object, 5000, x, y, z + 5) end ) addCommandHandler ("getmoving", function (commandName) outputChatBox ("Is object "..(isObjectMoving(object) and "moving" or "not moving")) end )
Requirements
This template will be deleted.
See Also
- createObject
- getObjectScale
- moveObject
- setObjectScale
- stopObject
- getObjectMass
- getObjectProperty
- setObjectMass
- setObjectProperty