array gets

Get help using Construct 2

Post » Tue Nov 17, 2015 7:36 pm

Ok so i create this Array and It will evolve to a large array. The Array Width is 6 and Height is 2 and Depth 1.

I have it set up for all in the Width value in order starting from 0-5 Blank, Hp, Power, Speed , Type

And for the height in order from 0-1: Blank, Name

Now I want to create a system where instead of using X,Y value I want to do something like Get value at "Name","speed" because like I said this will be come a large array and If i can get away with doing Name, speed it would drastically reduce the time of finding the code and have a function to check value of name and then power and have it running on checking the value = value instead of IF 1,0 or 1, 8 you can imagine how bulky the code would be.

I just cannot figure out how to access a function to would allow me to use the name as a trigger finder and the stat for easy picking

Because I want to load itself into various variable holder for use in battle to pull from or to view it.

Or am I doing this wrong.
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Tue Nov 17, 2015 8:38 pm

For large arrays like unit lists and such I use instance variables for stat positions on an axis so I don't need to remember stuff like if I had health as 12th or 13th item and can just use array.hp in place of it.
But for using the name maybe IndexOf(name) could work if names are unique.
B
17
S
6
G
1
Posts: 41
Reputation: 1,725

Post » Tue Nov 17, 2015 9:24 pm

Well since the names are going to be Unique and I realized that using variable in your sense would work alot better.

So If i use like say Selected = indexof (name) and use a variable like array.speed

How would I get the program to check for the index(name) is equal to a Y and then add that with array.speed in a X,Y coor so that its comes up to Finding coor value of 3,1 ?

How would i code that ? because later in the code I am going to use Level to multiply or Add value to this base value

such as once value is found this is base value of level one and then once you level to two I will have it increase by 2 or so on and I would like to keep this array that i am working on to be only for Base value of level one And I will use this to determine the stat of enemy and your own player. and Yes I will have another Array for player and enemy value.
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Wed Nov 18, 2015 12:16 am

Hmm I'm not sure I understand what you are asking.

and then add that with array.speed in a X,Y coor

based on that are you are asking how to add the array value in a another expression? If so
something+array.at(array.IndexOf(name),array.speed) might be what you want.

Also I'm not sure but as far as I can tell it might be better to use X for names and Y for stats because some stuff seems to be either for just X or X and Y but not for just Y.
B
17
S
6
G
1
Posts: 41
Reputation: 1,725

Post » Wed Nov 18, 2015 4:50 am

ummm ok how about is there a way to get a value coor then like say if Name is in the array at 0,1 How would I extract the value coor Y number only which is number (1) to be use with the variable coor speed.
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Wed Nov 18, 2015 5:35 am

Hey @Maukka I was using a test mini example and I came across some thing funny. So for this example i used array 2x2 and used 0,1 and 1,1. I set the 0,1 to Name and 1,1 99. and i added a button with a text variable = "Name".

apparently even if you use Button.variable in the Contain value array condition. The Array doesnt see the Button.variable="Name" but rather see the value as plain Button.variable.

So then I tested a another theory that if the array at 0,1 has value Button.variable it now reads it. Can anyone explain why this is happening. I mean the Button text variable is the same value as the array but the engine doesnt reads it as that way ?

NVM the " " on teh name for button.variable is what prevented it...silly me bad habits

Ok i found it It was in the loops.

for each x,y + currentvalue=variable -> set variable to CurY This was it and thx you @Maukka Ill use your techique as well.
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Thu Sep 22, 2016 5:45 am

yes this was my question that how i can call those all players which are having team A in the array :) and those whor are having B in other list or table.
B
17
S
5
Posts: 45
Reputation: 1,240


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 9 guests