How do I create a functional Inventory? (File Attached)

0 favourites
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • If anyone can rate me on a scale on 1-10 how close i am to succeeding or failing in creating an inventory (1 being failing), my pet project on One Drive is [here =!ArPmy3wHxvqIhV3BeOw6ACNdMh9d?e=dC666b]

    So I've read and attempted probably every community article, comment, tutorial and youtube video 10 times over in the past 5 weeks on inventories or learning arrays etc. (I've spent many nights watching Bliskins YT Tutorials) only to get stuck every time on the same function. there just seems to be so many methods out there but I cant get a single one to work. So i give in, and I am asking the community for help so that I may learn.

    I am unable to wrap my head around arrays and json files, its like learning another language on top of another language.

    I am failing at the act of game item 'upon collision' with the player (not mouse click), add the item to the player inventory, to show the inventory image, to stack properly. to use keyboard navigation to select and action (drop,use etc.).

    I have the inventory visuals, space to open, arrows to navigate. would love tools on the left and resources on the right.

    I have got it to collect on mouse click, however stacking only works sometimes and unable to transfer this to 'on collision' and i've had minor success tutorials using dictionaries however this seems extremely tedious adding a bunch of events for every single item, i feel like adding to an array or file to be loaded in seems more efficient.

    This is my first anything, i am learning as i go and i feel like i've come pretty far in 6 weeks since knowing nothing however i've tried to tackle the inventory for 5 of those weeks and feel like i am no closer.

    If anyone is skilled enough & has the time to mess around with my file, feel free to delete/modify etc. I'm keep to learn from live examples.

    (Side note: Not a big deal however also struggling to get animal animations to smoothly update with their walking direction [also more than 1 of the same animals seem to sync their animations despite moving in opposite directions])

  • I am at work so I can't dig into your code ATM. I do however have 2 videos I made that work with inventories and don't use Arrays. If Arrays are your problem, check out these videos and build one without Arrays ;).



  • I’ll check that out after a sleep. Cheers! Thanks in advance.

  • winstreak i appreciate your videos, i followed them both for a single item however there must be something im doing wrong as I cannot get them to stack. Note: I did use different objects to seperate in_game vs inventory on screen.

    I also tried to implement families for a larger group of items however failed also.


  • I would definitely use arrays, it's so easy. An array is just a list of items and you can see what's going on very easily with what you've collected. You can use simple conditions like when you pick up an item, check if the array contains the item, and add 1 or stack it.

    In my opinion it's more difficult to make an inventory without an array and if you are new with the software you will likely come across bugs that you don't know how to fix. Checking if a certain item is overlapping another item to be able to pick it up etc. This can all be avoided with a simple array.

    Array items are rows, X=0, X=1, X=2. Pick up an item, check if array contains item, if not then push to the back of array. Second column could be amount collected so you can stack. Easily display the array items in your game : give the inventory slots instance variable IDs that relate to the array rows - for each slot set slot.item to

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the support lionz. I do really need to get my head around Arrays and it’s functions. It appears so simple, I’ve given it a few cracks but I’m not finding it the case.

  • It also feels like you have more control if you view it in debug preview. You can see what the array contains and what's changing within it. I just think of the items as a list, X rows at column Y=0, the same as a spreadsheet. Then at the other columns you can add more data like amount at Y=1 etc.

  • lionz you wouldnt happen to have a working example describing what you've written would you?

  • Ok I had some free time I made this quick one. You can see how it adds items to the array and stacks them, and also how you can remove them.

  • i appreciate your time lionz!

    Looking good so far i was able to adapt your instructions to my group of items to the array.

    just gotta work out how to adapt your inventory text/drop to my own inventory visuals.!ArPmy3wHxvqIhWMB0S7eIo7xnqk8

  • One way is to have invslot with single frame animations of all the items with matching names, add the variable for array location like I did with the text object in the example, then you can set invslot animation to

    Another option is to create object by name and every time you open the inventory, for each invslot create the object for invslot.item on top of it. That could work well if you are using a drag and drop approach to swapping items. If you are using arrow keys to select them then I would go for the first option.

  • This has worked incredibly argh, lionz thank you!

    One issue i've generated however (i searched for a solution however found a few old posts from yourself helping others with similar issues)

    The inventory object spawns endlessly and the only once rule doesn't seem to work in this context...

  • You can add it to the press space to open inventory event so it triggers once.

  • Thanks, unfortunately creates additional issues destroying every inventory item object when dropping the last item on a pile.

    I'll play around with it for a bit and see if i can come up with something.

    I really appreciate your time to show me how to create a functional array for inventory use.

  • lionz i got it to stop by only allowing the creation if the inventory slot is not overlapping an inventory item object. win...

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