Addressing Other Instances

Their are two ways to adress other objects. The first way is adressing by object type. This method uses the syntax "obj.dot varName" and gives unresticted acsess to first instance of an object if one exists.

//in GameMaker language

{

	player.time=6;

	player.x=0;

}



//in CPlusPlusTranslator

{

	player.dot time=6;

	player.dot x=0;

}

The second way is to adress an object by id. The fastest way to adress by id is to use the keyword "ID(id)", but this keyword only gives acsess to the object's built in varibles. If you want acsess to the user defined variables as well you will have to know the object type of the object you are adressing and use the keyword "OBJ_ID(id,obj)".

//in GameMaker language

{

	var otherID=instance_nearest(x,y,all).id;

	(otherID).x=0;

	(otherID).time=6;

}



//in CPlusPlusTranslator

{

	//if you do not know the object type

	{

		var otherID=instance_nearest(x,y,all).id;

		ID(otherID).x=0;

	}

	

	//if you know the object type

	{

		var otherID=instance_nearest(x,y,otherObject).id;

		OBJ_ID(otherID,otherObject).x=0;

		OBJ_ID(otherID,otherObject).time=6;

	}

}