GetObjectRotation: Difference between revisions
Jump to navigation
Jump to search
Line 20: | Line 20: | ||
The following code gets the object element by ID and outputs it's rotation: | The following code gets the object element by ID and outputs it's rotation: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
addEventHandler ( "onMapLoad", root, "mapStart" ) | addEventHandler ( "onMapLoad", root, "mapStart" ) | ||
function mapStart ( name ) -- this function gets called when the map starts | function mapStart ( name ) -- this function gets called when the map starts |
Revision as of 07:56, 9 September 2006
Object rotation can be retrieved from objects in mapfiles or objects that are created in scripts.
Syntax
float float float getObjectRotation ( object theObject )
Required Arguments
- theObject: The object whose rotation will be retrieved
Returns
Returns true if object exists, 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"/>
The following code gets the object element by ID and outputs it's rotation:
addEventHandler ( "onMapLoad", root, "mapStart" ) function mapStart ( name ) -- this function gets called when the map starts pirateship = getElementByID ( "Pirate Ship" ) -- get the object element if ( pirateship ) then rx, ry, rz = getObjectRotation ( pirateship ) -- get the rotation of the object outputChatBox ( "Ship RX = "..rx.." SHIP RY = "..ry.." SHIP RZ = "..rz ) -- output: Ship RX = 316.40628051758 SHIP RY = 2.421000 SHIP RZ = 0.851000 else outputChatBox ( "Couldn't find the object, 'Pirate Ship!'" ) end end
See Also