SetObjectRotation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 2: Line 2:


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


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setObjectRotation ( element object, float x, float y, float z )         
bool setObjectRotation ( element object, float rx, float ry, float rz )         
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''Object:''' The object to be rotated
 
*'''rx:''' Rotation X value
===Optional Arguments===
*'''ry:''' Rotation Y value
{{OptionalArg}}
*'''rz:''' Rotation Z value
*'''argumentName2:''' descriptiona
*'''argumentName3:''' description


===Returns===
===Returns===
Line 21: Line 19:


==Example==  
==Example==  
This example does...
In this example, I refer to an object in the mapfile with the ID "pirateship":
<syntaxhighlight lang="xml">
<object id="Pirate Ship" 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...
addEventHandler ( "onMapLoad", root, "onMapLoad" )
blabhalbalhb --abababa
function onMapLoad ( name, root )
--This line does this...
rx = 0
mooo
ry = 0
rz = 0 -- predefined varibles, for math code below
pirateship = getElementByID ( "pirateship" ) --assign element named 'pirateship' in map file to varible             
end
 
addCommandHandler ( "increaserotations", "chatboxShipRotateLeft" ) --On console command 'increaserotations', execute code
function chatboxShipRotateLeft ( playerSource, commandName )
outputChatBox ( "Rotational values increased" )
rx = rx + 10
ry = ry + 10
rz = rz + 10 -- rotations = rotations + 10
setObjectRotation ( pirateship, rx, ry, rz ) --Changed rotation is applied
end     
 
addCommandHandler ( "decreaserotations", "chatboxShipRotateRight" ) --Repeat and subtracted values to decrease rotations
function chatboxShipRotateRight ( playerSource, commandName )
outputChatBox ( "Rotational values decreased" )
rx = rx - 10
ry = ry - 10
rz = rz - 10
setObjectRotation ( pirateship, rx, ry, rz )
end
</syntaxhighlight>
</syntaxhighlight>


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

Revision as of 08:11, 9 September 2006


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

Syntax

bool setObjectRotation ( element object, float rx, float ry, float rz )        

Required Arguments

  • Object: The object to be rotated
  • rx: Rotation X value
  • ry: Rotation Y value
  • rz: Rotation Z value

Returns

Returns true if blah, false otherwise.

Example

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

<object id="Pirate Ship" posX="-1627.319092" posY="128.543411" posZ="6.581001" rotX="-0.760854" rotY="2.421000" rotZ="0.851000" model="8493"/>
addEventHandler ( "onMapLoad", root, "onMapLoad" )
function onMapLoad ( name, root ) 
rx = 0
ry = 0
rz = 0 -- predefined varibles, for math code below
pirateship = getElementByID ( "pirateship" ) --assign element named 'pirateship' in map file to varible              
end

addCommandHandler ( "increaserotations", "chatboxShipRotateLeft" ) --On console command 'increaserotations', execute code
function chatboxShipRotateLeft ( playerSource, commandName )
outputChatBox ( "Rotational values increased" )
rx = rx + 10
ry = ry + 10
rz = rz + 10 -- rotations = rotations + 10
setObjectRotation ( pirateship, rx, ry, rz ) --Changed rotation is applied
end      

addCommandHandler ( "decreaserotations", "chatboxShipRotateRight" ) --Repeat and subtracted values to decrease rotations
function chatboxShipRotateRight ( playerSource, commandName )
outputChatBox ( "Rotational values decreased" ) 
rx = rx - 10
ry = ry - 10
rz = rz - 10 
setObjectRotation ( pirateship, rx, ry, rz )
end

See Also