Jibble

Author Topic: Using items on other items problem  (Read 707 times)

Using items on other items problem
« on: 11 May 2014, 13:03 »
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: Adventure Game Studio
  1. function on_mouse_click(MouseButton button) // called when a mouse button is clicked. button is either LEFT or RIGHT
  2. {
  3.   if (IsGamePaused() == 1) // Game is paused, so do nothing (ie. don't allow mouse click)
  4.   {
  5.   }
  6.   else if (button == eMouseLeft) // Normal left click, outside inventory
  7.   {
  8.     if (player.ActiveInventory != null) // if item active, process useinv and reset description
  9.     {
  10.       ProcessClick(mouse.x, mouse.y, eModeUseinv);
  11.       Label2.Text = "@OVERHOTSPOT@";
  12.     }
  13.     else ProcessClick(mouse.x,mouse.y, mouse.Mode); // if not, process normal mouse click
  14.   }
  15.   else if (button == eMouseRight) // Normal Right click, outside inventory
  16.   {
  17.     if (player.ActiveInventory != null) // if iten active, deactivate item and reset description
  18.     {
  19.       player.ActiveInventory = null;
  20.       Label2.Text = "@OVERHOTSPOT@";
  21.     }
  22.     else ProcessClick(mouse.x,mouse.y, eModeInteract); // if no item active, process interact
  23.   }
  24.   else if (button == eMouseLeftInv) // Inventory Left click
  25.   {
  26.     if (player.ActiveInventory != null)             // if item in hand
  27.     {                                               //
  28.       ProcessClick(mouse.x, mouse.y, eModeUseinv);  // process use inv
  29.       player.ActiveInventory = null;                // then remove the item
  30.       Label2.Text = "@OVERHOTSPOT@";                // and reset the description, but this doesn't seem to work
  31.     }
  32.     else if (player.ActiveInventory == null)        // if no item active, then activate item
  33.     {
  34.       mouse.Mode = eModeUseinv;
  35.       player.ActiveInventory=InventoryItem.GetAtScreenXY(mouse.x,  mouse.y);
  36.       Label2.Text = String.Format("Use %s", inventory[game.inv_activated].Name);
  37.     }
  38.   }
  39.   else if (button == eMouseRightInv) // Inventory Right click
  40.   {
  41.     if (player.ActiveInventory != null) // if item active, deactivate item and reset description
  42.     {
  43.       player.ActiveInventory = null;
  44.       Label2.Text = "@OVERHOTSPOT@";
  45.     }
  46.     else inventory[game.inv_activated].RunInteraction(eModeInteract); // interact with item
  47.   }
  48. }

And this is the code for the inventory item:
Code: Adventure Game Studio
  1. function ibnt_metal_UseInv()
  2. {
  3.   if (player.ActiveInventory == iBobbypin)
  4.   {
  5.     cvanessa.Animate(52, 3, eOnce, eBlock);
  6.     cvanessa.LoseInventory(iBobbypin);
  7.     cvanessa.LoseInventory(ibnt_metal);
  8.     cvanessa.AddInventory(iLockpick);
  9.   }
  10. }

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

  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on one or more games that was nominated for an AGS Award!
Re: Using items on other items problem
« Reply #1 on: 11 May 2014, 16:07 »
ProcessClick() ignores GUIs and simulates a background click.

You need
Code: Adventure Game Studio
  1.   inventory[game.inv_activated].RunInteraction(eModeUseinv);

Re: Using items on other items problem
« Reply #2 on: 11 May 2014, 16:16 »
Awesome, thanks Khris! :)