how can i go about making a inventory for my character such as if i pick something up like a note on the ground it goes to my inventory then i can go into my inventory and look at it

I think this might be possible with logic bricks (I believe it’s been done before), but it would be a lot easier with Python, so I would recommend beginning to learn Python.

that’s what i want to do it in is python i know you have to create some kind of list then define whats in it my problem is going and making it to were when i pick the object up how do i go and view it in a inventory screen is what iam trying to do and i don’t no how i can do that in python. and if its possible i would like to do it with out all the logic bricks

Break the problem down into chunks: at its simplest-

Each item needs to have a property (that switches from False i.e. not picked up to True) plus the driving logic.

Have a collision sensor / near sensor that detects you are near the item. When you are near the property switches to True (to say you have picked it up). Once the item is picked up it could turn invisible (to show you have taken it).

Once the item has been taken, the item may send a message to an inventory scene to create the taken object. From here you can do what you want, and like SolarLune says, simple examples are easily achievable using logic. You could make a larger item that is closer to the camera to examine, for example. A note could be a texture mapped plane that is added via an add object logic block.

If you want to do something more complicated then Python is the way to go, using functions like globalDict and Pythons take on messages (which are more flexible than the logic block equivalent).

Whoops! I just posted as you did- disregard my comments on logic.

it would help if some one could explain the basics of the code so i could at least get started

There are hundreds of tutorials, Google is your friend. :wink:

ive searched Google and couldn’t find any thing what do you suggest that i type in to try and find some thing on it

Okay, here’s a quickie tutorial.

In its most basic form, you’re probably going to have a dictionary in which each item has a number associated (the number being however many of the item you have). You’ll want to define the inventory in an object variable so that it stays consistent from game frame to game frame (through-out playing the game). Then, you’ll want to add one to the item in the inventory if you pick an item up, and subtract one when you use or drop one. Here’s an example of defining the inventory and adding one when a collision sensor set to check for items is positive.

from bge import logic

cont = logic.getCurrentController()
obj = cont.owner

getitem = cont.sensors['GetItem'] # A collision sensor checking for any item with an 'itemtype' property

if not 'init' in obj:

     obj['init'] = 1

     obj['inventory'] = { # Create a new empty dictionary and initialize the items and their numbers
     'Health Potion':0,
     'Bread':0,     #and so on

if getitem.positive:
     itemtype = getitem.hitObject['itemtype']  # Get the type of item (the name) that you got 

     obj['inventory'][itemtype] += 1 # And add one to your inventory

     getitem.hitObject.endObject() # Lastly, destroy the object that existed

For actually displaying the objects that you have in your inventory, that would require a GUI setup, where each object / image corresponds to an item in your inventory dictionary, and a number would display how many you have (which is another, more complex part).

EDIT: For that, you’ll want to create a series of objects, and have each object change meshes depending on which object you’re looking for. Basically, create a list of GUI placeholder objects and a list of items in your inventory with a number greater than 0, and for each placeholder object in that list, check the inventory list and change the mesh to match the item. Someone should be able to post an example of this.

ok i see what your saying so is there a way instead of creating the GUI is there a way i can have it to were i pick up a certain amount of items then it keeps track of the items and shows some kind of number some were during the game then make it to were i can drop or destroy them using the inventory type setup like you have above

Before you create the gui for an inventory, you need to first establish the underlying data structure for the inventory - in its simplest form this would just be a list or bit list.

Once that is done you can start to think about how to display it. If you are using 2.5+ I recommend having a look at the bgui. This inventory display was created using bgui:

You can have a look at the code for the above here:

As you can see, you have to have a fairly good grasp on python to be able to use the bgui well. See the getting started for the bgui to get a jump start in using it.

I can’t really tell you how to code the gui for you inventory, because its your inventory. There are a hundred different ways to code an inventory and its gui. You can however ask more specific questions - how do you create a grid using bgui and then fill it with icons of items?

EDIT: To give actions (drop, destroy) you can think about using a context menu:

The code for that context menu can be found here:
The code for the above inventory gui can be found here:

ok thanks for the help ill take a look at this and see what i can do with it i didn’t no that even existed

this is a profectional inventory!