MoveObject: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Server client function}} | |||
__NOTOC__ | __NOTOC__ | ||
This function will smoothly move an object from its current position/rotation to the given target position/rotation in the given time. If the function fails for some reason, it will return false. | This function will smoothly move an object from its current position/rotation to the given target position/rotation in the given time. If the function fails for some reason, it will return false. | ||
Line 5: | Line 6: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> bool moveObject ( object theObject, int time, float targetx, float targety, float targetz, [ float targetrx, float targetry, float targetrz ] )</syntaxhighlight> | <syntaxhighlight lang="lua"> | ||
bool moveObject ( object theObject, int time, float targetx, float targety, float targetz, [ float targetrx, float targetry, float targetrz ] ) | |||
</syntaxhighlight> | |||
===Required Arguments=== | ===Required Arguments=== | ||
* '''theObject''' | * '''theObject:''' The object that will be moved. | ||
* '''time''' | * '''time:''' The time in milliseconds the object will arrive at the destination. | ||
* '''targetx''' | * '''targetx:''' The X value of the target position | ||
* '''targety''' | * '''targety:''' The Y value of the target position | ||
* '''targetz''' | * '''targetz:''' The Z value of the target position | ||
===Optional Arguments=== | ===Optional Arguments=== | ||
* '''targetrx''' | * '''targetrx:''' The X value of the target rotation | ||
* '''targetry''' | * '''targetry:''' The Y value of the target rotation | ||
* '''targetrz''' | * '''targetrz:''' The Z value of the target rotation | ||
===Returns=== | ===Returns=== | ||
Line 30: | Line 33: | ||
if ( someGuy ) then | if ( someGuy ) then | ||
-- Get the player's position | -- Get the player's position | ||
x, y, z = | x, y, z = getElementPosition ( someGuy ) | ||
-- Create a bed (1700) object near to the player | -- Create a bed (1700) object near to the player | ||
bed = createObject ( 1700, x + 5, y, z ) | bed = createObject ( 1700, x + 5, y, z ) |
Revision as of 19:42, 16 August 2007
This function will smoothly move an object from its current position/rotation to the given target position/rotation in the given time. If the function fails for some reason, it will return false.
The rotation arguments seem to be added to the current rotation, instead of using it as target rotation.
Syntax
bool moveObject ( object theObject, int time, float targetx, float targety, float targetz, [ float targetrx, float targetry, float targetrz ] )
Required Arguments
- theObject: The object that will be moved.
- time: The time in milliseconds the object will arrive at the destination.
- targetx: The X value of the target position
- targety: The Y value of the target position
- targetz: The Z value of the target position
Optional Arguments
- targetrx: The X value of the target rotation
- targetry: The Y value of the target rotation
- targetrz: The Z value of the target rotation
Returns
Returns true if the function moved the object succesfully, and returns false otherwise.
Example
This example created a model (of a bed) near a player called someguy, if they exist in the game. It will then move the model towards the player over 3 seconds.
-- Find a player called 'someguy' someGuy = getPlayerFromNick ( "someguy" ) -- If a player called someguy was found then if ( someGuy ) then -- Get the player's position x, y, z = getElementPosition ( someGuy ) -- Create a bed (1700) object near to the player bed = createObject ( 1700, x + 5, y, z ) -- Move the bed towards the player over 3 seconds (3000 milliseconds) moveObject ( bed, 3000, x, y, z ) -- Tell the player in the chat box outputChatBox ( "Moving a bed towards you!", someGuy ) else -- Tell everyone that a player called 'someguy' could not be found outputChatBox ( "Player someguy doesn't exist" ) end
See Also