How do I? Three things dealing with arrays.

Get help using Construct 2

Post » Mon Mar 16, 2015 7:39 pm

I've looked around through the forums and tutorials for something specific to this and I cannot find it. I'm needing some guidance for the following three steps:

1) Search for a string in an array and identifying its index.
2) Using that index locate another index by adding or subtracting from the y or x.
3) Taking the value placed in the new index and applying it to an instanced variable.

Thank you for your time.
I must not fear. Fear is the mind killer.
B
10
S
1
G
1
Posts: 22
Reputation: 966

Post » Mon Mar 16, 2015 9:21 pm

Hi,

1) Array.indexof("your string") => You will get the X index
2) Array.At(Array.indexof("Your String"),Y Index)
3) Set Variable to Array.At(Array.indexof("Your String"),Y Index)
B
14
S
4
G
2
Posts: 190
Reputation: 3,938

Post » Mon Mar 16, 2015 10:05 pm

Ok, the problem I'm having is when I attempt to replace the ("your string") portion with another text variable. Is there a way to apply the quotations after?

I guess to better explain, I'm trying to use ("sprite.AnimationName") there, but placing the quotations makes it search for sprite.AnimationName. When place it without the "" I get a return of -1 of the final variable.
I must not fear. Fear is the mind killer.
B
10
S
1
G
1
Posts: 22
Reputation: 966

Post » Mon Mar 16, 2015 11:20 pm

Remove the quotes in that case, quotes are only needed if it's a characters chain.
B
14
S
4
G
2
Posts: 190
Reputation: 3,938

Post » Mon Mar 16, 2015 11:21 pm

Do you have a sample capx so I can check what happens?
B
14
S
4
G
2
Posts: 190
Reputation: 3,938

Post » Mon Mar 16, 2015 11:42 pm

@j0hnbane I answered on your other topic
B
14
S
4
G
2
Posts: 190
Reputation: 3,938

Post » Tue Mar 17, 2015 12:02 am

That answered it, @beufreecasse, thank you yet again!
I must not fear. Fear is the mind killer.
B
10
S
1
G
1
Posts: 22
Reputation: 966


Return to How do I....?

Who is online

Users browsing this forum: blackhornet and 6 guests