how do i stack items up in inventory?

0 favourites
From the Asset Store
Inventory Aid
$4.90 USD
Create grid-based game inventories and items easily.
  • in my inventory max amount of healing potions is 10, if i pick up another healing potion it should add to the next empty slot.

    how do i do it?

  • Check this demo (you can open it in free version of C3)

    howtoconstructdemos.com/simple-stacking-inventory-system-c3p-construct3-demo

  • on construct 2, the function doesn't have that many options.

    and also, construct 2, i cant add a string variable to my object.

  • on construct 2, the function doesn't have that many options.

    You can use function parameters. For example:

    Call AddInvItem(Box.UID)

    inside the function access this parameter using Function.Param(0)

    and also, construct 2, i cant add a string variable to my object.

    Of course you can!

  • it doesn't work

  • I think I got it working, one question will your example work with an array? or can i just use the function only?

    i dont know which one is best to use for inventory, i have a lot of items in game

  • Making an inventory is usually a large and difficult task, and there are lots of ways to do it. I can't possibly tell you what's best for your game. Many people use arrays or dictionaries.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I did exactly the same what your example shows, but it isn't working in construct 2

  • i cant get it to work

  • i cant get the items to stack up.

  • Thank you very much dop2000 for your example, I will test every day and try to get it work on my game :)

  • Dop, do you still have that example? I tried to download it but it says it doesn't exist

  • here is a simple stacking inventory item adding subtracting using array... in C3... C2 should work the same... hope free version can use arrays? not sure..

    example inventory stacking items

    now i know that the example above just adds and subtracts to a entry, but based on that entry in your inventory you can create N bottles of potions of apple juice for example for the value at index 0 in this case.

    by doing something like

    on start of layout
    
    compare array.AT0 
    for "x" from 0 to 4 (lets say your inventory width item has 5 slots width only visually) 
    for "y" from 0 to array.at0 (but unlimited height cells)
    
    	action> 
    		create object on 
    			inventoryslot.X + loopindex(X)*item.width
    			inventoryslot.Y + ((loopindex("x") + loopindex("y")) /2) * item.height
    
    
    

    if the value at array0 is equal to 10 for example you should have 5 columns width of apple icons and 2 rows

    the above example is not that useful when you have large ammounts of items like in a crawler dungeon rpg thing... but does it jobs if you have a small inventory of like 5-10 items... i think there was a example for a stacking inventory like dungeon crawler type around here... doing a insert/pop array thing but its been years and the tutorials area got sort of mixed up. happy hunting and hope it helps.

    here is one that looks like the one i was thinking at ... maybe is newer than the one i was thinking at

    but has item categories and stacking inventory.

    rpg inventory + equipslots c3p

  • I have managed to get it to create a new stack, it shows the item. I only have one tiny problem and that is the text, when i click on the item it adds 1 and it makes the text all show 1 and it doesn't count 1 to that object only. Below is the image of my inventory showing the text count problem.

    Below here is my code, maybe i did something wrong? type something wrong?

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