SOLVED: Inventory Hover over button or maybe click button to run events

Started by Slasher, Wed 05/06/2013 19:12:50

Previous topic - Next topic

Slasher

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
 
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

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




Khris

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
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;
  }
}

Slasher

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



SMF spam blocked by CleanTalk