Using event interact inventory item

Started by Lior, Sat 10/08/2024 22:33:45

Previous topic - Next topic

Lior

Hi,
I want a specific inventory item will work like this:

if some global variable i've defined is true:
inventory item works as usual, means when i press on it on inventory window, the curser will just become the inventory image

else if the global variable i've defined is false:
the character says something, and then the curser become the inventory image

when i just tried to use the inventory event "interact inventory item", nothing happens.

I've found in the forum this code, i've put it in GlobalScript under on_mouse_click function:
Code: ags
else if (button == eMouseLeftInv) {
    if (player.ActiveInventory != null) player.ActiveInventory = null; // active item? drop it
    else inventory[game.inv_activated].RunInteraction(mouse.Mode); // interact with item
  }
and set "Override built-in inventory window click handling" to TRUE.
Now the character talks, but the cursor's image doesn't change.

How do i also make the cursor to change to inventory item image ?

Khris

You need something like this:

Code: ags
  else if (button == eMouseLeftInv) {
    InventoryItem* ii = inventory[game.inv_activated];
    if (ii == iTheItem && !hasRemarkedOnItem) {
      player.Say("something");
      hasRemarkedOnItem = true;
    }
    if (mouse.Mode == eModeInteract) player.ActiveInventory = ii;
    else ii.RunInteraction(mouse.Mode);
  }

SMF spam blocked by CleanTalk