How do I check if item and item amount are in array?

  • How do I go through each slot and check if

    Item type 4 is in array and has 10 amount AND Item type 6 is in array and has 5 amount, then just Log('Hello')?

    Thank you in advance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Array : Contains Value '4'

    Set local variable to current x

    If array.at(local variable, 1) = 10 then true / log hello

    Array : Contains Value '6'

    Set local variable to current x

    If array.at(local variable, 1) = 5 then true / log hello

  • Didn't really work for me since, if I have 10 amount of anything, it doesnt matter if the x is 4 or any other number (item type), it still runs the "Hello".

  • Ok to run more specifically you can do :

    For 0 to array.width (system loop)

    Array compare at xy 'loopindex' for x, 0 for y. value = '4'

    That will run through all x at y=0. This means it only checks the first row looking for a 4.

    Then when its true you add the curx to local variable against array.at(localvar, 1) to get the amount for 4.

  • I see how it should be working and it should, but now things got even weirder since, now it prints hello in increments of five and ten, and only take into account if x:0 is occupied. The inventory I have, I've checked now multiple times, runs correctly with the values.

    Did I follow your steps wrong?

  • Oh just as I posted the image I've seen that the item amount checking should've been a subevent. It's all good now! Thank you very much!!

  • Great, no problem :)

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