GetElementID: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
Line 24: | Line 24: | ||
idstring = getElementID ( flag ) -- get the id of the flag element | idstring = getElementID ( flag ) -- get the id of the flag element | ||
outputChatBox ( "The flag's ID is: " .. idstring ) -- output: The flag's ID is: northflag | outputChatBox ( "The flag's ID is: " .. idstring ) -- output: The flag's ID is: northflag | ||
</syntaxhighlight> | |||
Another ex; | |||
<syntaxhighlight lang="lua"> | |||
local obj = createObject(971, 0, 0, 3) | |||
setElementID(obj, 'testObj') | |||
idstring = getElementID ( obj ) -- get the id of the object | |||
outputChatBox ( "The obket's ID is: " .. idstring ) -- output: The object ID is: testObj | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 12:05, 2 June 2025
This function gets the ID of an element. This is the "id" attribute of the element and is a string, NOT a number like a model ID, weapons ID or similar.
Syntax
string getElementID ( element theElement )
OOP Syntax Help! I don't understand this!
- Method: element:getID(...)
- Variable: .id
- Counterpart: setElementID
Required Arguments
- theElement: the element from which to retrieve the ID.
Returns
This returns a string containing the element ID. It will return an empty string if it has no ID. It will return false if the element is invalid.
Example
To get the ID of the following element:
<flag id="northflag" posX="2365" posY="215" posZ="32" />
You could use the following code:
-- assume flag refers to the flag element in the above XML code idstring = getElementID ( flag ) -- get the id of the flag element outputChatBox ( "The flag's ID is: " .. idstring ) -- output: The flag's ID is: northflag
Another ex;
local obj = createObject(971, 0, 0, 3) setElementID(obj, 'testObj') idstring = getElementID ( obj ) -- get the id of the object outputChatBox ( "The obket's ID is: " .. idstring ) -- output: The object ID is: testObj
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