Getclone problem

Non-platform specific questions.

Getclone problem

Postby foleyjo » Sun Aug 21, 2011 2:26 pm

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?
KISS -Keep It Simple Stoopid
foleyjo
 
Posts: 275
Joined: Mon Jul 09, 2007 1:15 pm
Score: 15 Give a positive score

Re: Getclone problem

Postby lcl » Sun Aug 21, 2011 4:25 pm

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.
Last edited by lcl on Sun Aug 21, 2011 4:50 pm, edited 2 times in total.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Getclone problem

Postby Game A Gogo » Sun Aug 21, 2011 4:47 pm

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 :)
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Getclone problem

Postby lcl » Sun Aug 21, 2011 5:12 pm

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!
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Getclone problem (Solved)

Postby foleyjo » Sun Aug 21, 2011 5:21 pm

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
KISS -Keep It Simple Stoopid
foleyjo
 
Posts: 275
Joined: Mon Jul 09, 2007 1:15 pm
Score: 15 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest