Inventory Broken Sword Style

Started by Luca, Thu 15/05/2014 16:04:56

Previous topic - Next topic

Luca

Hi guys!
I'm having a problem:
I want to implement a Broken Sword's style inventory bar. So the bar works correctly (it disappears when I move away the mouse from it and it appears when I move the cursor near it), I can correctly examine the items in the inventory with the right click, but I can't select any item. It's supposed to happend by clicking on the selected item and the mouse should change icon with the one I setted in the "Inventory Items" menu.

To study how to do it, I copied the code in the LW_BASS_V2.0 template I found in the last AGS version, but nothing happened. (I didn't do the copy/paste with that code, but I rewrote line by line understanding what I was doing).

Could you please help me?

Thank you :)

Code: ags

function on_mouse_click (MouseButton button)
{
  if (IsGamePaused())
  {
    return;
  }
  //LEFT MOUSE BUTTON
  else if (button==eMouseLeft)
  {
    if (GetLocationType (mouse.x,  mouse.y) != eLocationNothing)
    {
      if (player.ActiveInventory ==null)
      {
        ProcessClick(mouse.x,  mouse.y,  eModeInteract);
      }
        else
        {
          ProcessClick (mouse.x,  mouse.y, eModeUseinv);
        }
      }
      else
      {
        if (player.ActiveInventory ==null)
        {
          ProcessClick(mouse.x,  mouse.y, eModeWalkto);
        }
        else
        {
         player.ActiveInventory=null;
        }
      }
    }
  //RIGHT MOUSE BUTTON
  else if (button == eMouseRight)
  {
    if (player.ActiveInventory != null)
    {
      player.ActiveInventory = null;
    }
    else if (GetLocationType (mouse.x, mouse.y)!= eLocationNothing)
    {
      ProcessClick(mouse.x,  mouse.y,  eModeLookat);
    }
  }
  //LEFT MOUSE BUTTON INVENTORY
  else if (button == eMouseLeftInv)
  {
    InventoryItem*item = InventoryItem.GetAtScreenXY (mouse.x, mouse.y);
    if (item != null)
    {
      
        if (player.ActiveInventory == null)
        {
          player.ActiveInventory = item;
        }
        else
        {
          if (item.ID != player.ActiveInventory.ID)
          {
            item.RunInteraction (eModeUseinv);
          }
        }
      }
    
  }
 //RIGHT MOUSE BUTTON INVENTORY
 else if (button==eMouseRightInv)
 {
   if (player.ActiveInventory !=null)
   {
     player.ActiveInventory=null;
     return;
   }
  InventoryItem *item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  if (item != null)
  {
    item.RunInteraction(eModeLookat);
  }
 }
}
Indiana Jones : Archeology = Big Lebowski : Communication Sciences

Khris

Did you set the option in General settings / Inventory that inventory clicks are handled by your script?
(Although right clicking them works, so it's probably something else.)

The code looks ok as far as I can see; what you can try is to use InventoryItem*item = inventory[game.inv_activated]; instead of InventoryItem.GetAtScreenXY (mouse.x, mouse.y) although again, the code you have should work.

Luca

Quote from: Khris on Thu 15/05/2014 16:15:12
Did you set the option in General settings / Inventory that inventory clicks are handled by your script?

Now THIS is embarrassing...
(roll)

Thank you :) solved!
Indiana Jones : Archeology = Big Lebowski : Communication Sciences

SMF spam blocked by CleanTalk