DetachElementFromElement: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 24: Line 24:
==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
<!-- Explain what the example is in a single sentance -->
This example does...
This function will detach any elements that might have been attached to the passed element.
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
function freeElement( element )
blabhalbalhb --abababa
      if ( isElementAttached( element ) ) then --If the specified element is attached to something
--This line does this...
            detachElementFromElement( element ) --Detach it.
mooo
      else
            outputChatBox( "Element is not attached" ) --If not, say it wasn't attached in the first place.
      end
end
</syntaxhighlight>
</syntaxhighlight>


Line 36: Line 39:
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc -->
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc -->
{{Element_functions}}
{{Element_functions}}
[[Category:Incomplete]] -- leave this unless you complete the function

Revision as of 11:56, 19 April 2007

This function detaches attached elements from one another.

Syntax

bool detachElementFromElement ( element theElement, [ element theAttachToElement ] )

Required Arguments

  • theElement: The element to be detached (the "child")

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.

  • theAttachToElement: The element you wish to detach from, will detach from the attached element if this isn't specified.

Returns

Returns true if the detaching was successful, false otherwise.

Example

This function will detach any elements that might have been attached to the passed element.

function freeElement( element )
      if ( isElementAttached( element ) ) then --If the specified element is attached to something
            detachElementFromElement( element ) --Detach it.
      else
            outputChatBox( "Element is not attached" ) --If not, say it wasn't attached in the first place.
      end
end

See Also