actor.cloneindex.animpos

Game Editor comments and discussion.

actor.cloneindex.animpos

Postby Oman » Tue Jul 21, 2009 5:09 am

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?
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

Re: actor.cloneindex.animpos

Postby skydereign » Tue Jul 21, 2009 5:26 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: actor.cloneindex.animpos

Postby Oman » Tue Jul 21, 2009 6:26 pm

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
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

Re: actor.cloneindex.animpos

Postby Oman » Tue Jul 21, 2009 7:26 pm

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
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

Re: actor.cloneindex.animpos

Postby skydereign » Tue Jul 21, 2009 9:10 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: actor.cloneindex.animpos

Postby Oman » Wed Jul 22, 2009 2:39 am

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!
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron