Page 1 of 1

actor.cloneindex.animpos

PostPosted: Tue Jul 21, 2009 5:09 am
by Oman
Here's a question ive had for a long time.

If i wanted to write
Code: Select all
textNumber = player.1.animpos

Where my text actor (000 obviously would be its current text) would show player.1's animpos. This current code doesnt work.

How would i do this?

Re: actor.cloneindex.animpos

PostPosted: Tue Jul 21, 2009 5:26 am
by skydereign
You would need to get the Actor * first. Try this.

Put this in GobalCode
Code: Select all
Actor *
getCloneIdx (const char *cname, int cindex)    //g_GetCloneByIndex, its original name
{
    char buffer[50];
    sprintf(buffer,"%s.%i",cname,cindex);
    return(getclone(buffer));
}


Then to do what you want, it would look like this.

Code: Select all
Actor * PLAYER = getCloneIdx(player, 1);
textNumber=PLAYER->animpos;


What this does is declare an Actor *. It combines the name, first variable, with the desired clone, second variable. Then it returns the Actor *, allowing you to get the animpos.

Re: actor.cloneindex.animpos

PostPosted: Tue Jul 21, 2009 6:26 pm
by Oman
does
Code: Select all
getclone("actorname.1")->variable

work aswell?

It seems to. I just stumbledupon it at ,http://game-editor.com/forum/viewtopic.php?f=6&t=5397

Re: actor.cloneindex.animpos

PostPosted: Tue Jul 21, 2009 7:26 pm
by Oman
I attempted to do what i wanted your way and recieved the error shown in the picture below. Am i doing anything wrong?
i simply copy and pasted your code. Did i need to replace anything?

Image

Re: actor.cloneindex.animpos

PostPosted: Tue Jul 21, 2009 9:10 pm
by skydereign
Sorry about that, it was a typo, kind of. It should be like this...

Code: Select all
Actor * PLAYER = getCloneIdx(player.name, 1);
textNumber=PLAYER->animpos;


I think your method would work, this just makes it easier if you are doing this for clones. I didn't know your setup, so I defaulted to this. It is more versatile, but the other method should work.

Re: actor.cloneindex.animpos

PostPosted: Wed Jul 22, 2009 2:39 am
by Oman
Ahh ok, im currently using the one liner (mine) but if yours work (im assuming it does) then we have an embarrassment of riches! yay! lolz thx for the help!