SetObjectRotation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
m (Changed "DeprecatedWithAlt" template to "Deprecated")
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Category:Incomplete]]
__NOTOC__
{{Server client function}}
{{Deprecated|setElementRotation|}}


__NOTOC__
Allows you to change an object's rotation while playing a map. The object can be from the map file or created in a script.
This fake function is for use with blah & blah and does blahblahblabhalbhl


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setObjectRotation ( element object, float x, float y, float z )         
bool setObjectRotation ( object theObject, float rotX, float rotY, float rotZ )         
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''theObject:''' The object to be rotated
 
*'''rotX:''' Rotation around the X axis
===Optional Arguments===
*'''rotY:''' Rotation around the Y axis
{{OptionalArg}}
*'''rotZ:''' Rotation around the Z axis
*'''argumentName2:''' descriptiona
*'''argumentName3:''' description


===Returns===
===Returns===
Returns ''true'' if blah, ''false'' otherwise.
Returns ''true'' if successful, ''false'' otherwise.


==Example==  
==Example==  
This example does...
In this example, I refer to an object in the map file with the ID "pirateship":
<syntaxhighlight lang="xml">
<object id="pirateship" posX="-1627.319092" posY="128.543411" posZ="6.581001" rotX="-0.760854" rotY="2.421000" rotZ="0.851000" model="8493"/>
</syntaxhighlight>
 
 
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
function onResourceStart ( name, root )
blabhalbalhb --abababa
    -- predefined variables, needed for the math code below
--This line does this...
    rotX = 0
mooo
    rotY = 0
    rotZ = 0
    -- assign element named 'pirateship' in map file to variable
    pirateship = getElementByID ( "pirateship" )
end
 
function chatboxShipRotateLeft ( playerSource, commandName ) -- On console command 'increaserotations'
    outputChatBox ( "Rotational values increased" )
    -- rotations = rotations + 10
    rotX = rotX + 10
    rotY = rotY + 10
    rotZ = rotZ + 10
    -- Changed rotation is applied
    setObjectRotation ( pirateship, rotX, rotY, rotZ )
end   
 
function chatboxShipRotateRight ( playerSource, commandName ) -- On console command 'decreaserotations'
    outputChatBox ( "Rotational values decreased" )
    -- rotations = rotations - 10
    rotX = rotX - 10
    rotY = rotY - 10
    rotZ = rotZ - 10
    -- Changed rotation is applied
    setObjectRotation ( pirateship, rotX, rotY, rotZ )
end
 
-- Set up event and command handlers
addEventHandler ( "onResourceStart", resourceRoot, onResourceStart )
 
addCommandHandler ( "increaserotations", chatboxShipRotateLeft )
addCommandHandler ( "decreaserotations", chatboxShipRotateRight )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{FunctionArea_Functions}}
{{Object functions}}

Latest revision as of 16:17, 13 February 2015

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use setElementRotation instead.


Allows you to change an object's rotation while playing a map. The object can be from the map file or created in a script.

Syntax

bool setObjectRotation ( object theObject, float rotX, float rotY, float rotZ )        

Required Arguments

  • theObject: The object to be rotated
  • rotX: Rotation around the X axis
  • rotY: Rotation around the Y axis
  • rotZ: Rotation around the Z axis

Returns

Returns true if successful, false otherwise.

Example

In this example, I refer to an object in the map file with the ID "pirateship":

<object id="pirateship" posX="-1627.319092" posY="128.543411" posZ="6.581001" rotX="-0.760854" rotY="2.421000" rotZ="0.851000" model="8493"/>


function onResourceStart ( name, root )
    -- predefined variables, needed for the math code below
    rotX = 0
    rotY = 0
    rotZ = 0
    -- assign element named 'pirateship' in map file to variable
    pirateship = getElementByID ( "pirateship" )
end

function chatboxShipRotateLeft ( playerSource, commandName ) -- On console command 'increaserotations'
    outputChatBox ( "Rotational values increased" )
    -- rotations = rotations + 10
    rotX = rotX + 10
    rotY = rotY + 10
    rotZ = rotZ + 10
    -- Changed rotation is applied
    setObjectRotation ( pirateship, rotX, rotY, rotZ )
end     

function chatboxShipRotateRight ( playerSource, commandName ) -- On console command 'decreaserotations'
    outputChatBox ( "Rotational values decreased" )
    -- rotations = rotations - 10
    rotX = rotX - 10
    rotY = rotY - 10
    rotZ = rotZ - 10
    -- Changed rotation is applied
    setObjectRotation ( pirateship, rotX, rotY, rotZ )
end

-- Set up event and command handlers
addEventHandler ( "onResourceStart", resourceRoot, onResourceStart )

addCommandHandler ( "increaserotations", chatboxShipRotateLeft )
addCommandHandler ( "decreaserotations", chatboxShipRotateRight )

See Also