Page 1 of 1

problems with cloning codes

PostPosted: Fri Nov 13, 2009 9:00 pm
by Fojam
ok, so I have clones for a few actors, but when I write code for the clones, it says there are errors... can someone help me?

Code: Select all
medium_ant_down.yvelocity = medium_ant_down.yvelocity - 3;
medium_ant_left.xvelocity = medium_ant_left.xvelocity + 3;
medium_ant_right.xvelocity = medium_ant_right.xvelocity - 3;
medium_ant_up.yvelocity = medium_ant_up.yvelocity + 3;
small_ant_down.yvelocity = small_ant_down.yvelocity - 3;
small_ant_down.1.yvelocity = small_ant_down.1.yvelocity -3;
small_ant_down.2.yvelocity = small_ant_down.2.yvelocity -3;
small_ant_left.xvelocity = small_ant_left.xvelocity + 3;
small_ant_left.1.xvelocity = small_ant_left.1.xvelocity + 3;
small_ant_right.xvelocity = small_ant_right.xvelocity - 3;
small_ant_right.1.xvelocity = small_ant_right.1.xvelocity - 3;
small_ant_right.2.xvelocity = small_ant_right.2.xvelocity - 3;
small_ant_up.yvelocity = small_ant_up.yvelocity + 3;
small_ant_up.1.yvelocity = small_ant_up.1.yvelocity + 3;
small_ant_up.2.yvelocity = small_ant_up.2.yvelocity + 3;
small_ant_up.3.yvelocity = small_ant_up.3.yvelocity + 3;
small_ant_up.4.yvelocity = small_ant_up.4.yvelocity + 3;



I want the main actor's clones to do exactly what it does. I'm not sure what is wrong... according to the code, it should work.
The error says that there is an error on every line of code that uses one of the clones. it says there is an expected ; but I already have one.

can someone help me?

Re: problems with cloning codes

PostPosted: Fri Nov 13, 2009 9:53 pm
by jimmynewguy
i'm sure there's a way to do this with arrays, but i really don't understand them :lol: the easiest way and the way i would do is to use switch. It's kind of like a whole bunch of if(==) without typing it each time, since actor.cloneindex.variable doesn't work
Code: Select all
switch(cloneindex)//each case is the cloneindex
{
case 0: xvelocity=-3;//kind of like if(cloneindex==0){
break;//end the if. kind of like the ending bracket or }
}


you'd have to do this with each different actor if you get what I'm saying, since you have different kinds of actors. or just have an event on the actor that changes it's yvelocity instead of using it's name.

Re: problems with cloning codes

PostPosted: Sat Nov 14, 2009 8:02 am
by skydereign
The problem with your code is that you can't do something like this.
Code: Select all
actorname.actorcloneindex.actorvariable;

Pretty much you can't get a clone, using dot, and then use another dot to specify with actor variable. You would need to use something like getCloneIdx. If you are using an Actor*, then you can do things with clone specific actor variables.
Code: Select all
Actor* currentclone = getclone("medium_ant_down.1");
// This gets your clone, allowing for direct access to the variables such as yvelocity
currentclone->yvelocity=currentclone->yvelocity + 3;


This is just a small example of Actor*, if you do want me to explain this than I can, but you might be able to use jimmynewguy's suggestion. The explanation I showed here was just to explain the concept, it is not the most optimal given your circumstance. Also it seems you can use parenting, I don't know exactly what you are trying to do... Anyways, I would be glad to help out if need be.

Re: problems with cloning codes

PostPosted: Sun Nov 15, 2009 10:12 pm
by Fojam
do you think that you can get makslane to change that? it is kind of annoying.

Re: problems with cloning codes

PostPosted: Mon Nov 16, 2009 4:54 am
by skydereign
Well that is a problem with C/C++ in general then, as actor variables are pretty much C++, it may be possible, but it would get really weird in coding. Not sure how you would do it cleanly, I guess if it ever sees a actorname.cloneindex.actorvariable, it could find the way, but you can also write a function that does it for you. Most of the time if there is a custom function that you can write, then it is better to do that... If you want, I can post a similar working function.