Unable to select/use inventory items

Started by TheEyess, Mon 30/01/2023 14:20:50

Previous topic - Next topic

TheEyess

Hey there,

I'm a newbie on AGS and I know this topic has already been discussed quite a few times, but I still haven't been able to find a solution in the forum.

My problem is this: I have an inventory bar in my game and items seem to be added correctly to it. However, I am unable to click on the item in my inventory and consequently, unable to use it on objects or hotspots in my room.

I doublechecked and all the "clickable" and "enabled"-parameters of both the inventory GUI and the inventory window where my items appear are set to "true".

I also enabled "Override built-in inventory window click handling" in general settings, heaving read that this might be a solution. I also made sure that my inventory window is big enough to accomodate my item's sprites.

Still, none of this has worked so far and I can't seem to find the problem. Any help would be greatly appreciated!

Snarky

Typically this problem is caused by not setting the item dimension properties for the inventory, so that the actual "clickable" part of the items is only a small corner of the sprite.

Another possibility is that a different, invisible GUI is covering up your inventory GUI.

A third possibility is an AGS bug that was discovered today, if you are calling SayBackground() from repeatedly_execute() (or any of that family of functions).

TheEyess

Thanks for ur answer!

The ItemHeight and Width parameters are both set to the size of my sprite.

The only other GUI I have at this point is a text window UI that seems to be working as it should, so that does not seem to be it.

Finally, in "repeatedly execute", I had the following function i found in an effort to solve the problem:

Code: ags
 InventoryItem *item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (item != null)
    item.RunInteraction(mouse.Mode); 


Deleting it didn't seem to change anything, neither to the better nor the worse.

TheEyess

UPDATE:

Recreated my game from the template and it now seems to work. Apparently, I started my first try from a blank file so I was missing some essential code. Sorry for the trouble!

Snarky

All right, glad you got it to work!

Khris

Quote from: TheEyess on Mon 30/01/2023 14:20:50I also enabled "Override built-in inventory window click handling" in general settings
Just for reference, turning on this option means you need to write code to be able to select an item (specifically, a block in on_mouse_click that deals with button == eMouseLeftInv).

Without custom inv click handling, interacting with an item should be enough to select it.

SMF spam blocked by CleanTalk