Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: DrWhite on Tue 17/11/2009 20:39:19

Title: Using inventory items without using an inventory
Post by: DrWhite on Tue 17/11/2009 20:39:19
In my new game there will be three buttons, which activate the character´s special ability.
I wanted to solve this by handling the abilities as objects - as there won´t be a real inventory.

For example: Klick on Button2 - activate object oDogjump
Then, using the object on a hotspot would activate a script.
But somehow it doesn´t work.  ???
My code looks like this:

function But2_OnClick(GUIControl *control, MouseButton button)
{
  if (player.ID == cDog.ID) {
  int x = mouse.x;
  int y = mouse.y;
  mouse.Mode = eModeUseinv; player.ActiveInventory = iDogjump.GetAtScreenXY(x, y);
  }
}

I´d be glad if someone could help me with this.
Title: Re: Using inventory items without using an inventory
Post by: Khris on Tue 17/11/2009 21:03:16
This should work:

function But2_OnClick(GUIControl *control, MouseButton button)
{
 if (player.ID == cDog.ID) {
 // mouse.Mode = eModeUseinv;    // this line shouldn't be necessary, afaik setting player.ActiveInventoryis enough
 player.ActiveInventory = iDogjump;
 }
}


.GetAtScreenXY is a static function; it can only be used like this:

  InventoryItem*pointer_to_clicked_item = InventoryItem.GetAtScreenXY(x, y);
Title: Re: Using inventory items without using an inventory
Post by: DrWhite on Tue 17/11/2009 21:36:14
Works perfectly. Thanks a lot Khris.  :)
Title: Re: Using inventory items without using an inventory
Post by: Helme on Tue 17/11/2009 22:57:24
Hey Khris, you're so predictable.

DrWhite asked me, if I know a solution. I said, if you post your question, Khris will answer you. ;D
Title: Re: Using inventory items without using an inventory
Post by: Khris on Tue 17/11/2009 23:41:21
Hehe, it didn't require a huge post, and I like those :)