Page 1 of 1

How do I declare a pointer of type Actor locally?

PostPosted: Mon Jan 21, 2008 11:29 pm
by yttermayn
How do I declare a pointer of type Actor locally? I want an actor to be able to store a pointer to another actor it created, locally.

Thanks!

Re: How do I declare a pointer of type Actor locally?

PostPosted: Tue Jan 22, 2008 1:09 am
by makslane
Use the return value of the CreateActor action:

Code: Select all
Actor *myactor = CreateActor(...);

Re: How do I declare a pointer of type Actor locally?

PostPosted: Tue Jan 22, 2008 1:22 am
by DilloDude
If you want to store an actor as an actor variable, you have to use some other kind of variable. Strings work well. Just store the actor's clonename:
Code: Select all
Actor *actor = CreateActor(...
//stuff with actor
strcpy(string, actor->clonename);

Then use getclone to turn it back into an actor:
Code: Select all
Actor *actor = getclone(string);
//stuff with actor

Re: How do I declare a pointer of type Actor locally?

PostPosted: Tue Jan 22, 2008 4:44 am
by yttermayn
Actor *actor = CreateActor(...

Dosn't the above have to go into a global code area? That's the only place I've been able to get a string declaration to work. If that's the case, it's no good - the createactor() is executed by another created actor's "create actor" event script, which won't let me use the line as shown above. Maybe I should just say what I'm doing and ask how you would do it:

My view -> draw actor script at some point creates a zombie actor. The new zombie actor creates a text actor to display hit points above its head in the zombie -> create actor script.

What is the easiest way to do this? Maybe I've just been looking at it all wrong...

Re: How do I declare a pointer of type Actor locally?

PostPosted: Fri Jan 25, 2008 3:42 pm
by yttermayn
Allright! Thanks, Dillodude. Once I figured out another problem, your method worked out nicely. Points for you!