Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Rui 'Trovatore' Pires on Sat 14/02/2004 22:51:05

Title: Confusing error which makes no sense
Post by: Rui 'Trovatore' Pires on Sat 14/02/2004 22:51:05
How can the following line of code

if (button==LEFTINV) RunInventoryInteraction(GetInvAt(mouse.x,mouse.y),GetCursorMode());

POSSIBLY bring up the error window...

---------------------------
Adventure Game Studio
---------------------------
An error has occured. Please contact the game author for support, as this
is likely to be a scripting error and not a bug in AGS.
(ACI version 2.60.697)

(Global script line 163)
Error: RunInventoryInteraction: invalid inventory number

---------------------------
OK  
---------------------------



...and how can it only do so SO randomly I can NEVER repdroduce the problem?? AND, this has happened with two projects of mine already!

Is it just me, or does it make NO sense?
Title: Re:Confusing error which makes no sense
Post by: Kairus on Sun 15/02/2004 03:38:56
What if the cursor was not located over an inventory item?
In that case GetInvAt will return -1.
I don't know what RunInventoryInteraction will do if you give it the -1 parameter, but I'm sure it can't be anything good. The best thing that could happen would be that RunInventoryInteraction did nothing if it's called with such parameter, but I'm nor sure of it.

Perhaps it would do the same effect you want but a little more harmless with the line that's shown in the manual:

if (button == LEFTINV)
 RunInventoryInteraction(game.inv_activated, GetCursorMode());

I think that global variable always has a correct number...
Title: Re:Confusing error which makes no sense
Post by: Rui 'Trovatore' Pires on Sun 15/02/2004 07:35:39
Kay, I'll try it out. The baffling thing is, (button==LEFTINV) should only be called when the player clicks on an inventory item, so there should always be an inventory item under the cursor. That's what I STILL can't figure out.
Title: Re:Confusing error which makes no sense
Post by: Kweepa on Sun 15/02/2004 09:08:22
Have you used RefreshMouse() in the script? That might change the x, y coordinates. If so, you could try storing mouse.x and mouse.y in local variables.

Or, perhaps you have closed the inventory window.

Or, maybe you have used AddInventory or RemoveInventory, thus changing the order of the icons in the window.

Or, it could be that AGS uses the whole rectangle for the inventory to determine if you clicked on it, but GetInvAt just uses the non-transparent parts? Does it happen if you click on the black bits around the inventory objects?

Steve