Using inventory items without using an inventory

Started by DrWhite, Tue 17/11/2009 20:39:19

Previous topic - Next topic

DrWhite

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.

Khris

#1
This should work:

Code: ags
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:

Code: ags
  InventoryItem*pointer_to_clicked_item = InventoryItem.GetAtScreenXY(x, y);

DrWhite


Helme

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

Khris

Hehe, it didn't require a huge post, and I like those :)

SMF spam blocked by CleanTalk