[Solved] Finding the first empty value in an Array

0 favourites
  • 4 posts
From the Asset Store
Use this game pack to create your own game, modify the existing game or simply take a look and see how it was made.
  • I'm trying to make a code that finds the first "0" value on an Array and places a number there.

    I don't understand why this fills the entire array with the new value:

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

    Is the "Stop Loop" useless here? What can I do for an "For Each XY element" to stop?

  • It appears System:Stop Loop does nothing for Array:For each nn element, just for System: loops. I put some logging in your code and the loop does not stop. I guess just have a local variable "valueFound" or similar and set it to 1 when you've found the first zero, and use this as a second expression in the arrInv:Value at condition. AFAIK.

    Edit: anything->nothing

  • It appears System:Stop Loop does anything for Array:For each nn element, just for System: loops. I put some logging in your code and the loop does not stop. I guess just have a local variable "valueFound" or similar and set it to 1 when you've found the first zero, and use this as a second expression in the arrInv:Value at condition. AFAIK.

    Thanks, that worked ^^

    [attachment=0:2ui4rrxl][/attachment:2ui4rrxl]

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Cool.. it had me stumped and the manual is very scant on this.

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