How do I This System Inventory [SOLVED]

Get help using Construct 2

Post » Mon Jul 03, 2017 1:15 am

Hi, I'll try to be as soon as possible ...
I'm looking for a system that works as follows ...
When my character collides with the "Item" check an empty slot if empty set position to empty slot.

Image
Last edited by willmonteirofx on Sun Jul 09, 2017 1:35 pm, edited 1 time in total.
B
15
S
4
G
1
Posts: 36
Reputation: 1,455

Post » Mon Jul 03, 2017 8:52 am

Hello o/

There are probably many ways to do that, so I am going to tell you what I would do and then you see if it works for you, if it doesn't just come back here later and let us know because someone else might have a better idea.

Well if the player will fill the slots from left to right, and then use the items at the same order, all you need is a variable to tell which slot is currently being used. If variable is 0 goes to the first slot and then adds 1 to the variable, and so on. And after you use the item just destroy it and subtract 1 from the variable.

However, if the player can use the objects in any order he wants, then this means that the player can collect 3 objects, use the one at the second slot, and then you can't place the 4th item at the 3 slot again, nor at the forth.
If that is the case you will need to select your slot object and on the object settings on the left you gotta set a Instance variable. This variable will tell if the slot is being used or not. Then when the player collides with a object you can set "system>pick object by comparison" and then you compare if the value of the variable of the slot (something like this slotName.instanceVariableName) is the same as the value that tells it is empty. The game will then select a slot that is empty and move the object there.
Keep in mind, however, that this might result in objects being placed inside random slots and not in order from left to right.

For it to be in order I would do something like, set another instance variable for the slots that works as their ID so they can be organized from 1 to 5.Then and set another instance variable, but for the objects this time, that tells if the object is at a slot or not.
Then every time the player collects an object you go "system>for" set it from 1 to 5 and then compare if the object is at a slot and if the slot that has the same ID as the loop.index. This will check all the slots in order every time the player collides with something, and then once the object is in place the other checks will be false.

I don't know if I'm being clear enough, but try and work with instance variable and loops, and if you need more details just ask o/
B
17
S
7
Posts: 280
Reputation: 2,522

Post » Tue Jul 04, 2017 2:10 am

Hello! O/

So... first, thank you very much for the help, I thought no one could answer me... I think I understood part of your theory ...

Well, I created a new project and put everything in a very simple way...

1 - I put ID's in the Slots using variables and I used the same duplicate sprite 5 times, putting different ID's for each one.

Image

Image

2 - I also put a bollean variable to check if it will be Busy or Not.

Image

3 - Then I put an 8-way behavior on the character so he could move around the scene.

Image

4 - Then I put all the features that the character will pick up, also separating the items from the scene in layers. I hope you understand...

NOTE: Open this image in a new tab, to see better, the site has cut.

Image

Now I need to know if it's more or less as you imagine it, or need to change something?
B
15
S
4
G
1
Posts: 36
Reputation: 1,455

Post » Tue Jul 04, 2017 5:20 am

You are in the right path. Good job o/

I think that a variable in the pick ups that tell if they are are on the floor or in the HUD can help you later on. But depending on how you use your layers that might not be necessary.

Good work.
B
17
S
7
Posts: 280
Reputation: 2,522

Post » Tue Jul 04, 2017 5:32 am

I have no idea what to do now ...

The variable to know if the items are on the floor or the layer, must be boolean or numbers?

How does "system> for" work in this case?

And how do I get the functions if I collide with the items?

I'm really lost
B
15
S
4
G
1
Posts: 36
Reputation: 1,455

Post » Tue Jul 04, 2017 9:09 am

It's easy. First make a "Family" of all the "items" you have.

Then, do this:

For Each box:
--- if box overlapping with Family ------ | Set box.occupied = true
--- else ------------------------------------------- | Set box.occupied = false
B
10
S
2
Posts: 109
Reputation: 982

Post » Tue Jul 04, 2017 9:33 am

Did you mean like that?

Image

The slot has not even changed to busy :?

Image
B
15
S
4
G
1
Posts: 36
Reputation: 1,455

Post » Tue Jul 04, 2017 9:34 am

You can use my template.
https://www.scirra.com/store/royalty-fr ... coins-3380

Regards
Andy
Image Image iTunes: Match3 | Google Play: Match3
B
105
S
38
G
31
Posts: 1,166
Reputation: 29,082

Post » Tue Jul 04, 2017 9:43 am

Sorry, I'd love to buy it, but I'm trying to learn how it works :/
B
15
S
4
G
1
Posts: 36
Reputation: 1,455

Post » Tue Jul 04, 2017 10:02 am

At this point, I'm trying to understand, what to do next...

Image

I've placed a text variable to indicate when items are on the floor, inventory, or mouse pointer.

Image
B
15
S
4
G
1
Posts: 36
Reputation: 1,455

Next

Return to How do I....?

Who is online

Users browsing this forum: zenox98 and 13 guests