(Solved)Have a button handle the interactions of an inventory item.

Started by FanOfHumor, Mon 18/04/2022 16:59:55

Previous topic - Next topic

FanOfHumor

I have a button that displays an inventory item in my custom inventory. I don't have an inventory window but instead I have buttons in place of where the inventory items should be placed.Its really hard to explain so i'll try explaining with pictures.

I have a button for interactions.

and an inventory item for receiving the actions as events.

I want the inventory item to recognize events
from the buttons interactions.(As if The inv-item was clicked instead of the object)

if ikey(the button) has an item used on it then ikey2(inv-item) should recognize it as .
And so on with the other events.
I hope I explained it clear enough.
Thanks in advance.

eri0o

I cannot understand which type of AGS struct ikey is. Is it an object, a button or an inventory item?

If it's an inventory item, you can call it's interaction using RunInteraction
Code: ags
ikey.RunInteraction(eModeInteract);

Khris

You can use
Code: ags
  if (mouse.Mode == eModeUseinv) { ... }

FanOfHumor

Oops! I called the button an object. ikey is a button and ikey2 is an inventory item. Will try that Khris when I get a chance. Although something about that doesn't sound right for a button .I could be wrong.

FanOfHumor

How do I get the global inventory item ("item") to equal the selected inventory item.

I added this to the basic function do_inventory_action(MouseButton button, InventoryItem* item)
Code: ags
  Object *o = Object.GetAtScreenXY(mouse.x, mouse.y);
  if (o != null && o.GetProperty("inventory")==true)
  {
    mouse.Mode=eMouseLeftInv;
  }

Sorry if my explanation is fragmented and confusing.

Khris

eMouseLeftInv is a click type, not a mouse mode.
If you want to set the key as active cursor after clicking the button, you can do
Code: ags
  player.ActiveInventory = ikey2;

This should also change the mouse mode to  eModeUseinv.

eri0o

I think I am almost understanding... Are you making a room that works like an inventory, with objects being the things the player added to the inventory?

FanOfHumor

Its with buttons being the things the player added to the inventory.Its definitely figured out by now. Thanks for your help both of you.

SMF spam blocked by CleanTalk