GetElementChild: 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
This function returns an element based on it's parent.


==Syntax==  
==Syntax==  
Line 10: Line 10:


===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''parent:''' the element above the one to be returned in the hierarchy.
*'''index:''' the element's index (0 for the first element, 1 for the second, etc).


===Optional Arguments===  
===Returns===
{{OptionalArg}}
Returns the requested element if it exists, or false if it doesn't.
*'''argumentName2:''' descriptiona
*'''argumentName3:''' description


===Returns===
==Example==
Returns ''true'' if blah, ''false'' otherwise.
To spawn a player at the red team's third spawnpoint:
<syntaxhighlight lang="lua">
<team1 id="red">
    <spawnpoint id="spawnpoint_0" posX="2507.8715820313" posY="2772.6071777344" posZ="10.8203125" rot="270" skin="285"/>
    <spawnpoint id="spawnpoint_1" posX="2508.060546875" posY="2780.3647460938" posZ="10.8203125" rot="270" skin="285"/>
    <spawnpoint id="spawnpoint_2" posX="2508.0053710938" posY="2776.2897949219" posZ="10.8203125" rot="270" skin="285"/> -- third spawnpoint
    <spawnpoint id="spawnpoint_3" posX="2510.6899414063" posY="2778.3745117188" posZ="10.8203125" rot="270" skin="285"/>
</team1></syntaxhighlight>


==Example==
You could use the following code:
This example does...
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
teamRed = getElementByID ( "red" ) -- find the parent element by it's ID and assign it to teamRed variable
blabhalbalhb --abababa
teamRedSpawn = getElementChild ( teamRed, 2 ) -- find teamRed's third child element (which happens to be a spawnpoint)
--This line does this...
spawnPlayer ( player, teamRedSpawn ) -- spawn a player at the spawnpoint
mooo
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{FunctionArea_Functions}}
{{FunctionArea_Functions}}

Revision as of 11:59, 2 June 2006


This function returns an element based on it's parent.

Syntax

element getElementChild ( element parent, int index ) 

Required Arguments

  • parent: the element above the one to be returned in the hierarchy.
  • index: the element's index (0 for the first element, 1 for the second, etc).

Returns

Returns the requested element if it exists, or false if it doesn't.

Example

To spawn a player at the red team's third spawnpoint:

<team1 id="red">
    <spawnpoint id="spawnpoint_0" posX="2507.8715820313" posY="2772.6071777344" posZ="10.8203125" rot="270" skin="285"/>
    <spawnpoint id="spawnpoint_1" posX="2508.060546875" posY="2780.3647460938" posZ="10.8203125" rot="270" skin="285"/>
    <spawnpoint id="spawnpoint_2" posX="2508.0053710938" posY="2776.2897949219" posZ="10.8203125" rot="270" skin="285"/> -- third spawnpoint
    <spawnpoint id="spawnpoint_3" posX="2510.6899414063" posY="2778.3745117188" posZ="10.8203125" rot="270" skin="285"/>
</team1>

You could use the following code:

teamRed = getElementByID ( "red" ) -- find the parent element by it's ID and assign it to teamRed variable
teamRedSpawn = getElementChild ( teamRed, 2 ) -- find teamRed's third child element (which happens to be a spawnpoint)
spawnPlayer ( player, teamRedSpawn ) -- spawn a player at the spawnpoint

See Also

Template:FunctionArea Functions