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

Get help using Construct 2

Post » Thu Mar 02, 2017 10:03 pm

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:

Image

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

Image

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.

Image

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).

Image

4. After doing this, add the new item and the specified amount of it to the array wherever the next blank space is.
B
18
S
9
Posts: 103
Reputation: 1,817

Post » Fri Mar 03, 2017 1:12 am

https://www.dropbox.com/s/3gxyx4901mrbv ... .capx?dl=0

Next time it would be nice if you at least provide the array. Thank you.
B
33
S
18
G
27
Posts: 2,441
Reputation: 20,346

Post » Fri Mar 03, 2017 2:43 am

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:

https://www.dropbox.com/s/3o5xykpvzy974 ... .capx?dl=0

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.
B
18
S
9
Posts: 103
Reputation: 1,817


Return to How do I....?

Who is online

Users browsing this forum: ivanski1983, KTML5, Yahoo [Bot] and 3 guests