Today I had to quickly return to the language files to update the Quick Message script and the Add Quest scripts to handle multiple languages. And before starting the inventory system it was necessary to work out the best way of handling the text strings. I decided to use the objects name (in english) and reference the objects that way rather than assigning numerical numbers like I’ve done for objectives and dialogues.
So, on to the inventory. Tricky little system this one. Firstly I would need a few more sprites. The first obviously being the item that can be picked up; for this I decided to do the Key Code Card first as it would be a simple sprite to create and that would allow me to get on with the more important coding. The second sprite would be a new mouse interaction icon to depict that the object is something that can be picked up.
Once those were done I created a parent object that will serve as the base for all collectables, this parent object handles the interaction with the mouse and also adds the item to the players inventory array. This last part proved a little harder than expected because the object being picked up is actually destroyed (to remove it from the level) but it still needs to be referenced in the inventory. Took about an hour to work out how to pass through the objects name and sprite index so I could store what it was and what it looks like. Then it was the case of accessing the language files to get the display title for the object. Finally with the inventory now containing an item I could start to draw the items on the screen.
I had made the decision that the player will probably only ever have up to 6 items at once (hopefully), and so I thought it would be interesting to display those on the right side of the screen. If the mouse moves over the inventory image the title is displayed to the left. I’ve also drawn the items semi-transparent and will illuminate them on mouse over. Next week I will concentrate on what happens when the item is clicked. For the Key Code Card it will display the ‘Examine System’ details for the object as it is used for a puzzle and not for direct interaction with the environment. This will allow the player to complete the locked door towards the end of the first floor. Exciting stuff.