GetElementParent: Difference between revisions
Jump to navigation
Jump to search
m (Corrected addEventHandler call (position and function pointer)) |
|||
Line 26: | Line 26: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
This function determines a spawnpoint's parent element, and announces | This function determines a spawnpoint's parent element, and announces its ID: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function spawnpointUse ( player ) -- this function gets called whenever a spawnpoint is used | function spawnpointUse ( player ) -- this function gets called whenever a spawnpoint is used | ||
theSpawnGroup = getElementParent ( source ) -- get the spawnpoint's parent element | theSpawnGroup = getElementParent ( source ) -- get the spawnpoint's parent element | ||
Line 35: | Line 34: | ||
-- Example output: "Joe spawned at team blue's spawnpoint." | -- Example output: "Joe spawned at team blue's spawnpoint." | ||
end | end | ||
addEventHandler ( "onSpawnpointUse", getRootElement (), spawnpointUse ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{element_functions}} | {{element_functions}} |
Revision as of 15:03, 15 August 2007
This function is used to determine the parent of an element.
Syntax
element getElementParent ( element theElement )
Required Arguments
- theElement: The child of the parent element you want returned.
Returns
This returns the parent as an element. It returns false if theElement is invalid, or is the root node.
Example
Consider the following map file:
<spawngroup 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"/> </spawngroup> <spawngroup id="blue"> <spawnpoint id="spawnpoint_5" posX="2733.4184570313" posY="2753.1276855469" posZ="10.8203125" rot="90" skin="124"/> <spawnpoint id="spawnpoint_6" posX="2733.5258789063" posY="2748.1110839844" posZ="10.8203125" rot="90" skin="125"/> </spawngroup>
This function determines a spawnpoint's parent element, and announces its ID:
function spawnpointUse ( player ) -- this function gets called whenever a spawnpoint is used theSpawnGroup = getElementParent ( source ) -- get the spawnpoint's parent element -- announce the parent's ID and the player who spawned there: outputChatBox ( getClientName ( player ) .. " spawned at team " .. getElementID ( theSpawnGroup ) .. "'s spawnpoint." ) -- Example output: "Joe spawned at team blue's spawnpoint." end addEventHandler ( "onSpawnpointUse", getRootElement (), spawnpointUse )
See Also
- attachElements
- createElement
- destroyElement
- detachElements
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementByIndex
- getElementByID
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getAllElementData
- hasElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementType
- getElementVelocity
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementWithinColShape
- isElementWithinMarker
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementVelocity
- setLowLODElement
- getPedContactElement
- getResourceDynamicElementRoot
- getResourceRootElement