Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Lior on Sat 10/08/2024 22:33:45

Title: Using event interact inventory item
Post by: Lior on Sat 10/08/2024 22:33:45
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:
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 ?
Title: Re: Using event interact inventory item
Post by: Khris on Sun 11/08/2024 20:40:32
You need something like this:

  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);
  }