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?
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...
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.
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