Accessing Actors Dynamically

Questions, comments and discussion about the Game Editor development.

Accessing Actors Dynamically

Postby bamby1983 » Thu Feb 21, 2013 3:17 am

I have a scenario where I store the cloneid of an actor in a variable and then later need to use this value to check the animindex of this first actor. This check is done when I click on another actor with clones, so unless I'm mistaken, getClone won't work here.

I can use sprintf to get the exact actor name (including the cloneindex within it) into a character string, but how do I use this character string to check the animindex of the actor. I can't use the dot operator as it would try to check the animindex property of the strong and not the actor itself, which throws an error.

Would anyone please be able to let me know whether there is a way by which I can find the animindex of an actor using the above string?
bamby1983
 
Posts: 112
Joined: Tue Jul 31, 2012 11:36 pm
Score: 8 Give a positive score

Re: Accessing Actors Dynamically

Postby skydereign » Thu Feb 21, 2013 3:42 am

getclone can use clonenames. And clonename is the name of the actor with the cloneindex attached. So you can use getclone.
Code: Select all
char buffer[30];
int index = 5;
int a_index = -1;
sprintf(buffer, "someactor.%d", index);
a_index = getclone(buffer)->animindex;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Accessing Actors Dynamically

Postby bamby1983 » Thu Feb 21, 2013 3:46 am

Thanks Sky! You are awesome!
bamby1983
 
Posts: 112
Joined: Tue Jul 31, 2012 11:36 pm
Score: 8 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest