0 Favourites

[Solver] Not understanding this loop issue

  • So in this function I have 2 loops, one called "item" and one called "z".

    "item" loops through the X index of an array called "Chance", while "z" loops through the depth of the array (which is 2).

    "item" returns me the X position at which this function stops, while "z" returns the depth at what that happens

    But for some reason, "z" always returns 0, when the events are like this:

    (in this order, the loop goes "1,0" "1,1" "2,0" "2,1" "3,0" "3,1"... and always stops at "X, 0" for some reason)

    (events 21 and 23)

    [attachment=1:1bqx9n76][/attachment:1bqx9n76]

    And if I switch the order of the loops, "z" always returns 1

    (in this order, the loop goes "1,0" "2,0" "3,0" "4,0" "5,0" "6,0"... and always stops at "X, 1" for some reason)

    (events 21 and 23)

    [attachment=0:1bqx9n76][/attachment:1bqx9n76]

  • One obvious problem is that you check endloop=1 to Stop the outer loop, but the inner one will still run one more time. You should at least have an Else after Endloop=1 to stop that inner loop.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • One obvious problem is that you check endloop=1 to Stop the outer loop, but the inner one will still run one more time. You should at least have an Else after Endloop=1 to stop that inner loop.

    Oh my god, I love you _@

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
378 33,281
part12studios's avatar
part12studios
Unread hot topic
300 118,435
blackhornet's avatar
blackhornet
Unread hot topic
0 Favourites
Spam issue
201 16,841
Tom's avatar
Tom Construct Team Founder