Clones to check their number

Game Editor comments and discussion.

Clones to check their number

Postby d-soldier » Tue Jul 24, 2007 5:24 pm

How would I script an actor to check it's clone id (.1, .2, etc.) in reference to what it's supposed to do in it's draw acytor script? Something like:

if (cloneid==.1)
{
do this
}
else if (cloneid==.2)
{
do this
}
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby metal_pt » Tue Jul 24, 2007 9:50 pm

Use cloneindex :)
]v[eta[_ - Using GE since June, 15 2007
Currently using v1.3.8 Registered
metal_pt
 
Posts: 117
Joined: Sat Jun 16, 2007 12:57 pm
Location: Sintra, Portugal
Score: 2 Give a positive score

Postby d-soldier » Tue Jul 24, 2007 9:58 pm

Show me it as in the example script above.
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby metal_pt » Tue Jul 24, 2007 10:00 pm

Here you go:

Code: Select all
if (cloneindex==1)
{
    do this
}
else
    if (cloneindex==2)
    {
        do this
    }
]v[eta[_ - Using GE since June, 15 2007
Currently using v1.3.8 Registered
metal_pt
 
Posts: 117
Joined: Sat Jun 16, 2007 12:57 pm
Location: Sintra, Portugal
Score: 2 Give a positive score

Postby d-soldier » Tue Jul 24, 2007 10:02 pm

Nice... +1 for you. I'll check this after work.
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby metal_pt » Tue Jul 24, 2007 10:05 pm

Thanks.

Have a nice day at work :)
]v[eta[_ - Using GE since June, 15 2007
Currently using v1.3.8 Registered
metal_pt
 
Posts: 117
Joined: Sat Jun 16, 2007 12:57 pm
Location: Sintra, Portugal
Score: 2 Give a positive score

Postby d-soldier » Wed Aug 01, 2007 1:36 am

Works like a charm, starting with cloneid being 0 of course.
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby d-soldier » Mon Aug 13, 2007 7:56 am

If you destroy the first three clones of an actor (.0,.1,.2) then the next time the actor is created, it should be .0 again, right? I've got a variable making sure that one actor doesn't exceed three clones at a time, and all those numbers are scripted on what to do in their draw-actor event based on their cloneindex, but after I destroy them, the next batch do nothing when created....
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby Troodon » Mon Aug 13, 2007 2:01 pm

I think if you delete cloneindex 1,2 and 3 and create new ones, they will be named 4,5 and 6.
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby d-soldier » Mon Aug 13, 2007 11:08 pm

The strange thing is, I have a different actor which's draw-actor event is set the same way (cloneindex.1 does this, .2 does something else, .3 is over here, etc.) and it works great... even after the first several are destroyed, the next one to be created has followed the .0 scripting... so I assumed that if only one actor is currently active, it is always .0, regardless of how many came before it... Is this not the case, someone who knows for sure?
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby makslane » Tue Aug 14, 2007 1:06 am

The next clone number will be the max current clone number + 1.
So, if you have the actors 5, 6, 20, the next will be the 21.
Now, if the 21 and 20 are destroyed, the next will be 7.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby d-soldier » Tue Aug 14, 2007 2:41 am

Ahhh.. I see. So If there are none, it will be zero again, like I thought... thanks for breaking it down.
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby DilloDude » Tue Aug 14, 2007 4:03 am

I find the best way to keep track of clones is to store their clonenames in an array. Also keep a variable that is the number of them. Use an actor integer so each one knows its spot in the array. When yuo create a new one, use:
Code: Select all
spot = count;
strcpy(array[count], clonename);
count ++;

When one is destroyed, use:
Code: Select all
count --;
strcpy(array[spot], array[count]);

When you want to cycle through them, use:
Code: Select all
int i;
for (i = 0; i < count; i ++)
{
    Actor *AC = getclone(array[i]);
    //do stuff
}
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron