SetElementParent: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
{{Important Note|The client-side version of this function can only be used on client-created elements. It cannot be used to modify the parent of server side elements.}} | {{Important Note|The client-side version of this function can only be used on client-created elements. It cannot be used to modify the parent of server side elements.}} | ||
{{Note|This function does not change when an element will be destroyed - Elements are always destroyed when the resource that created them is stopped.}} | {{Note|This function does not change when an element will be destroyed - Elements are always destroyed when the resource that created them is stopped.}} | ||
{{Note|When an element is destroyed, its parent becomes the new parent of its children. | {{Note|When an element is destroyed, its parent becomes the new parent of its children.}} | ||
{{Note|setElementParent only works new parent is the root element, or if ancestor is map root}} | |||
{{Tip|This function does not affect the child elements position. To attach elements use the function [[attachElements]].}} | {{Tip|This function does not affect the child elements position. To attach elements use the function [[attachElements]].}} | ||
==Syntax== | ==Syntax== |
Revision as of 21:42, 10 December 2013
This function is used for setting an element as the parent of another element.
Important Note: The client-side version of this function can only be used on client-created elements. It cannot be used to modify the parent of server side elements. |
Tip: This function does not affect the child elements position. To attach elements use the function attachElements. |
Syntax
bool setElementParent ( element theElement, element parent )
Required Arguments
- theElement: The element that you wish to set the parent of.
- parent: The element you wish to be the parent of theElement.
Returns
Returns true if both elements are valid, false otherwise.
Example
Click to collapse [-]
ServerThis example sets the parent of each spawnpoint to a dummy element:
dummyElem = createElement ( "spawngroup", "Group of spawn points" ) -- create a dummy element local spawnpoints = getElementsByType ( "spawnpoint" ) -- get a table of spawn point elements for k,v in spawnpoints do -- loop through the table of spawn points setElementParent ( v, dummyElem ) -- set the dummy element as the parent of the spawn point end -- all of the spawn points are now children of 'dummyElem'
This is the equivalent of:
<spawngroup id="Group of spawn points"> <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"/> <spawnpoint id="spawnpoint_3" posX="2510.6899414063" posY="2778.3745117188" posZ="10.8203125" rot="270" skin="285"/> </spawngroup>
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