In adventure games you can often have an inventory (a list of all the things you are carrying) This is useful as you can see what you have found so far and perhaps in some game what you can use.
To make an Inventory we need to make two new definitions.
Put them after your last "room" definition but before your "launching" code that starts the fist room
You also need to add one line of code that starts the inventory with an empty list before you call your first location - meadow() in my case.
You have to alter the cave code to take account of the new options of inventory and pick up the box
This code defines two routines - one to Add things to the inventory - this uses a global variable and one to just print out the inventory when asked to do so.
In the above test you can see that I have moved to the cave and then asked for the inventory - I have not picked anything up yet so it says "You have nothing"
Now I will get the box and look at the inventory
You can add other things in rooms to pick up and add to the inventory using the same idea
My game so far is below...
You may have noticed that you can pick up an item twice - we can change the code for AddInventory to stop this happening.
We then only add it if it is not already there!
If you want to take my code - saving you typing it all in it is below...