Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Trisk on Wed 20/04/2005 21:24:28

Title: Inventory GUI icon defaults to walk? *Solved*
Post by: Trisk on Wed 20/04/2005 21:24:28
I'm sorry if this is repeating something there is already a solution for, but I've looked everywhere in the BFAQ and in the AGS help file, as well as searching in the forums, but I can't find a solution to this madeningly simple problem.

I'm using the custom inventory GUI, and I haven't really made any modifications to it yet. At several points in my game, I have the player combining several items to create a different item. I use a simple script to do this. At the end of the script, I use an AddInventory command and two LoseInventory commands. Viola, items combined.

The problem is, when I LoseInventory the item that WAS the mouse cursor, the cursor changes to the WALK icon, and you can't interact with the inventory any more until you click on the arrow button. There has to be a way to stop AGS from doing this? Why would it ever change to walk in the inventory?

I suppose in the script I could just manually return the mouse cursor to an arrow, but I'd have to add that code into EVERY combination script, which seems really inefficient to me...

Any help would be awesome!
Trisk
Title: Re: Inventory GUI icon defaults to walk?
Post by: monkey0506 on Wed 20/04/2005 22:23:44
Perhaps if you set the active inventory item to the new item before deleting the old ones?  But I'm not sure I fully understand the problem so this could be completely wrong.
Title: Re: Inventory GUI icon defaults to walk?
Post by: strazer on Wed 20/04/2005 22:35:13
Try this:


function on_event(int event, int data) {
  //...

  if (event == LOSE_INVENTORY) { // if player just lost an inv item

    if ((IsGUIOn(YOURCUSTOMINVGUI)) && (GetCursorMode() == MODE_WALK)) // if the inv GUI is displayed and mouse has changed to walk mode (lost active inv item)
      SetCursorMode(7); // set mouse to pointer mode

  }

  //...
}
Title: Re: Inventory GUI icon defaults to walk?
Post by: Trisk on Thu 21/04/2005 04:41:46
OK, I put that into the global script, like so:

---------------------------------
function on_event(int event, int data) {
Ã,  //...

Ã,  if (event == LOSE_INVENTORY) { // if player just lost an inv item

Ã,  Ã,  if ((IsGUIOn(INVENTORY)) && (GetCursorMode() == MODE_WALK)) // if the inv GUI is displayed and mouse has changed to walk mode (lost active inv item)
Ã,  Ã,  Ã,  SetCursorMode(MODE_USE); // set mouse to use mode
Ã,  Ã,  Ã,  SetMouseCursor(6);  //set mouse icon to pointer
Ã,  }

Ã,  //...
}

--------------------------------
If I combine, everything works beautifully. However, If I use an item on another item that DOESN'T get removed from the inventory - e.g. using a roll of tape on a piece of glass tapes one end of the glass so you can hold it without cutting yourself, but it doesn't use up the whole tape roll - the icon STILL turns into an arrow, but ACTS as if it is still the roll of tape. So I still have to click on the arrow to turn the icon back into MODE_USE.

I'm really confused by why it would do that...the criteria of the "if" statement look valid...

-confused,
Trisk
Title: Re: Inventory GUI icon defaults to walk? *Still confused*
Post by: strazer on Thu 21/04/2005 06:03:01
That's because there are braces missing:

function on_event(int event, int data) {
  //...

  if (event == LOSE_INVENTORY) { // if player just lost an inv item

    if ((IsGUIOn(INVENTORY)) && (GetCursorMode() == MODE_WALK)) {
      SetCursorMode(MODE_USE);
      SetMouseCursor(6);
    }

  }

  //...
}

If you add more than one line after an if-clause, you have to enclose them in braces for them to be included:

if (a) {
b;
c;
}

If you do

if (a)
b;
c;

only b gets included in the if-clause. It's the same as if you would do

if (a) b;
c;
Title: Re: Inventory GUI icon defaults to walk? *Still confused*
Post by: Trisk on Thu 21/04/2005 16:03:02
I don't know how to break this to you, strazer...but you are THE MAN!!!

Thanks so much! It works like a charm! Three cheers! :D
Title: Re: Inventory GUI icon defaults to walk? *Still confused*
Post by: strazer on Thu 21/04/2005 18:05:58
Hehe, you're welcome.  :)