How do I Make This Inventory System Work?

  • Okay guys, this is going to be a long one. Let me preemptively beg for patience and mercy. You WILL have to explain things like I'm 5 years old.

    I'm trying to create an inventory system based off of this Construct 2 tutorial:

    https://www.dropbox.com/s/a21t52ct6evtm69/Inventory%20Tutorial.capx?dl=0

    Here is my game:

    https://www.dropbox.com/s/lnmfbwosi59171v/MURDER%20CASTLE%20GAME%2010.21.capx?dl=0

    The main difference is that my game does not use a mouse; it is keyboard only, which was the beginning of the problem.

    There are collectibles spread around the floor in the "Foyer" layout. The goal is:

    1) To have these items disappear from the layout and appear in the inventory

    2) To be able to select these items from the inventory by positioning the Selector over them and pressing Enter

    3) To be able to combine items in the inventory

    4) To be able to compound certain items without taking up more space in the inventory. For example: the player will have to collect keys throughout the game. If they collect 3 keys, I don't want that to take up 3 inventory slots... I want one key in one slot with the text " You have Key 1, Key 2, Key 3" and have them be able to select from that list.

    Let's begin with item 1: Upon collision with a collectible, the collectible disappears from the layout and appears in a slot in the inventory.

    I have studied the tutorial for weeks and tried to copy it to the best of my ability (keep in mind, my ability is shit). Collectibles do not disappear when I collide with them, and they do not appear in the inventory.

    Relevant Event Sheet items:

    Line 49-51

    Line 69-70

    Thank you so much. Let's have fun today!

  • First of all, your link doesn't work.

    I've seen this tutorial before and frankly, I don't like it. I think it's overly complicated.

    Search for "inventory" on this page, there are lots of other tutorials which may work better for you:

    https://www.scirra.com/tutorials/all

  • dop2000

    Oh no! Let me try again:

    https://www.dropbox.com/s/fzxehbacz1t8329/MURDER%20CASTLE%20GAME%2010.23.capx?dl=0

    May I ask, why don't you like this particular inventory system? I think it looks super cool, and it does everything I would want my own inventory to do.

    I did look at the Construct 2 FAQ list and saw a couple other options for an inventory, but they didn't have the "sophistication" of this one, lol. I will look again.

    Please please please help me with this one though, ok? I really like it!

  • Ok, for starters:

    1) You have two PlaceInInventory functions. Delete the duplicate one in Logic group.

    2) You need to add InvCell sprites to your layout. Don't forget to set correct value for Order instance variable for each cell.

    3) In lines 42 and 44 change Item.animationFrame to Collectibles.animationFrame

  • You tell me!

    What is your next problem?

  • dop2000

    Lol, sorry.

    https://www.dropbox.com/s/zdt44j7soy6gy7v/MCG10.26.capx?dl=0

    The collectibles are supposed to disappear and reappear in one of the Inv Cells, but they're still just sitting on the Level layer?

  • Why did you remove 4 actions from the "DisplayINVContent" function? Restore them and your inventory will work.

    Did you delete and then re-added invCell sprite or Collectibles family? You should be careful when you delete an object in C2, as all events and actions mentioning this objects are automatically removed from the event sheets.

    I suggest you compare your code with the previous version (the one you uploaded a few days ago) to make sure nothing else is missing.

  • dop2000

    You're right, i didn't even notice that! Fixing now...

  • dop2000

    Hi again! I'm on a roll. I went through every line of the inventory example and tried to copy as much as I could. Just a few more bugs to work out!

    1. 'Drop Item' doesn't work... the item remains in the inventory. (Line 108)

    2. 'Delete After Use' is supposed to delete the item from the inventory after being used. If you get the note, go to the dude, press I to open the inventory, and use the note, you will see that it's still in the inventory after use. It's supposed to be gone! (Line 110)

    3. If you get the note and select it from the inventory without going to the dude, the game is supposed to pause and let you read the note. But the game does not pause, and the Notes layer does not become visible as it should (Line 128).

    Also, if you get the note before getting the handkerchief sometimes the note does not appear in the inventory?

    What do you think, Dop2000?

    My game:

    https://www.dropbox.com/s/twtbcfklsi77asp/MCG10.28.capx?dl=0

    Inventory Tutorial:

    https://www.dropbox.com/s/a21t52ct6evtm69/Inventory%20Tutorial.capx?dl=0

  • 1. In line 80 you need to pass item number (item's position in the array, or InvCell.order number) to the "DropItem" function.

    For this you need to pick the correct cell, the one which is currently selected.

    Similar issue with "Use" function - you are passing Collectibles.AnimationFrame to the "SelectItem" function, which is incorrect, because by default Collectibles refers to all items. You need to first pick the correct instance of the Collectibles family first, the one which is selected.

    2. Same issue - you need to pass item number to the function.

    3. I tried that and it worked for me. The game didn't pause (because Wait doesn't actually pause the game), but the lines "Jim takes the note and reads it. etc...." appeared on the screen.

    4. If you pick up the note before the handkerchief, they end up in the same inventory slot. Not sure why.

    You can see it in debug mode - both sprites are in the second cell.

    I told you I don't like this inventory system. Integrating it into your game made it even more complex, it's now really hard to understand what's going on.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • dop2000

    Okay! Thank you, I will work on these things. May I ask, what does it mean to 'pass the item number to the function'? How would I do it?

    Oh, and if you select the note from the inventory without 'giving' it to Jim, so to speak, the game really is supposed to pause, and the note itself is supposed to take up the entire screen and let you read what it says. I've altered the timescale and everything too, but it just won't happen. (Line 128)

    Do you have an inventory system that you personally prefer? I'd love to check it out! Perhaps I will start this whole thing over, lol. Thank you!

    https://www.dropbox.com/s/omyycniwzr8g80x/MCG10.28.2.capx?dl=0

  • dop2000

    Fixed the note problem!

    https://www.dropbox.com/s/ptxi1sxfqsh3v7l/MCG10.29.capx?dl=0

    Grab the note and select it from the inventory without going near Jim, and you can read it!

    I'm irrationally proud of myself right now.

    Have a great Sunday!

  • [quote:2q55lmdp]May I ask, what does it mean to 'pass the item number to the function'? How would I do it?

    I thought you knew this.

    You can pass data to functions as parameters, for example:

    Call function without any parameters:

    Function call "AddToInvertory" ()

    Call function with one parameter:

    Function call "AddToInvertory" (itemNumber)

    Call function with three parameters:

    Function call "AddToInvertory" (itemNumber, inventoryType, quantity)

    Inside the function you can access these parameters using Function.Param(0), Function.Param(1) etc.

    By the way, functions can also return data. So you can have something like this:

    itemQuantity = Function.Call("GetNumberOfItemsInInventory", itemName)

    You pass itemName to the function, and the function returns quantity of this item in the inventory.

    [quote:2q55lmdp]Grab the note and select it from the inventory without going near Jim, and you can read it!

    I'm irrationally proud of myself right now.

    Yeah, I see it now. Pretty good!

    As for the inventory system, I can't tell you which one I prefer, because I don't have any RPG games with inventory

    If I ever need one, I'll probably create it from scratch. It may take more time, but at least it will be tailored to my needs and I'll have full understanding how it works.

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