How do I Set up inventory using Array

Not favoritedFavorited Favorited 0 favourites
From the Asset Store
Inventory Aid
$4.90 USD
Create grid-based game inventories and items easily.
  • OK...

    I managed to get it working with just a width set up. But everytime I try and add a height I get issues. Either it combines the entries or it overwrites the previous entry. I'm pretty sure it's either searching columns and rows at the same time and finding empty slots and placing it in all locations before it stops the loop. Or it's because my logic is wrong. But I followed a guide and it still didn't work.

    (Current set up with Width only.)

    And this is what I get when I set up Height.

    I don't get it lol....

  • This is working but for Width only...

  • Well a couple of things, you don't need Z as it'll just be confusing at this point so when using array actions use set at X,Y. And you have added 2 loops you just need the 1. The point of my loop is to run through the rows, the 'loopindex' is the iteration of the loop which is also the number of the row. Because you only have one loop you don't need to specify the name of the loop and just use loopindex. Think of loopindex as the number of the row or X. If you take out the second loop then this should work as intended.

  • Thanks for your update. I agree I think the Z depth is just causing confusion for me. I will remove it and just use XY.

    The thing is My inventory is 36 slots. 9 wide 4 high. If a line gets full how do I make it check the next line for an empty slot? I thought I needed an additional loop for Height? When I did a test it did not automatically move to the next line.

    I can get it working right if I remove the height and just have a width but when that row is full (9 slots) it does not add to the next row. So I was trying to add a condition and a height check so I could change rows when item slots on the first row are full.

    But when I did that it just added items to every single empty spot in the first position of each row. So I think my logic was wrong.

    It's working now for the first row. Thanks for your help. I'm just now struggling to figure out how to move it to the next row when that one is full.

    I still have to set yp my Items menu looool. Really hoping I can copy and paste this set up and just rename things cause this has been so confusion for me. And everything was going so well until these menus!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Your inventory should be made up of slot objects that you can give IDs that match the row ID in the array. So if it is 9 slots across for example, 0-8 in the array account for the first row, then 9-17 in the array account for the second row. You don't need to move between any row of the visible inventory as the array rows (X) each refer to one slot. So the logic you have now, if 0-8 are all occupied it means the first visible row is full and it will then continue onto 9 and beyond which starts the second visible row.

    To expand on the slot object variable ID in case you were not already using that, each slot can have a variable ID that refers to their place in the array. So the first slot.ID=0 and the second one is slot.ID=1. Then for example if you were to show a description on hovering mouse over the slot it would be set text to array.at(slotID,1). The slotID refers to its row in the array.

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