Trying to make simple inventory.

0 favourites
  • 11 posts
From the Asset Store
Inventory Aid
$4.90 USD
Create grid-based game inventories and items easily.
  • Hello, I'm beginner.

    I'm trying to make inventory with only three slots.

    I made an array with width 3, height and depth 1. I also made sprite slots with SlotID instance variable. Every sprite instance has different SlotID, 1,2 and 3. How to use that SlotID instance variable to create picked item icon on exact slot? Also, what would be best way to make such inventory so I can add any picked item to it? I don't want to hardcode specific items because there would be a lot of them. What I have until now is really primitive and the last part where item icon has to be created on exact slot is not working. This is first part where you pick up item.

    and another one where I'm trying to create item icon on the slot.

  • You can check array in debug view to see if "FireEx" is actually added to the array as expected. If it is then I would expect the UI to work though you move it to the bottom of the layer maybe it's hidden underneath other objects? Again you can check in debug view if the icon exists and its location.

    Adding items to the inventory depends on the design of the game and what happens when you pick them up. If you push the item name to the back of the array it is like adding items to a list. For example if your array size is 1,1 instead of 3,1 as you described, if you pick up the FireEx and push FireEx to the back of the array it would appear at 1,0 in the array, same as where you hardcoded it to appear at 1.

  • Thank you for you answer.

    It's confusing because I would expect a list containing three items(text) in array, maybe three rows where I can store text value and I only see row 0 when in debug mode.

    For now I added new condition so icons would be created on the right slot, but I would like that icons appear on the first empty slot.

  • So you mentioned that the array size is 3,1,1 but from the screenshot it's 1,1,1. So because you checked in debug mode you can see why the icon logic won't work as FireEx doesn't exist in the array, in fact row 1 does not exist.

  • It seems to me too. Does width indicate the number of columns? Here are my array properties.

  • Width is the rows(X). You probably have events to fill the array that affect the size.

  • It works now, but I added height 3 also. I thought that if I would have 3 rows (width 3) that would be enough to store three item names.

  • Yeah you've added there 3 columns, it didn't work earlier because you only have 1 row. That array does not have a width of 3 so you've changed it somehow with events.

  • Now I have 1 for width and 3 for height and it works. If width is 3 I can't see it at all in the debug mode. Thanks for help.

  • I want to check is there a empty space in array and if there is, I want to write name of the item that is previously stored into item global text variable.

    So I got global variable I, global text variable item, which default value is "empty" and array InvMission that has Width 1, Height 3 and Depth 1. It also has default values on all three slots "empty". Don't know what's wrong but it only fills only 0,0 of a array with the name of item that is picked up first.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That loop appears to be running constantly and doesn't relate to when an item is picked up? Also the condition is strange it's checking specifically 0,1 is empty, is that the intention? Since the For implies it is running through all columns then you want to check if (0,loopindex) is empty which would check 0,0 0,1 0,2. Later I noticed the global variable item, if you are trying to use this to not run the loop when global variable is empty then it needs to be at the top level of the loop.

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