How do I stop the loop at the first satisfying value in the array?

0 favourites
  • 3 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies.
  • So, I am doing inventory on arrays, however, on the Internet I did not find a single necessary guide for what I need. Since I am not a very good programmer, I ran into problems at the stage of writing the item data to the inventory array.

    The problem is that no matter how perverted I am, the values change in the entire array completely. That is, an array full of zeros is replaced with an array full of ones - although I only want the first satisfying value to be replaced. How can I solve this problem?

    {"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"for-each-element","objectClass":"Inventory","parameters":{"axes":"xy"}}],"actions":[],"children":[{"eventType":"block","conditions":[{"id":"compare-at-xy","objectClass":"Inventory","parameters":{"x":"Inventory.CurX","y":"Inventory.CurY","comparison":0,"value":"0"}}],"actions":[{"id":"set-at-xy","objectClass":"Inventory","parameters":{"x":"Inventory.CurX","y":"Inventory.CurY","value":"ui_item.IID"}},{"id":"stop-loop","objectClass":"System"}]}]}]}

    {"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"for-each-element","objectClass":"Inventory","parameters":{"axes":"xy"}}],"actions":[],"children":[{"eventType":"block","conditions":[{"id":"compare-at-xy","objectClass":"Inventory","parameters":{"x":"Inventory.CurX","y":"Inventory.CurY","comparison":0,"value":"0"}}],"actions":[{"id":"set-at-xy","objectClass":"Inventory","parameters":{"x":"Inventory.CurX","y":"Inventory.CurY","value":"ui_item.IID"}},{"id":"stop-loop","objectClass":"System"}]}]}]}

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • "Stop Loop" doesn't work in "Array For Each element" loops. I don't know why.

    You can use a local boolean variable to stop processing the loop.

    Array For Each XY
    Boolean variable loopContinue is true
    
    .... Array Current value=0 : Set loopContinue to false
    
  • Stopped in to say the last solution completely helped fix the problem!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)