This can be done in several ways, but before that, your original problem can be solved by this (among others).
- Code: Select all
CreateActor("ratLegL", "ratLegLeft", "(none)", "(none)", 0, 0, false);
ChangeParent("Event Actor", ratLegL.clonename);
Reason being while CreateActor returns the created actor (can be very useful by the way), it also sets the default actor actorName to the last created actor. So using ratLegL.clonename will guarantee that it was the actor created in the first line. That might have made less sense than I intended it to.
Anyway, moving on to your other problem, if you declare a variable in a script event, it is a local variable. That is to say, if you declare one in the Create Actor event, it won't exist in the draw. Now, if you possibly can, you want to use creator or parent, but that won't always work. Therefore you will need to use a getclone type function, and store an index. For example, if you want a leg actor, create an actor variable, legIndex.
- Code: Select all
legIndex = CreateActor("ratLegL", "ratLegLeft", "(none)", "(none)", 0, 0, false)->cloneindex;
ChangeParent("Event Actor", ratLegL.clonename);
That way you store the cloneindex so you can use a getclone2 function to retrieve the Actor* that you were trying to use in draw.
- Code: Select all
Actor* theleg = getCloneIdx("ratLegL", legIndex);
theleg->x= blabla;