Create Actor Question

Game Editor comments and discussion.

Create Actor Question

Postby MiG3 » Sun Oct 02, 2005 8:28 pm

I have an actor that creates another actor, with this code:

CreateActor("Scroll", "icon", "no parent", "no path", -718, -41, true);

How can I give this new instance certain values? What I want to do, like I do in Game Maker, is this:

aa=CreateActor(...);
aa.variable=value;

I just want to affect this instance of the actor, not all of them, so I can't use Scroll's CreateActor event.

Thanks,
MiG3
MiG3
 
Posts: 12
Joined: Sat Oct 01, 2005 8:34 pm
Score: 0 Give a positive score

Postby makslane » Mon Oct 03, 2005 1:30 am

Try this:

Actor *newactor = CreateActor("Scroll", "icon", "no parent", "no path", -718, -41, true);

newactor->yourvariable = value;
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby MiG3 » Mon Oct 03, 2005 2:21 pm

As soon as I put the actor declaration thing down, I got an error

Scroll_Effects[0]=0;

Actor *newactor = CreateActor("Scroll", "icon", "no parent", "no path", -718, -41, true);


Error: Unexpected declaration Scroll_Effects.

I got another error for

newactor.name = Scroll_Names[0];

Error: Illegal structure operation

Why is it saying that?

MiG3
MiG3
 
Posts: 12
Joined: Sat Oct 01, 2005 8:34 pm
Score: 0 Give a positive score

Postby makslane » Tue Oct 04, 2005 2:18 am

Error: Unexpected declaration Scroll_Effects.


What is "Scroll_Effects"? is a string array?


newactor.name


newactor is a pointer, so, you must refer the mebers with '->' not '.'

newactor->name

And...

To copy a string you need use the strcpy function:

strcpy(string, "hello!");

Other problem, the actor's name is a read only variable, so, you can't change.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby MiG3 » Tue Oct 04, 2005 8:59 pm

What is "Scroll_Effects"? is a string array?


Yes, it is. Don't see how it affects anything but yes. It worked fine before I had that declaration that came after it.

strcpy(string, "hello!");


That doesn't help very much. K. Look. He said

Actor *newactor = CreateActor("Scroll", "icon", "no parent", "no path", -718, -41, true);


Now, how do I use that whilst using strcpy? I need an example, because it doesn't make sense without one.

Thirdly, I tried this:

newactor->fire=1;


But alas, it decreed an

Error: Illegal Structure Operation.

This might have to do with the fact that the Actor *newactor command isn't working, and newactor isn't pointing yet, but just to make sure it's right, I'm posting it here.

MiG3
MiG3
 
Posts: 12
Joined: Sat Oct 01, 2005 8:34 pm
Score: 0 Give a positive score

Postby makslane » Tue Oct 04, 2005 10:16 pm

Is the fire variable an actor or global variable?
To works must be a actor variable.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby MiG3 » Tue Oct 04, 2005 11:31 pm

It's an actor, and that line works now. I still don't know how to do the create actor thing though.

Could you post an example of the create actor thing?
MiG3
 
Posts: 12
Joined: Sat Oct 01, 2005 8:34 pm
Score: 0 Give a positive score

Postby makslane » Wed Oct 05, 2005 1:49 pm

Can you send me your game?
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby MiG3 » Wed Oct 05, 2005 9:49 pm

For some reason the computer I have the game on won't connect to this website at all. It keeps sending me to http://www.game-editor.com:19638/webhost/rollout/site.

Could you just type an example on how to create an actor, and change one of those actor's variables?

MiG3
MiG3
 
Posts: 12
Joined: Sat Oct 01, 2005 8:34 pm
Score: 0 Give a positive score

Postby makslane » Wed Oct 05, 2005 10:40 pm

I'm making some changes in the server, I think will be stable tomorrow.
I don't know what you need. The codes in this post must works:


Actor *newactor = CreateActor("Scroll", "icon", "no parent", "no path", -718, -41, true);

newactor->fire = 10; //If fire is an integer or real actor variable
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Joshua Worth » Wed Oct 05, 2005 10:42 pm

MiG3 wrote:For some reason the computer I have the game on won't connect to this website at all. It keeps sending me to http://www.game-editor.com:19638/webhost/rollout/site.

Could you just type an example on how to create an actor, and change one of those actor's variables?

MiG3
It happened EVERYWHERE!
Stay sweet
User avatar
Joshua Worth
 
Posts: 515
Joined: Tue Jul 19, 2005 12:00 am
Location: Stralia
Score: 5 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest