Inventory help (SOLVED)

Started by R4L, Thu 24/08/2006 11:40:49

Previous topic - Next topic

R4L

Now I have another problem, concerning inventory. On GUI STATUSLINE I also have inventory. There are five boxes, and I would like only one item to be displayed in each. I made 5 different inventory windows, but whenever I pick up something in the game, the same items go into the first box. This is the first time I have tried to actually create inventory as I usually use the default GUI to do that.

Joe

Do you mean some thing like this?



Maybe you forgot setting the item height and width.
Copinstar © Oficial Site

monkey0506

That shouldn't do that unless the item height and width were set to 0...o.0 I think.

Anyway, they don't default to 0.

What he probably did is he probably drew different InventoryWindows for each item.

You just draw one window that contains all the item's spaces. Then you set the Item height and width.

R4L

I did this.

I already set the item width and height. I just need to be able to show one inventory item in each black box, and each box can only show one item. My problem is that I don't know how to limit the amount of inv items per box, and let the player pick up items in any order.

SSH

So you want the first box always contains the Spanner, for example, if you have it. The next box only contains the Briefcase, etc.

Right, so there's a number of ways of doing this:

1. Use GUI buttons instead and change the graphic in on_event when event is addinventory

2. Use 5 dummy characters, each of whom can only pick up one particular item, and set each gui inv window to point to one of them

3. Set the width of inv items to be the distance between top right corners of your "holes", make the inv window go over all of them, and then

4. Always have all items in your inventory, but make them default to invisible sprites and turn the sprites to normal when you get the item...

5. Look at the entires to the Grid-based inventory coding competition

and many more...
12

R4L

What I meant SSH is that I have alot of inventory items, and I want the player to be able to pick them up in any order. For example, the player has nothing, and then he picks up a wrench. The wrench will be in box one. But if he has another item in the first box, the wrench will be put in box two. I understand if this is too complicated. I would rather not try to code all of this, especially since I may not understand any of it. So what I think I might do is instead of show individual boxes, im going to have a whole slot, which will have one InventoryWindow and show up to 5 items. This can be accomplished with ItemsPerRow correct?

monkey0506

#6
You draw ONE InventoryWindow. Then you can add them and they should show up in the appropriate location (based on the ItemHeight and ItemWidth). You can't manually set ItemsPerRow. That's determined by the ItemWidth and Width (of the InvWindow).

[EDIT:]

I guess I didn't completely read it correctly. Ashen got it.

Ashen

#7
If I'm understanding you right, you don't care WHAT order the items are in, provided the most recently added item is the first in the InvWindow, rather than the last?

From the manual (Characeter.AddInventory):
Quote
By default, the new item is added to the end of the character's inventory list. However, you can insert it in a particular position in the list by supplying the second parameter. The new item is inserted before the current item at addAtIndex. Indexes are numbered from 0, so to add the item at the start of the list, pass 0 as the second parameter.

So, just adding 0 to all your AddInventory commands should do it.

EDIT: Re-reading it, I might've got what you want totally backwards. Just using a single InvWidow, and possibly using the ItemWidth property to set spacing, might be enough for what you want.
I know what you're thinking ... Don't think that.

R4L

Okay I got it now. My icons were 16 by 16, and I set the inv window to hold 8 items. Thanks for the help everyone!

SMF spam blocked by CleanTalk