Page 1 of 1

Cloneindex Problem

PostPosted: Tue Apr 24, 2012 1:06 pm
by tzoli
Hi. I have a little problem with the cloneindex.
What is the correct form of this?:
Code: Select all
    int i;
    i=cloneindex-1;
    block.i.type=0;


and this:
Code: Select all
    int i;
    i=cloneindex-1;
    if(block.i.type==0){
    ...
    }

Re: Cloneindex Problem

PostPosted: Tue Apr 24, 2012 4:31 pm
by Game A Gogo
instead of having block.i.type (Since the compiler in GE doesn't like that for some reason)

you'll need to use the GetClone function

Code: Select all
Actor tactor;//Temporary actor
int i;
char temp[256];//Temporary string holder
i=cloneindex-1;
sprintf(temp,"block.%d",i);
tactor=getclone(temp);//getclone returns a pointer to the mentioned actor.
//A pointer is a variable that points to a space in memory, in this case, tarctor will point to "block.i"
tactor->type=0;
//When dealing with pointer variables, you need to use the point-to (->) and not the .


Code: Select all
Actor tactor;
int i;
char temp[256];
i=cloneindex-1;
sprintf(temp,"block.%d",i);
tactor=getclone(temp);
if(tactor->type==0)
{
    //do something :)
}


if you need help with some explanation, just ask!

Re: Cloneindex Problem

PostPosted: Tue Apr 24, 2012 5:30 pm
by tzoli
Thanks! :D Now it will be easier to change variables between a lot of actors. I gave a +