Has event "other click" on inventory items been changed?

Started by Monsieur OUXX, Tue 24/12/2019 15:25:12

Previous topic - Next topic

Monsieur OUXX

Please note that this is about inventory, not room objects. Room objects have "ANY click" event, whereas inventory items have "OTHER click" event.

I went digging into some old scripting I had in a game I started many versions of AGS ago. I saw that I conveniently always ever used the "other click on inventory item" instead of separate, individual  events  such as "look at inventory item", "interact inventory item", etc. I was then checking the current mouse action INSIDE of the event function, to produce the appropriate response.
I used this technique throughout my entire game, to have less event functions cluttering my global script.

And now, I'm only just noticing that this is broken. The "other click" event is NOT firing when using "look at", "use", etc. on my inventory items. I specifically have to use the "look at inventory item" event for it to respond to "look at", for example.

I know my question sounds like the question of a confused person, but that's exactly what it is. I'm confused: Was the inventory item event "other click" always like that or has it been changed? How the heck did I manage to have my game work so far ? (I have a dozen inventory items, all using only the "other click" event)
 

eri0o

According to the source code and git blame, this has been the behavior for at least 6 years.

You can just set all inventory items event to use the same function and then retrieve the mode directly from the mouse. If you don't want to do this by the Editor, you can script a python or other type of script to change the functions in the Game.agf xml file.

Isn't possible to get a click event and then get the InventoryItem at X and Y, and not use events at all? Seems like what you actually want to do.

Cassiebsg

You could try and see if setting the compatibility mode to an older version helps (you find it in the settings panel, I think).
There are those who believe that life here began out there...

Crimson Wizard

#3
Quote from: eri0o on Tue 24/12/2019 15:56:25
According to the source code and git blame, this has been the behavior for at least 6 years.

You are linking code to GetInvAt, which returns inventory item by request, but not processes clicks on it.
It's RunInventoryInteraction, from line 102. And yes, it looks like you only get "Other click" if it's NOT Look, Interact, UseInv or Talk.



Could you clarify how do you handle clicks, do you do that in script (please post an example), or using built-in click handling (have "Override build-in inventory click handling" set to false)?

Khris

I did a quick test with AGS 2.72's Default Game, and I can confirm that even back then, AGS did not always run the "Other click" event.
So to get this to work, there has to be something like
Code: ags
  else if (button == eMouseLeft) inventory[game.inv_activated].RunInteraction(eModeUsermode1);

in an on_mouse_click.
This line will trigger "Other click on inventory".

So the part of the game that broke is most likely your own code, not AGS itself.

Monsieur OUXX

OK, thanks everyone. I don't know what kind of trick I was using back then to make it work when I programmed this game (maybe an extra mouse mode dedicated only to that, or whatnot) but it's not worth investigating it. I'll do what people suggested (and i also the way "Tumbleweed" handles inventory clicks) and just bind all the events to the same function.
Could be worth adding an event "any click" for consistency with objects and hotspots.
 

SMF spam blocked by CleanTalk