Arrays inside Actors?

Game Editor comments and discussion.

Arrays inside Actors?

Postby yttermayn » Thu Mar 03, 2011 2:05 pm

I am writing a procedurally generated space exploration game. As each star is generated, I want to store some semi-random (seeded) values for the various attributes of orbiting planets, etc. Storing them in pre-defined single variables would be a hassle, it would be much easier to access them from an array that is local to the actor. However, when I try to add a variable with the 'variable button', it tells me arrays have to be global. If I manually declare it in the create actor script of a particular star where the data is to be kept, the array is only accessible from inside that script, and likely the data is lost when the create actor event is finished.
How do I give each star actor its own independent array?
yttermayn
 
Posts: 48
Joined: Sun Nov 25, 2007 4:10 pm
Score: 2 Give a positive score

Re: Arrays inside Actors?

Postby schnellboot » Thu Mar 03, 2011 3:16 pm

2 dimensional arrays
or actor variable array
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Arrays inside Actors?

Postby yttermayn » Thu Mar 03, 2011 7:21 pm

schnellboot:

In response to "2 dimensional arrays": I know what a 2 dimensional array is, but I do not understand how that helps me make a non-global array for an actor. Please elaborate.

In response to "actor variable array" How do you make an 'actor variable array'? Please note what I wrote above: "when I try to add a variable with the 'variable button', it tells me arrays have to be global"

Thank you.
yttermayn
 
Posts: 48
Joined: Sun Nov 25, 2007 4:10 pm
Score: 2 Give a positive score

Re: Arrays inside Actors?

Postby skydereign » Thu Mar 03, 2011 7:26 pm

Sorry to say actor variables can't be an array. To elaborate on what schnell might have been getting at, you instead have to create a global two dimensional array. The first sub is for the clone, the other for the seeded variables each clone should have. So you can structure it like this, array[cloneindex][0]. Just make it big, and as long as you clean up the actors, it will never exceed your array size.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Arrays inside Actors?

Postby schnellboot » Thu Mar 03, 2011 7:30 pm

skydereign wrote:Sorry to say actor variables can't be an array. To elaborate on what schnell might have been getting at, you instead have to create a global two dimensional array. The first sub is for the clone, the other for the seeded variables each clone should have. So you can structure it like this, array[cloneindex][0]. Just make it big, and as long as you clean up the actors, it will never exceed your array size.

exactly.
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Arrays inside Actors?

Postby yttermayn » Thu Mar 03, 2011 10:24 pm

I understand now. Thank you both. I had been tossing around a very similar idea myself after I posted last. Thanks again!
yttermayn
 
Posts: 48
Joined: Sun Nov 25, 2007 4:10 pm
Score: 2 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest