0 Favourites

How do I find/remove items from an array on a specific axis?

  • Hi, this is a followup question to another topic I made the other day. I realized I had another question but it's a bit bigger than the other and so I think it requires its own thread.

    I'm stuck on the next step of the process. I want to be able to find a specific item ID in the array, but I can't do "Array contains value" because the X and Y values can appear multiple times or be the same number. What I need is a way to compare ONLY the X axis or ONLY the Y axis, but I can't figure that out either. I need your help again, fellow Construct 2 users!

    In addition, if anyone can help me figure out how to make the item craftable (as in, how to search for the value again upon clicking the craft button, then remove 1 of the item and give the new item) that would be much appreciated. But I realize that's possibly a little more in-depth than you may want to go.

    The basic process would be like this:

    1. Search for the appropriate item only in the first row and its amount only in the second row.

    2. If it is found and the player has enough, display the craft button. In the doodle, the stuff required to craft a new item would be 8 of whatever Item #2 is.

    3. When the player clicks the craft button, remove the required amount (and the item itself if the resulting value leaves the player with 0 of it).

    4. After doing this, add the new item and the specified amount of it to the array wherever the next blank space is.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Next time it would be nice if you at least provide the array. Thank you.

  • That's close, but it's not quite what I'm looking for, and I don't know how to adapt it to my own code. I think it might be better if I just dump the whole capx file on you and let you poke around:

    The function code I'm using to handle adding/removing things from the inventory is from this tutorial, I even adapted the comments so I wouldn't forget what everything does. I really just cannot wrap my head around how to make arrays do things.

    Down at the bottom of the event sheet you can see where I tried my own prototype tinkering to get it to work, feel free to just delete all that.

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