Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: LeChuck on Sun 23/10/2005 02:17:06

Title: Custom inventory annoyance (SOLVED)
Post by: LeChuck on Sun 23/10/2005 02:17:06
I'm having my own inventory, where you can pick things off of the inventory background like in Sam and Max. While it gives you the illusion of taking stuff from the inventory, all it does is set the inventory slot sprite to a blank one, and change the cursor sprite into the old inventory sprite. Everything is working grand, except when putting it back to the spot where it originally was.

I'm having this in all my items' Use Inventory On This Item script:


// script for inventory1: Use inventory on this item

if (character[EGO].activeinv==1) {
Ã,  Ã,  SetInvItemPic(1, 54); // Replaces the blank sprite with the original one, user has "put back" the item.
Ã,  Ã,  SetActiveInventory(-1);
Ã,  Ã,  SetCursorMode(MODE_USE);
Ã,  Ã,  Wait(15);
}


It's the Wait() function that's causing the annoyance for me. After you've put the item back, it waits for a little while, breaking the illusion I'm looking for, which, by the way, works great when I click with the item anywhere else on the inventory surface (which also puts the item back to its original slot).

If I don't have the Wait() in there, it will pick the item right back up, and it won't release the item. Any clues here?
Title: Re: Custom inventory annoyance
Post by: RickJ on Sun 23/10/2005 03:40:11
What happens if you do a Wait(1) instead of Wait(15)?  The other thing I am wondering is why not just change the invenrtory item quanity instead of changing the pic?
Title: Re: Custom inventory annoyance
Post by: LeChuck on Sun 23/10/2005 15:05:17
Wait(1); will also just pick up the item again as noone can release the mouse button in one game cycle.

But wouldnt setting the inventory quantity item to 0 make you lose the inventory? Or will you still have the object available in your hand, just not in the inventory window?
Title: Re: Custom inventory annoyance
Post by: RickJ on Sun 23/10/2005 15:12:23
Quote
Wait(1); will also just pick up the item again as noone can release the mouse button in one game cycle.
Are you sure?  Isn't this called from an interaction event?

Quote
But wouldnt setting the inventory quantity item to 0 make you lose the inventory? Or will you still have the object available in your hand, just not in the inventory window?
It would remove it from the inventory list and hence the window.
Title: Re: Custom inventory annoyance
Post by: LeChuck on Mon 24/10/2005 00:56:03
Quote from: RickJ on Sun 23/10/2005 15:12:23
Are you sure?Ã,  Isn't this called from an interaction event?
Yeah, I've tried it.


Quote
It would remove it from the inventory list and hence the window.

That's okay, I figured another workaround. Consider this thread SOLVED.
Title: Re: Custom inventory annoyance (SOLVED)
Post by: Ashen on Mon 24/10/2005 00:57:56
Any chance you could share your solution, for future reference?
Title: Re: Custom inventory annoyance (SOLVED)
Post by: LeChuck on Mon 24/10/2005 03:36:39
Quote from: Ashen on Mon 24/10/2005 00:57:56
Any chance you could share your solution, for future reference?


Ã,  // script for inventory1: Use inventory on this item

if (character[EGO].activeinv==1) {
Ã,  Ã,  SetInvItemPic(1, 54);
Ã,  Ã,  SetActiveInventory(-1);
Ã,  Ã,  while (IsButtonDown(eMouseLeft)) { } // this is the new line
Ã,  Ã,  SetCursorMode(eModeUse);
}


Now that I think about it, it's not really a workaround, it's just that it doesnt do anything while the mouse button is being helt down. Again, I tried similar stuff before posting this thread without much success. Then I post a thread about it, find a ridiculously easy solution myself and make me look like a fool. :P
Title: Re: Custom inventory annoyance (SOLVED)
Post by: SSH on Mon 24/10/2005 10:00:25
AGS normally only runs interactions on "Button up" rather than "Button down" so I'm not sure why you get this behaviour to start with, unless you've been changing the default script around a lot already.