Compare two 2D Arrays

Get help using Construct 2

Post » Mon Feb 18, 2013 4:59 pm

Hello all.

I have been using C2 for a while now and due to the awesome community here have been able to provide solutions to problems that have arisen in the past. Alas I think I may need to reach out with this one.

I would like to compare the values in the corresponding cells in two Arrays. If they match up the user wins the game, if not a message appears for them to try again etc

Here is what I have started with but I can't help but feel I am going about it in the wrong way?



Am I on the right track?
B
6
Posts: 5
Reputation: 644

Post » Mon Feb 18, 2013 5:35 pm

Yep, you're on the right track. But the "curValue" from your "array_Solution" doesn't iterate at all through the array. Just replace the "array_Solution.curValue" with "array_Solution.At(array_Level_1.CurX,array_Level_1.CurY)". And add a "Stop loop" action, no need to continue the iteration when one error is found .
B
45
S
16
G
18
Posts: 845
Reputation: 13,673

Post » Tue Feb 19, 2013 11:07 am

Thanks for your help. I have amended my event to what I understand you have said but it is still not working quite right. The "Win" action seems to come up no matter whether they match or not.

Here what I have now.




When the Arrays have different values in the "Win" still comes up? I'm pretty sure it's just my ordering of the events and have tried different ways but to no avail. Any help would be appreciated. Thanks again.
B
6
Posts: 5
Reputation: 644

Post » Tue Feb 19, 2013 2:56 pm

Ok, your construction is somewhat right, but the else never fires (because an empty condition is always true). When you click the button, set the text to "Win", we assume the solution is correct unless proven otherwise. Change your condition to "not equal" and get rid of the else statement altogether. You don't need any extra sub-event under the loop. You should get something like this :

B
45
S
16
G
18
Posts: 845
Reputation: 13,673

Post » Wed Feb 20, 2013 10:50 am

Brilliant!
Thank you very much for help. I appreciate it.
I think I probably would never have thought about nesting the two event conditions there.
Have a great day.
B
6
Posts: 5
Reputation: 644

Post » Wed Feb 20, 2013 5:14 pm

Thanks ! Always glad to help, and good day to you too ! Magistross2013-02-20 17:14:28
B
45
S
16
G
18
Posts: 845
Reputation: 13,673


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Artpunk, Bad Wolf, davides, NRABrazil, Vallar, WhosWho and 28 guests