Inventory Example

Post your own tutorials, guides and demos.

Post » Thu Feb 12, 2009 10:32 am

I started putting together an example of how to handle an 'inventory' system. Pretty simple, but a good example of how to use functions :) I'll improve it later so its got more items and limits etc...at the moment left click picks up, and right click drops
B
4
S
2
G
5
Posts: 641
Reputation: 3,011

Post » Thu Feb 12, 2009 11:43 am

Cool! Will be keeping my eyes on this one...

I started one the other day but it got a little complex.. so I put it to the side for now.. ;)
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Fri Feb 13, 2009 6:15 pm

Think it'd be possible to make an inventory that you can drag and drop objects out of?

I was trying to think up how to do it but couldn't. :(
B
2
S
2
G
4
Posts: 136
Reputation: 1,722

Post » Fri Feb 13, 2009 6:26 pm

I made a start on one that was going to allow that. Also, something like a sword could take up 6 squares and if you replaced it with something that took up 4, it'd be an automatic switch over. At least that's what I had in mind but it's not as easy as it sounds. Might have another go at the weekend.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Sat Feb 14, 2009 3:15 am

Adjusting the index value shuffles them around so its possible. Its just a case of making the events organised enough that it doesn't get confusing or messy.

If you have 8 spots and you have a sword that takes up 4, and 4 different potions which take up 1...then how would you move the sword about? Would you just drag and drop it over the potions, and everything else would automatically shuffle to give the sword room ?
B
4
S
2
G
5
Posts: 641
Reputation: 3,011

Post » Sat Feb 14, 2009 3:48 am

[quote="David":24mmv1ns]Adjusting the index value shuffles them around so its possible. Its just a case of making the events organised enough that it doesn't get confusing or messy.

If you have 8 spots and you have a sword that takes up 4, and 4 different potions which take up 1...then how would you move the sword about? Would you just drag and drop it over the potions, and everything else would automatically shuffle to give the sword room ?[/quote:24mmv1ns]

It would be exactly like in Diablo II... if you don't have slots available, you have to drop the item and reshuffle your inventory spaces to make room. A lot of people found that "annoying" but I find it in true RPG spirit... reordering your bag-o-goodies to shovel in one last treasure! You can always swap a smaller or same sized item for something bigger (or same sized >.>) but putting a larger item in place of a smaller one would require the spaces to be there already.

You could always make an "auto sort" function (like in Sacred 2) which arranges your inventory for "best fit".

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
45
S
17
G
37
Posts: 2,853
Reputation: 25,966

Post » Sat Feb 14, 2009 1:17 pm

Yeah swapping the other way round would be a nightmare since you'd have to work out what to do with the multiple items you've replaced by the sword. I'll finish off my crappy shooter thing today and then set about this and see if I have better luck this time around. Would be good to see David finish at the same time and people could see 2 different methods of doing it. Mine will be the messier one by far ;)
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Sat Feb 14, 2009 1:21 pm

Hashtable Object would be the best to use for inventory system, at least that is what I believe. Alternatively you could just create 'inventory slot' sprites that would store anything thrown at them, but hashtable is more flexible - you can create a dynamic number of inventory slots for each existing key. ;)
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155


Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 0 guests