How to make an "additem" function loop

0 favourites
  • 2 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies. For use in game and custom works.
  • Hey guys, so I have been working on an inventory system, and I have the basics down, except when trying to add an item, I want to use a function that uses these basic commands:

    on function "additem"

    pick "inventory" equal to parameter(pickedinventory)

    and continue only if the parameter(addquant) > 0

    if the parameter(xindex) < pickedinventory.width = parameter(additemid) , 1) < maximum stack size

    - add to inventory slot amount by 1

    - call the "additem" function, this time

    with -1 "addamount"


    -call the "additem" function, this time add 1 to xindex slot


    -call the "additem" function, this time add 1 to xindex slot


    -create a new stack at the inventory.indexof("none")

    I have used this code and it does not work. is there any logic problems with it? The preview keeps crashing every time I try to add and item thats over its maximum stack size.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That "maximum stack" error means that the function calls itself recursively many times.

    Could you post your capx or a screenshot of the events?

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