Inventory/Bag for rpg

kagames173

  • Posts: 3
I need help making a inventory button that pulls up your items for a rpg i'm making can someone please point me in the right direction or just tell me what to do?

Kajitii

  • Posts: 184
For starters, you'll probably want a list.  But since lists can only contain numbers, text, and other lists, you're going to have to think about how you'll be able to store the information in such a format. 

For example, in the game I'm making, I have a list that represents the whole entire room in a grid-like fashion.  Each spot on the list has an index number equal to (y*sceneWidth(tile) + x).  And for each spot, there is a number that represents what kind of terrain and actor (if any) exist in that location.  Terrain values occupy the third and fourth digit, while the actor occupies the first and second digit.  So for the number 0199, the 0100 tells me that there's open ground terrain, while the 0099 tells me that the player character occupies that spot.

This system works fine for relatively small amounts of actors and terrain types, but if you're making an RPG (particularly one where time isn't critical), then you'll want to label your items by their name.

rob1221

  • *
  • Posts: 9472
Quote
But since lists can only contain numbers, text, and other lists...

This is false.  Lists can contain anything, including actors.  However, do not save a game attribute list unless it contains numbers, text, or other lists containing the same.

Savager

  • Posts: 31
I would need to make a inventory bag too :S. Someone can explain it a little bit more how to do it please? Thx!

Satyre

  • *
  • Posts: 270
I created a popup menu with some actors and state numbers once.

You can create some invisible small actors that are anchored to the screen and will be visible when the "open bag" button is pressed. Also the texts should then be drawn.

The second method is to save your x/y position and map and make a scene transition to your "bag" scene where all actors (items weapons etc) are shown, and when you press the bag button again you will be transfered to the last map and with the last positions. The only problem by that would be that all other actors will be spawned again unless you give them a special boolean (do not spawn when "close bag" button was pressed). Hope the ideas give you a way to solve your problem.

Kajitii

  • Posts: 184
Quote
But since lists can only contain numbers, text, and other lists...

This is false.  Lists can contain anything, including actors.  However, do not save a game attribute list unless it contains numbers, text, or other lists containing the same.

Whoops, that's absolutely correct xD  My bad.

Practically speaking though, you'd only want lists with numbers, texts, and/or lists of likewise contents just to save yourself some headache.

froz

  • Posts: 250
Why? I'm using list with actors all the time. I can't imagine my game without it, unless I would create sophisticated workaround for each case. Is there any reason why I shouldn't put actors into lists (I'm not talking about game attributes here, so saving is not an issue)?

Kajitii

  • Posts: 184
Usually when someone says RPG, I think of something like The Guardian Chapter 2.  It has save points, and it has an inventory.  If you want to have an inventory whose contents you can save and access when you load the game again, you'd better do it using game attributes.

If the OP doesn't plan on having a save feature, then he can completely disregard my advice and go nuts with lists xD

froz

  • Posts: 250
Ah, ok, nevermind then. You got me worried for a moment :).