Page 1 of 1

clone index question

PostPosted: Sat Apr 16, 2011 12:55 pm
by savvy
ok, so im trying to make it so that the view moves to a specific actor depending on its clone index. (short level transfer thing)
i have this so far, according to GE documentation...
Code: Select all
int i = level; //level is the level variable
Actor*getclone(char*levelindicator);
x=levelindicator[i].x;

im trying different things... if i get it right ill post so here, and show what i put.

please help

savvy

Re: clone index question

PostPosted: Sat Apr 16, 2011 5:15 pm
by DarkParadox
Well, as it's my habit, I always use cloneID [by Feral] when working with clones (put in global code, save it):
Code: Select all
char buffer[50];
char * cloneID(const char *cname, short unsigned int cindex)
{
    sprintf(buffer, "%s.%d", cname, cindex);
    return buffer;
}


And use this code:
Code: Select all
// We don't need "i" anymore, just use level directly
x=getclone(cloneID("levelindicator", level))->x;
// See here, get clone lets us get a variable from a clone, and cloneID sets the name for us.
// The "->" is required instead of a "." when using getclone, and the X is retrieved.


Hope this helps, (^↽^)

Re: clone index question

PostPosted: Sun Apr 17, 2011 1:24 pm
by savvy
thanks a bunch dark ;) 1up for you

Re: clone index question

PostPosted: Sun Apr 17, 2011 10:33 pm
by lcl
Btw dark, here's more easy to use function for checking clones by index.
Code: Select all
char ACTOR[50];

Actor * getClone2(char NAME[50], int NUM)
{
    sprintf(ACTOR, "%s.%i", NAME, NUM);
    return getclone(ACTOR);
}


Example:
Code: Select all
getClone2("myActor", 5)->x = 10;


I don't remember who made this one originally, but I use it. :)