Page 1 of 1

Getclone problem

PostPosted: Sun Aug 21, 2011 2:26 pm
by foleyjo
Hey all

Just having a bit of a problem using the get clone feature.

What I'm trying to do : At the end of a level a well done message appears and then after a while the next level starts.
When the end of level message appears all the actors on the screen have their events disabled
This includes an actor called Fan which has many clones .

How Im trying to do it:

Code: Select all
int Fans;
int i;
Fans = ActorCount("Fan");
for (i=0; i<Fans; i++)
 { EventDisable(getclone 2("Fan",i)->clonename, EVENTALL);}


Why I think it's not working : Because with the events that are happening through the level the first fans clone index may not be 0 and they all may not be indexed in a 0 to x kind of way. (eg:jumping from 4 to 6 to 8 rather than 4 5 and 6)

My Question : How would I get around this?

Re: Getclone problem

PostPosted: Sun Aug 21, 2011 4:25 pm
by lcl
Create integer topIndex and do this:
Fan - Create actor - Scriot editor:
Code: Select all
if (cloneindex > topIndex)
{
    topIndex = cloneindex;
}

And destroy actor - script editor:
Code: Select all
int i, temp = 0;
if (cloneindex == topIndex)
{
    for(i = 0; i < topIndex; i ++;)
    {
        if (strcmp(getclone2("Fan", i)->clonename, "") != 0){temp = i;}
    }

    topIndex = temp;
}

And now use topIndex instead of ActorCount();
Tell me if this doesn't work for some reason.

Re: Getclone problem

PostPosted: Sun Aug 21, 2011 4:47 pm
by Game A Gogo
lcl wrote:
Code: Select all
if (cloneindex > topIndex)
{
    topIndex = cloneindex;
}

can be replaced with this line:
Code: Select all
topIndex=max(cloneindex,topIndex);


Don't get me wrong, I just want to improve your code :)

Re: Getclone problem

PostPosted: Sun Aug 21, 2011 5:12 pm
by lcl
Game A Gogo wrote:
lcl wrote:
Code: Select all
if (cloneindex > topIndex)
{
    topIndex = cloneindex;
}

can be replaced with this line:
Code: Select all
topIndex=max(cloneindex,topIndex);


Don't get me wrong, I just want to improve your code :)

:D that's smart!

Re: Getclone problem (Solved)

PostPosted: Sun Aug 21, 2011 5:21 pm
by foleyjo
didn't work lcl .

Actually it probably did work but I haven't done it correctly.

So I have created the topindex integer (as global is this correct) and added your code into the fan create and destroy bits like instructed.

Then in the create actor script of the "well done" message I have

Code: Select all
for (i=0; i<=ITopIndex; i++)  //note I have changed topindex to ITopIndex this is the same in the other parts of the code.
{
  EventDisable(getclone2("Fan",i)->clonename, EVENTALL);
}



UPDATE ---I changed the EventDisable command to a destroy actor and it worked.
While typing this update I have just realised the mistake I have been making

The fans were awkward to pick up and move due to the image having holes in it. So I created an invisible actor for fan selection. When I've been trying the code I have been disabling the fans events. However the fan does not have any events.
So I think it should work now I am applying it to the correct actor. Thanks for the help

UPDATE 2 --yup that was it