Inventory Item doesn't get set as active

Started by Ostyster, Wed 03/08/2016 19:54:18

Previous topic - Next topic

Ostyster

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.

Cassiebsg

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.
There are those who believe that life here began out there...


Cassiebsg

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.
There are those who believe that life here began out there...

Ostyster

Ok but what do i have to type in to make the left mouse button select the clicked item as activated item

Code: ags

else if (button == eMouseLeftInv)
  {
  
  }

Slasher

#5
you'd better off using the default template and not empty template which is for more experienced scripter's...

Ostyster


Cassiebsg

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.
There are those who believe that life here began out there...

Slasher

The default template already contains many functions and includes everything inventory requires built-in.

its easier to begin game making as a novice (nod)

Ostyster

I will try looking through an already made code and if that doesn't help me i will start over.
Thanks for your help

Snarky

#10
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
  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.

Khris

The clicked item can be retrieved by
Code: ags
  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.

SMF spam blocked by CleanTalk