Using items on other items problem

Started by EliasFrost, Sun 11/05/2014 13:03:49

Previous topic - Next topic

EliasFrost

Hi! So I'm updating my inventory system a bit and I try to make it so that the player can combine items with other items in the inventory, but my script doesn't seem to work for other inventory items, though they work for things outside the inventory, such as objects and hotspots. I have no idea why it doesn't work and I've read the script through several times but I still can't locate the problem, I would be very greatful if someone could take a look at the script and see if you can find the problem, please. :)

Here's the script for the mouse click:

Code: ags

function on_mouse_click(MouseButton button) // called when a mouse button is clicked. button is either LEFT or RIGHT
{
  if (IsGamePaused() == 1) // Game is paused, so do nothing (ie. don't allow mouse click)
  {
  }
  else if (button == eMouseLeft) // Normal left click, outside inventory
  {
    if (player.ActiveInventory != null) // if item active, process useinv and reset description
    {
      ProcessClick(mouse.x, mouse.y, eModeUseinv);
      Label2.Text = "@OVERHOTSPOT@";
    }
    else ProcessClick(mouse.x,mouse.y, mouse.Mode); // if not, process normal mouse click
  }
  else if (button == eMouseRight) // Normal Right click, outside inventory
  {
    if (player.ActiveInventory != null) // if iten active, deactivate item and reset description
    {
      player.ActiveInventory = null;
      Label2.Text = "@OVERHOTSPOT@";
    }
    else ProcessClick(mouse.x,mouse.y, eModeInteract); // if no item active, process interact
  }
  else if (button == eMouseLeftInv) // Inventory Left click
  {
    if (player.ActiveInventory != null)             // if item in hand
    {                                               //
      ProcessClick(mouse.x, mouse.y, eModeUseinv);  // process use inv
      player.ActiveInventory = null;                // then remove the item
      Label2.Text = "@OVERHOTSPOT@";                // and reset the description, but this doesn't seem to work
    }
    else if (player.ActiveInventory == null)        // if no item active, then activate item
    {
      mouse.Mode = eModeUseinv;
      player.ActiveInventory=InventoryItem.GetAtScreenXY(mouse.x,  mouse.y);
      Label2.Text = String.Format("Use %s", inventory[game.inv_activated].Name);
    }
  }
  else if (button == eMouseRightInv) // Inventory Right click
  {
    if (player.ActiveInventory != null) // if item active, deactivate item and reset description
    {
      player.ActiveInventory = null;
      Label2.Text = "@OVERHOTSPOT@";
    }
    else inventory[game.inv_activated].RunInteraction(eModeInteract); // interact with item
  }
}


And this is the code for the inventory item:
Code: ags

function ibnt_metal_UseInv()
{
  if (player.ActiveInventory == iBobbypin)
  {
    cvanessa.Animate(52, 3, eOnce, eBlock);
    cvanessa.LoseInventory(iBobbypin);
    cvanessa.LoseInventory(ibnt_metal);
    cvanessa.AddInventory(iLockpick);
  }
}


I suspect it has something to do with how I handle mouse clicks, but I have stared at the script for way too long to see the problem, would be cool if a pair of fresh eyes took a look at it.

Thanks :)

Khris

ProcessClick() ignores GUIs and simulates a background click.

You need
Code: ags
  inventory[game.inv_activated].RunInteraction(eModeUseinv);

EliasFrost


SMF spam blocked by CleanTalk