ID:843056
 
I want to create an inventory system, but am a bit lost at how I should go about creating it. These are the features that I want it to have:


-Additional Slots (Unlock-able)
-Pages of slots (rotate through 12 @ a time)
-Stack-able items
-Items will be treated as overlays on the slots
-Moving items w/MouseDrag(), MouseDrop()
-Disable item pickup by user when inventory is opened
-Moving items from Page A to Page B , Page B to Page C, etc (Display each slot in a tab style?) by dragging an item onto the tab
-A new page is created when the current page's slot count goes over 12
-Slots will be unlocked 1 or 2 at a time, so a tab may only display 7 slots while the first one displays the full 12


This is the end goal:


(The numbers in squares are tabs)
A lot of these features are self explanatory. If you have no idea on how to go about creating any of these features, I'd say this inventory system would be too complicated for you to make at the moment.

1) Pages of Slots - I would use list associations. As an example, page one would be associated with a list of items on that page. page[1] = list(apple, knife, bear skin)

2) Stacking - When you place an item into the inventory, you could always check that current page to see if you're already holding that item. If so, +1 the suffix of that item and make the visual overlay number change.

3) Moving item from page to page - When you click item(s), place them in limbo as you page through. Once you find the idea page, click on an open space and those items in limbo would be placed there.
What about keeping track of the number of slots a player has?

Say, for instance, you have Tab 1 with 12 slots.
Then, Tab 2 may only have 7 slots.

What would be the best way to keep track of this? Should each "Tab" have its own list?

In response to Cloud Magic (#2)
Cloud Magic wrote:
What would be the best way to keep track of this? Should each "Tab" have its own list?

Yes. In my original post I incorrectly referred to the pages/tabs as slots. I have since edited my post and made the correction.

You could always check the length of a list with len.
In response to .screw (#3)
Alright, cool.

Now, when I pick up an item should I be searching through the entire list each time I do so in order to place it in the first available slot?

Would it be best if I somehow kept track of either

A) A free slot, which, if it became unavailable, there would immediatly be a search for a new slot to set as "THE" free spot

B) Kept track of every free slot available

or go with the big "search" as I initially said?

(PS: thanks for all of your help! I appreciate it)
The HUD Groups Library has a demo that shows how to create an inventory where you can drag and drop to rearrange or equip items. It doesn't have tabs, but it could be a good start.
In response to Forum_account (#5)
I appreciate your advice, and I have used some of your work in my project (Revised the pixel-based detection system and I'm using Keyboard), this is just something I'd rather craft myself.
In response to Cloud Magic (#6)
Whether you use it or not, examining the code couldn't hurt. That is likely what he was getting at (although he does sell his libraries a lot - not that that's a bad thing).
In response to Albro1 (#7)
Albro1 wrote:
Whether you use it or not, examining the code couldn't hurt. That is likely what he was getting at (although he does sell his libraries a lot - not that that's a bad thing).

Exactly. The demo in that library doesn't provide most of the features you're looking for but it's a good place to start. It shows how to drag and drop items to move them around and provides some idea of how you'd manage it all (ex: who remembers what slot each item is in - the item or the interface?). You'd still have to add tabs and stackable items.