Multiple Inventories

For questions about using Classic.

Post » Fri Jul 27, 2012 3:46 pm

Okay this is getting pretty complicated. Currently my inventory is a layer with "emptyslot" sprites on it. If you drop an item on the inventory layer it moves to the nearest emptyslot. I wanted to create a separate inventory for my car too so I made another layer with empty slots and added several events to basically duplicate the actions of the Inventory layer. If you are adjacent to the car you can see the car inventory but if you are not the car inventory moves off screen.

This works just fine for 2 inventories but what I really want to do is make many different backpacks, cars and npc's that can all have there own inventory. Obviously this will become unsustainable quickly with my current system. It took me a day to works the kinks out of a second inventory layer. There has to be a better way to do this, I would love to keep the basic principles of the visual drag and drop inventory the same, but I would understand if that is impossible or extremely complicated.

Basically, It needs to be like the Bethesda games but instead of 1000's of containers I would only want to make around 30-50, you do not find items in containers, just on the floor. Also the containers would have to keep track of a couple of variables for each item, ie. health. The way I am doing this now is with private variable on the sprites themselves which are never destroyed when moving between ground and inventories.

If anyone has any suggestions for how to tackle this I would really appreciate it.
B
4
Posts: 18
Reputation: 336

Post » Fri Jul 27, 2012 11:01 pm

Here's one idea:
http://dl.dropbox.com/u/5426011/examples13/multi_inv.cap

Basically the bags are in a container with an array, so each bag has an array for it's contents. When the player touches a bag the bag's inventory is displayed. The player's inventory is handled the same as the bags, except there is no array for the player's inventory, just the slots. One could be made later if needed.
B
79
S
24
G
54
Posts: 4,749
Reputation: 40,761

Post » Sat Jul 28, 2012 4:32 am

Actually I figured it out in a way that let's me keep all of my item data in the sprite itself, so each item is it's own entity that can exist in any box, I did it all with local variables, So far I can't find any bugs. Fingers crossed as I continue to add functionality. Basically I had a system that was about 40 events handling all of the differents items and whether or not they were in the inventory, I had to completely delete the entire group of events and start fresh, it was terrifying, that was about 12 hours ago, I feel way better now.
B
4
Posts: 18
Reputation: 336

Post » Sun Jul 29, 2012 7:33 pm

67 Events in three separate groups but game now supports an infinite number of Inventory containers that are Super easy to create, and best of all it never destroys or spawns a sprite. I'm going to test it for couple more hours but so far I can't find any big problems. I feel so much better now.
B
4
Posts: 18
Reputation: 336


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests