GetComponent

Category: Objects / Components
Since engine version: 4.6.5.0 CP

Description

Used to determine object components.

Syntax

int / id GetComponent (id idComponent, int iIndex, object pObj, id idDef);

Parameters

idComponent:
[opt] Object component of which to determine the count. If not specified, iIndex is used and the id of the component is returned.
iIndex:
[opt] Index of the component to be returned. This parameter is ignored if idComponent is specified. Returns the id of the indicated component which can then be used to determine the count in a subsequent call to GetComponent.
pObj:
[opt] Object of which to determine components. Can be 0 in local calls. If idDef is specified, this parameter is ignored.
idDef:
[opt] Definition of which to determine components. If 0, the specified object is checked instead.

Example

var i,cid,num;
while (id = GetComponent(0, i++, 0, GetID()))
	if ((num = GetComponent(id) - GetComponent(id, 0, 0, GetID())) > 0)
		while (num--) CreateObject(id, 0, 0, GetOwner());
Creates all components which are still missing in the calling object (e.g. in a construction site) in front of the object.
See also: SetComponent, Split2Components
Cucaracha, Mai 2002