An exception in the function eMouseLeftInv: how to do? (solved)

Started by Clarabella, Thu 28/02/2008 17:24:05

Previous topic - Next topic

Clarabella

I had a visible inventory in my game and I wanted inventory items to be active when you left-click on it. I managed to do this.
Then, I tryed to make an exception: I want my inventory item to be active if I left click it, except if the lookAt cursor is active. If the lookAt cursor is actvive I want the function "inventoryitem_look()" to happen. But I don't know how to make it happen. So, here is my script:

if (button == eMouseLeftInv)
  {
    if (mouse.Mode == eModeLookat)
    { ??? }
   else
   {
    player.ActiveInventory = inventory[ game.inv_activated ];
   }

Is this the right way to do what I want? And if so, what do I have to put instead of the ??? smiley between the two brackets? I want it to be a generic function, so that every inventory item I look at, that function happens.

Thanks!

Matti

You can replace the smiley with this line:
inventory[game.inv_activated].RunInteraction(mouse.Mode);

This will run the interaction of the current cursor mode, which is - in your case - the look mode

twin-moon

This is how I'd do it:

Code: ags
    if (button == eMouseLeftInv) {
      InventoryItem *item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
      if (Mouse.Mode == eModeLookat) item.RunInteraction(eModeLookat);
      else player.ActiveInventory = item;
    }


And remember to set "Handle inventory clicks in script" on the General Settings to true (but judging from your post I guess you know that).
                                    The Grey Zone

Clarabella

I had some problems and I couldn't read your answers before.
Thank you both for help, I used the first solution and it works perfectly!

SMF spam blocked by CleanTalk