detachElements
Client-side
Server-side
Shared
Pair: attachElements
This function detaches attached elements from one another.
OOP Syntax Help! I don't understand this!
- Method:element:detach(...)
Syntax
bool detachElements ( element theElement, [ element theAttachToElement = nil ] )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.
- theAttachToElement (default: nil): The element you wish to detach from, will detach from the attached element if this isn't specified.
Returns
- bool: result
Returns true if the detaching was successful, false otherwise.
Code Examples
shared
This example attaches a marker to a vehicle, and detaches it when it blows up.
function attachMarkerToVehicle(theVehicle) -- create the marker to attach local arrowMarker = createMarker(0, 0, 0, "arrow", 1.5, 0, 0, 255, 255) -- attach the marker above the vehicle attachElements(arrowMarker, theVehicle, 0, 0, 2) -- add an event handler for when the vehicle blows up addEventHandler("onVehicleExplode", theVehicle, onMarkedCarExplode)end
function onMarkedCarExplode() -- get the elements attached to the vehicle local attachedElements = getAttachedElements(source) -- loop through the table of elements for i, v in ipairs(attachedElements) do -- detach the element from the vehicle detachElements(v, source) end -- remove the event handler removeEventHandler("onVehicleExplode", source, onMarkedCarExplode)endSee Also
Element Functions
- addElementDataSubscriber
- attachElements
- clearElementVisibleTo
- cloneElement
- createElement
- destroyElement
- detachElements
- getAllElementDataUpdated
- getAttachedElements
- getElementAlpha
- getElementAngularVelocity
- getElementAttachedOffsets
- getElementAttachedTo
- getElementBonePosition
- getElementBoneQuaternionNew
- getElementBoneRotation
- getElementBoundingBox
- getElementByID
- getElementByIndex
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getElementDimension
- getElementDistanceFromCentreOfMassToBaseOfModel
- getElementHealth
- getElementID
- getElementInterior
- getElementLighting
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRadius
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementSyncer
- getElementType
- getElementVelocity
- getElementZoneName
- getLowLODElement
- getRootElement
- hasElementData
- hasElementDataSubscriber
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementCollidableWith
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLocal
- isElementLowLOD
- isElementOnFireNew
- isElementOnScreen
- isElementStreamable
- isElementStreamedIn
- isElementSyncer
- isElementVisibleTo
- isElementWaitingForGroundToLoad
- isElementWithinColShape
- isElementWithinMarker
- removeElementData
- removeElementDataSubscriber
- setElementAlpha
- setElementAngularVelocity
- setElementAttachedOffsets
- setElementBonePosition
- setElementBoneQuaternionNew
- setElementBoneRotation
- setElementCallPropagationEnabled
- setElementCollidableWith
- setElementCollisionsEnabled
- setElementDataUpdated
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementLightingNew
- setElementMatrix
- setElementModel
- setElementOnFireNew
- setElementParent
- setElementPosition
- setElementRotation
- setElementStreamable
- setElementSyncer
- setElementVelocity
- setElementVisibleTo
- setLowLODElement
- updateElementRpHAnim
Element Events
- onClientElementColShapeHit
- onClientElementColShapeLeave
- onClientElementDataChange
- onClientElementDestroy
- onClientElementDimensionChange
- onClientElementInteriorChange
- onClientElementModelChange
- onClientElementStreamIn
- onClientElementStreamOut
- onElementClicked
- onElementColShapeHit
- onElementColShapeLeave
- onElementDataChange
- onElementDestroy
- onElementDimensionChange
- onElementInteriorChange
- onElementModelChange
- onElementStartSync
- onElementStopSync