CreateElement: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Undo revision 36309 by MOJRM-511 (talk))
Line 5: Line 5:
Elements created using this function are placed in the element tree with their parent as the 'dynamic' map element.
Elements created using this function are placed in the element tree with their parent as the 'dynamic' map element.


MOJRM-511
==Syntax==
<syntaxhighlight lang="lua">
element createElement ( string elementType, [ string elementID = nil ] )
</syntaxhighlight>
 
===Required Arguments===
*'''elementType:''' The type of element being created.
 
===Optional Arguments===
*'''elementID:''' The ID of the element being created.
 
===Returns===
Returns the element if it was successfully created. Returns ''false'' if the arguments are wrong.


==Example==
==Example==

Revision as of 03:34, 2 June 2013

This function is used to create a new dummy element in the element tree which do not necessarily represent an entity within the San Andreas world. A common use for this function is for creating custom elements, such as a Flag or a Base.

Elements created using this function are placed in the element tree with their parent as the 'dynamic' map element.

Syntax

element createElement ( string elementType, [ string elementID = nil ] )

Required Arguments

  • elementType: The type of element being created.

Optional Arguments

  • elementID: The ID of the element being created.

Returns

Returns the element if it was successfully created. Returns false if the arguments are wrong.

Example

This example creates a "flag" element, named "blue", which will be at the resource's dynamic map.

blueTeamFlag = createElement( "flag", "blue" )

Except for it being placed in a different map root, that line will have the same effect as having this in a .map file:

<flag id="blue" />

See Also