array Loop help, if statement inside while.

Get help using Construct 2

Post » Sat Jan 05, 2013 3:01 pm

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 Xs 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.).

CoffeeOD2013-01-05 15:02:24
B
7
S
1
Posts: 51
Reputation: 1,087

Post » Sat Jan 05, 2013 5:21 pm


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.blackhornet2013-01-05 17:27:30
ImageImageImage
B
67
S
19
G
121
Posts: 3,196
Reputation: 72,879


Return to How do I....?

Who is online

Users browsing this forum: MarkThomas and 0 guests