Page 1 of 3

Creating an Inventory

PostPosted: Fri Apr 03, 2009 6:00 am
by TheIllusionist
I'm making a game but I'm stumped on the inventory style I want to use.
It has two rows, 4 squares in each row, and 2 arrows to scroll with. when an item is picked up, it goes into the first slot. If an item is in the first slot, it goes to the second slot and so on. When the first eight squares are filled, it goes down a row, giving 4 more squares on the bottom row, and can be navigated with the arrows mentioned above. How would I go about doing this?

Re: Creating an Inventory

PostPosted: Fri Apr 03, 2009 1:33 pm
by jimmynewguy

Re: Creating an Inventory

PostPosted: Fri Apr 03, 2009 11:27 pm
by TheIllusionist
That helped, but I forgot to mention the second part. In the demo you showed me, you click a button to be able to pick up an item, but in my inventory there are 9 buttons; Give, Pick Up (already explained), Use, Open, Look at, Push, Close, Talk to, and Pull. How can I make it so when I'v selecte one option, I can change to another without the previous option sticking?

Re: Creating an Inventory

PostPosted: Sat Apr 04, 2009 1:46 am
by skydereign
I think you are talking about the demo I made. I could edit it for that purpose if you want, but what I would do is use a variable. And upon clicking the items in the inventory, or pressing a key, I would determine the proper event, using a switch statement. Though to change it to what you want, I would need to know a little more. Are you talking about events on the items in the inventory? Or are they events to items outside the inventory? I am pretty sure in my demo, all you do is pick them up, and then use them, or some such. You want to be able to do multiple things to the items depending on what mode you are in, right?

Re: Creating an Inventory

PostPosted: Sat Apr 04, 2009 4:18 am
by TheIllusionist
The different options are for both inside and outside the inventory

Re: Creating an Inventory

PostPosted: Sat Apr 04, 2009 5:32 am
by skydereign
Okay, here is a small version of what I was talking about. The difference is in the mouse down events, and that there is now a variable called ActionNum. The text explains what the numbers would signify. Now in the click events, there is a switch statement, this determines what events to do depending on ActionNum's value. Just create more cases, one for each event. If you need more help, just ask. One thing to note, I have found a couple bugs/places to improve, so this is not a perfect inventory. I may improve it later if you wish.

Re: Creating an Inventory

PostPosted: Sat Apr 04, 2009 5:39 am
by TheIllusionist
Well... the main idea is right, but instead of pushing a number, you click the option. And also, when you move your cursor over an option, it lights up.

Re: Creating an Inventory

PostPosted: Sat Apr 04, 2009 5:43 am
by skydereign
Do you need help with that? I can set up a demo of that if you wish.

Re: Creating an Inventory

PostPosted: Sat Apr 04, 2009 6:02 am
by TheIllusionist
A demo would be great. :mrgreen:

Re: Creating an Inventory

PostPosted: Sat Apr 04, 2009 6:24 am
by skydereign
Here it is. Any other questions, feel free to ask, or if I missed something with this demo. The number press is still there, but you can now click the lit up tile.

Re: Creating an Inventory

PostPosted: Sat Apr 04, 2009 6:39 am
by TheIllusionist
This is the perfect inventory :mrgreen: Thanks a million

+2 :mrgreen:

Re: Creating an Inventory

PostPosted: Sat Apr 04, 2009 6:43 am
by skydereign
So you know, if you take the 8th item, you will not be able to scroll down anymore... This was one of the bugs I was talking about. You may or may not come across it, but if it becomes a hindrance, just tell me.

Re: Creating an Inventory

PostPosted: Sat Apr 04, 2009 7:23 am
by TheIllusionist
There was just a couple things I want to know. 1. When you click use, then right click an item, it disappears. How do I make it so that it stays? 2. After I click the action, you do I use said action with an object?

Re: Creating an Inventory

PostPosted: Sat Apr 04, 2009 4:24 pm
by skydereign
Do you mean depending on what item? Because to make an actual use from the item, you would just change the case 2 event triggered by a right click. If you look at the right click event, there are some if (itemtype[ofst(a,0]==1), I would actually put a switch there instead. So the entire script looks like this.
Code: Select all
switch(ActionNum)
{
    case 0: //Give
    // The code for Give
    break;
    case 1: //Pickup
    // Probably nothing, as this is clicking in the inventory, meaning you already picked it up
    break;
    case 2: //Use
    switch(itemtype[ofst(a,0])
    {
        case 0: //Item type 0
        // Your event for item type 0
        break;
        // make a case for each itemtype
    }
    break;
    // make a case for each ActionNum
}


In the existing code, there is a reset, itemtype[ofst(a, 0)]=0;. This is what gets rid of the item. The above does not have that.

Re: Creating an Inventory

PostPosted: Sat Apr 04, 2009 6:53 pm
by TheIllusionist
In this demo, you only need to click pick up once to collect all the item. How do I change that?