Page 1 of 1
Clones to check their number
Posted:
Tue Jul 24, 2007 5:24 pm
by d-soldier
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
}
Posted:
Tue Jul 24, 2007 9:50 pm
by metal_pt
Use cloneindex
Posted:
Tue Jul 24, 2007 9:58 pm
by d-soldier
Show me it as in the example script above.
Posted:
Tue Jul 24, 2007 10:00 pm
by metal_pt
Here you go:
- Code: Select all
if (cloneindex==1)
{
do this
}
else
if (cloneindex==2)
{
do this
}
Posted:
Tue Jul 24, 2007 10:02 pm
by d-soldier
Nice... +1 for you. I'll check this after work.
Posted:
Tue Jul 24, 2007 10:05 pm
by metal_pt
Thanks.
Have a nice day at work
Posted:
Wed Aug 01, 2007 1:36 am
by d-soldier
Works like a charm, starting with cloneid being 0 of course.
Posted:
Mon Aug 13, 2007 7:56 am
by d-soldier
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....
Posted:
Mon Aug 13, 2007 2:01 pm
by Troodon
I think if you delete cloneindex 1,2 and 3 and create new ones, they will be named 4,5 and 6.
Posted:
Mon Aug 13, 2007 11:08 pm
by d-soldier
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?
Posted:
Tue Aug 14, 2007 1:06 am
by makslane
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.
Posted:
Tue Aug 14, 2007 2:41 am
by d-soldier
Ahhh.. I see. So If there are none, it will be zero again, like I thought... thanks for breaking it down.
Posted:
Tue Aug 14, 2007 4:03 am
by DilloDude
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
}