CreateObject: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
Creates any GTASA world object at a specified location using x,y,z. The object rotation can also be set with the optional arguments rx, ry, rz.
Creates an object in the GTA world.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">createObject ( id, x, y, z, [rx, ry, rz] )</syntaxhighlight>  
<syntaxhighlight lang="lua">object createObject ( id, x, y, z, [rx, ry, rz] )</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''ID:''' A Whole integer specifying the GTASA object model ID
*'''id:''' A whole integer specifying the GTASA object model ID.
*'''X:''' A Float value that specifies the X coordinate where the object is spawned at in the GTASA world
*'''x:''' A floating point number representing the X coordinate on the map.
*'''Y:''' A Float value that specifies the Y coordinate where the object is spawned at in the GTASA world
*'''y:''' A floating point number representing the Y coordinate on the map.
*'''Z:''' A Float value that specifies the Z coordinate where the object is spawned at in the GTASA world
*'''z:''' A floating point number representing the Z coordinate on the map.


===Optional Arguments===  
===Optional Arguments===  
{{OptionalArg}}  
{{OptionalArg}}  
*'''rx:''' A Float value that specifies the created objects X rotation
*'''rx:''' A floating point number representing the rotation about the X axis in degrees.
*'''ry:''' A Float value that specifies the created objects Y rotation
*'''ry:''' A floating point number representing the rotation about the Y axis in degrees.
*'''rz:''' A Float value that specifies the created objects Z rotation
*'''rz:''' A floating point number representing the rotation about the Z axis in degrees.


==Example==  
==Example==  
Explain what the example does here
This example creates an object when the map starts:
<syntaxhighlight lang="lua">root = getRootElement ()
<syntaxhighlight lang="lua">root = getRootElement ()
addEventHandler ( "onMapLoad", root, "onMapLoad" )
addEventHandler ( "onMapLoad", root, "mapLoad" )
function onMapLoad ( name, root )
function mapLoad ( name )
createObject ( 5540.6654, 1020.55122, 1240.545, 15, 10, 4.4, 6.2] )
  -- create an object at a specified position with a specified rotation
  createObject ( 1337, 5540.6654, 1020.55122, 1240.545, 90, 0, 0 )
end</syntaxhighlight>
end</syntaxhighlight>


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

Revision as of 20:56, 10 November 2006

Creates an object in the GTA world.

Syntax

object createObject ( id, x, y, z, [rx, ry, rz] )

Required Arguments

  • id: A whole integer specifying the GTASA object model ID.
  • x: A floating point number representing the X coordinate on the map.
  • y: A floating point number representing the Y coordinate on the map.
  • z: A floating point number representing the Z coordinate on the map.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • rx: A floating point number representing the rotation about the X axis in degrees.
  • ry: A floating point number representing the rotation about the Y axis in degrees.
  • rz: A floating point number representing the rotation about the Z axis in degrees.

Example

This example creates an object when the map starts:

root = getRootElement ()
addEventHandler ( "onMapLoad", root, "mapLoad" )
function mapLoad ( name )
   -- create an object at a specified position with a specified rotation
   createObject ( 1337, 5540.6654, 1020.55122, 1240.545, 90, 0, 0 )
end

See Also