array Loop help, if statement inside while.

0 favourites
  • 2 posts
From the Asset Store
For Adventure, Action, Heroes, Sci-fi and Action-RPG games.
  • I have done this multiple times using code, but having brainfart with C2 drag&drop system, any help would be very welcome.

    In short:

    1) while inventory(0) < inventory.width let loop run trough array from first to final "slot".

    2) If currentX equals 0 set string to get what X is first empty, then stop loop all together, no need to touch anything other as I want to get first empty (in this case "0") X location.

    Here is my few attempts but they fail, some loop affect all X?s and other just stops after first one, does not run trough all values and then pick first 0.

    This is inventory test where I want to put new item automatic to first empty slot available, since its random (maybe first slot is taken, maybe first, second, fourth but not third etc.).

    <img src="http://media.rajatila.com/images/failurtpt.jpg" border="0" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • <img src="http://www.blackhornettechnologies.com/Construct2Stuff/forwithstop.jpg" border="0">

    forwithstop.capx

    You have to be careful not to mix context. "Stop loop" doesn't specify "while", only "for"-type commands, in it's help commands. The array object unfortunately doesn't have a "stop loop" either, so that doesn't help. These two examples do what you need in different ways.

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