Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Slasher on Wed 05/06/2013 19:12:50

Title: SOLVED: Inventory Hover over button or maybe click button to run events
Post by: Slasher on Wed 05/06/2013 19:12:50
Hi,

I'm only working on one cylinder today.

I'm trying to use an inventory item hover over a button (Button28 is the slot for a DVD).

The inventory can be any one of 4 music DVD's.

This works but is not refined enough.

Not sure. Can you help me please?

Code (AGS) Select

if (cspace.ActiveInventory==iswan &&  mouse.x>=81 &&  mouse.y<=121 && Game.DoOnceOnly("Swan"))
{
if (Game.DoOnceOnly("swan_play"))
  a2001_theme.Play();
  cspace.LoseInventory(iswan);
  cspace.ActiveInventory=null;
}
}



EDIT: This is almost there with this way:

Code (AGS) Select

if (cspace.ActiveInventory==iswan &&  mouse.x>=260 &&  mouse.x<=300 &&  mouse.y<=90 && Game.DoOnceOnly("Swan"))




Many thanks if you can offer the real way...



Title: Re: Inventory Hover over button or maybe click button to run events
Post by: Khris on Wed 05/06/2013 21:08:06
Where are you using this code?
Because you can put it inside the button's OnClick function, and that way you don't need any coordinate checks.

Code (ags) Select
function btnDVDSlot_OnClick(GUIControl *control, MouseButton button) {
  if (button != eMouseLeft) return;
 
  if (mouse.Mode == eModeUseinv && player.ActiveInventory == iswan) {
    a2001_theme.Play();
    player.LoseInventory(iswan);
    player.ActiveInventory = null;
  }
}
Title: Re: Inventory Hover over button or maybe click button to run events
Post by: Slasher on Wed 05/06/2013 21:43:47
Cheers Khris,

That makes sense, I really should have seen it.

Anyhow, I now have it so I can play any of 4 DVD's.

Thank you