# Spawn units W array [Solved]

Get help using Construct 2

### » Sun Oct 30, 2016 3:05 pm

Hello.

I got the follow informations:

There are 8 buildings in this world.

1 Array
-sets each buildings UID at 0.0
-sets how many men lives in building 0.1
-sets how many women lives in building 0.2
-sets how many girls lives in building 0.3
-sets how many boys lives in building 0.4
-sets how many money they have 0.5

Now comes the question:

I want the SYSTEM, to CREATE the humans at their specific building UID (array 0,0)

how would you do that?

CAPX link - https://www.dropbox.com/s/v8uq9o10sbtu4ap/ForQuestions.capx?dl=0
Last edited by CrudeWall on Sun Oct 30, 2016 9:20 pm, edited 1 time in total.
B
20
S
10
G
2
Posts: 170
Reputation: 3,402

### » Sun Oct 30, 2016 8:40 pm

so in other word you want to have an entire array that would list all of the building ID number and their own populated civilian. To generate a community with people.

Best way to do it is to create the array object with its own variable instance and then just number what location they are at such as this Building A is 0 building B is 1 building C is 3

And then for the rest is Men is 0 women is 1 girl is 2 boy is 3 and money is 4

Now for the array if you want Building B and to know what money it has you can refer the reference in where the coor are which is 1,4

Now that we have coor finder down if you need to modify it.

Next you will need to create a function with several parameters

Basically use the parameter to retrieve a value from the array that you want to use now

Do a repeat (parameter data value)
Spawn the created object

So in other word define on how to find the value of the array and then use that value to spawn the object. If this wasnt what you were looking for you might have to explain what you want a little better.
B
52
S
24
G
6
Posts: 391
Reputation: 7,855

### » Sun Oct 30, 2016 9:20 pm

Gearworkdragon wrote:so in other word you want to have an entire array that would list all of the building ID number and their own populated civilian. To generate a community with people.

Best way to do it is to create the array object with its own variable instance and then just number what location they are at such as this Building A is 0 building B is 1 building C is 3

And then for the rest is Men is 0 women is 1 girl is 2 boy is 3 and money is 4

Now for the array if you want Building B and to know what money it has you can refer the reference in where the coor are which is 1,4

Now that we have coor finder down if you need to modify it.

Next you will need to create a function with several parameters

Basically use the parameter to retrieve a value from the array that you want to use now

Do a repeat (parameter data value)
Spawn the created object

So in other word define on how to find the value of the array and then use that value to spawn the object. If this wasnt what you were looking for you might have to explain what you want a little better.

Thank you for the reply - i did how ever just got it to work. (I wanted it to create the people belonging to each house)

-On start of layout
(local value "Spawn_X")
(local value "Spawn_Y")
-For each (building)
-Compare in the array (loopindex,1)=1
*System set "Spawn_X" to building
*System set "Spawn_Y" to building
*System create "Man" at "Spawn_X"/"Spawn_Y"
B
20
S
10
G
2
Posts: 170
Reputation: 3,402