Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Ostyster on Wed 03/08/2016 19:54:18

Title: Inventory Item doesn't get set as active
Post by: Ostyster on Wed 03/08/2016 19:54:18
I want my Character to be able to combine Inventory items but I can't click on a Inventory item in any way. the items get displayed as they should but i can't look at them, talk to them and most importantly interact with them.
Title: Re: Inventory Item doesn't get set as active
Post by: Cassiebsg on Wed 03/08/2016 20:24:43
It would help a lot to know what template, if any, are you using. And maybe AGS version.
And if you not using a template, then you code.
Title: Re: Inventory Item doesn't get set as active
Post by: Ostyster on Wed 03/08/2016 20:31:04
AGS 3.3.5 and no template
Title: Re: Inventory Item doesn't get set as active
Post by: Cassiebsg on Wed 03/08/2016 20:51:00
You need to code the mouse clicks for the inventory window.

on your function on_mouse_click

You'll need to make a if button==eMouseLeftInv (and/or eMouseRightInv) (this is the Mouse clicks for inventory window)

I'm assuming you already coded normal eMouseLeft and eMouseRight.
Title: Re: Inventory Item doesn't get set as active
Post by: Ostyster on Wed 03/08/2016 21:00:59
Ok but what do i have to type in to make the left mouse button select the clicked item as activated item

Code (ags) Select

else if (button == eMouseLeftInv)
  {
 
  }
Title: Re: Inventory Item doesn't get set as active
Post by: Slasher on Wed 03/08/2016 21:41:56
you'd better off using the default template and not empty template which is for more experienced scripter's...
Title: Re: Inventory Item doesn't get set as active
Post by: Ostyster on Wed 03/08/2016 21:43:52
So best way is to start over... Ok
Title: Re: Inventory Item doesn't get set as active
Post by: Cassiebsg on Wed 03/08/2016 21:46:19
Or take a look at it, learn how it's done, and then copy it to your project. ;)
Also, default template = sierra interface. Check first what interface you're aiming for, there's a template for most usual interfaces.
Title: Re: Inventory Item doesn't get set as active
Post by: Slasher on Wed 03/08/2016 21:47:28
The default template already contains many functions and includes everything inventory requires built-in.

its easier to begin game making as a novice (nod)
Title: Re: Inventory Item doesn't get set as active
Post by: Ostyster on Wed 03/08/2016 21:49:05
I will try looking through an already made code and if that doesn't help me i will start over.
Thanks for your help
Title: Re: Inventory Item doesn't get set as active
Post by: Snarky on Wed 03/08/2016 23:08:48
To answer your question, though, at least one part of the answer is to set the player's active inventory to the inventory item clicked on, and probably set the cursor mode to inventory:

Code (ags) Select
  else if (button == eMouseLeftInv)
  {
    player.ActiveInventory = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
    mouse.Mode = eModeInventory;
  }


I seem to recall there are some special cases for when you're over an inventory window but no actual inventory item, so you might want to check if the InventoryItem* you get is null.
Title: Re: Inventory Item doesn't get set as active
Post by: Khris on Sat 06/08/2016 12:34:33
The clicked item can be retrieved by  player.ActiveInventory = inventory[game.inv_activated];
button is only set to eMouseLeftInv/eMouseRightInv if the player actually clicked an item, and the item id is stored in game.inv_activated. That way one can't get a NPE error when moving the mouse really fast while clicking.