Game Development Community

Confusion about how CopySource operates

by Michael Rogers · in Torque Game Engine · 07/07/2005 (12:04 pm) · 1 replies

I have the following code, and I don't understand why anotherMovieObject isn't getting the myFavoriteShow field from movieObject:

$movieObject = new SimObject(){
		myFavoriteShow = "Toy Story II"; // a dynamic field in movieObject
};
	
$anotherMovieObject = new SimObject(freddie :  movieObject){ 
		myFavoriteAuthor = "Arthur Connon Doyle";
};

	
echo("1" SPC $movieObject.myFavoriteShow);
echo("2" SPC $movieObject.myFavoriteAuthor); // shouldn't exist
echo("3" SPC $anotherMovieObject.myFavoriteShow);  // doesn't print because ???
echo("4" SPC $anotherMovieObject.myFavoriteAuthor); // should display ACD

Shouldn't $anotherMovieObject acquire all of the dynamic fields, such as myFavoriteShow?

Thanks for any insights,

Michael

#1
07/07/2005 (6:40 pm)
To answer my own question, the problem was how I specified the CopySource.

The item following the : in new SimObject ( : ) must be the name of an object. So, this fixes my problem:

$movieObject = new SimObject(anderson){
myFavoriteShow = "Toy Story II"; // a dynamic field in movieObject
};

$anotherMovieObject = new SimObject(freddie : anderson){
myFavoriteAuthor = "Arthur Connon Doyle";
};

All praise to Joel Baxter, who's brilliant 2002 tutorial helped me understand this.

Michael