AddInventory and item order in inventory slots (SOLVED)

Started by dronon, Mon 31/07/2006 04:12:23

Previous topic - Next topic

dronon

I'm using the deault AGS template, and my character starts off with the key and the pink poster in his inventory, but not the blue cup.

At one point, I have an instruction to add the blue cup to my inventory, and I want it to be in the first slot, so I set: character[EGO].AddInventory(iCup,0); and then use UpdateInventory (); . But it always ends up in the third slot. Am I interpreting this command correctly? Can I get my inventory to be re-ordered as (cup, key, pink poster) instead of (key, pink poster, cup)?

Imhotep

Don't use UpdateInventory () after you added the blue cup and it will work fine.

Because of this (in the manual):
Note that using this function (UpdateInventory) will reset the order that items are displayed in the inventory window to the same order they were created in the editor.

dronon

(slaps forehead)

Okay, that works now. Thanks!

Now that I've got this figured out, I'm going to try to implement a successive-right-click command in the inventory that will "push" an item from the first slot until it reaches the desired position. Inelegant, but hey, why not.

Ashen

Is there any other reason than 'why not'? If we knew want you wanted to do, we might be able to suggest a more 'elegant' way to do it.
I know what you're thinking ... Don't think that.

dronon

Quote from: Ashen on Wed 02/08/2006 11:43:48
Is there any other reason than 'why not'? If we knew want you wanted to do, we might be able to suggest a more 'elegant' way to do it.

Actually, now that I've got it coded in, it's a lot less ugly than I thought it would be! This allows me to plunk items back anywhere in my inventory when I right-click with them over another inventory object.

Code: ags

  if ((button == eMouseRightInv) && (mouse.Mode == 4)) { 
    InventoryItem *item2 = player.ActiveInventory;
    int counter2 = 0;
    int counter = 0;
    while (counter < invCustomInv.ItemCount) {
      String location = Game.GetLocationName(mouse.x, mouse.y);
      String indexname = invCustomInv.ItemAtIndex[counter].Name;
      if (location == indexname) {counter2 = counter;}
      counter ++;
      player.LoseInventory(item2);
      player.AddInventory(item2,counter2);
      mouse.Mode = 2;
      mouse.UseModeGraphic(eModePointer);
      }
    }


SMF spam blocked by CleanTalk