IsObjectMoving: Difference between revisions
Jump to navigation
Jump to search
m (added New feature tag) |
m (Update) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{ | {{Shared function}} | ||
{{ | {{Added feature/item|1.5.9|1.5.8|20811|This function checks if an [[object]] is moving.}} {{New feature/item|3.0161|1.6.0|22430|This function is now also available on the server side.}} | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">bool isObjectMoving ( object theObject )</syntaxhighlight> | <syntaxhighlight lang="lua">bool isObjectMoving ( object theObject )</syntaxhighlight> | ||
{{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 | ||
) | ) | ||
Line 32: | Line 31: | ||
==Requirements== | ==Requirements== | ||
{{Requirements| | {{Requirements|1.6.0-9.22430|1.5.8-9.20811|}} | ||
==See Also== | ==See Also== | ||
{{Client_object_functions}} | {{Client_object_functions}} |
Latest revision as of 21:42, 23 May 2024
This function checks if an object is moving.
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
Minimum server version | 1.6.0-9.22430 |
---|---|
Minimum client version | 1.5.8-9.20811 |
Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version server="1.6.0-9.22430" client="1.5.8-9.20811" />
See Also
- getObjectMass
- getObjectProperty
- setObjectMass
- setObjectProperty
- Shared
- createObject
- getObjectScale
- moveObject
- setObjectScale
- stopObject