Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Ytterbium on Sat 07/02/2004 03:48:23

Title: How do I script a double click detector?
Post by: Ytterbium on Sat 07/02/2004 03:48:23
I'm sorry if this is in the manual, but if it is, I couldn't find it.

I'd like my game to do something different if you double click on an inventory item rather than single click. I know this has been done in AGS games before (No, I'm not talking about Alien Rape Escape! Okay, fine, I am.), and I'd like to know how.

Please don't tell me to RTFM, because TFM doesn't answer TFQ.

Title: Re:How do I script a double click detector?
Post by: Darth Mandarb on Sat 07/02/2004 08:49:05
Quote from: Ytterbium on Sat 07/02/2004 03:48:23Please don't tell me to RTFM, because TFM doesn't answer TFQ.
I don't have the answer you're looking for, but I just wanted to tell you this made me laugh!

That was pretty darn funny!  I hope you figure this out!

~ d
Title: Re:How do I script a double click detector?
Post by: Chicky on Sat 07/02/2004 12:37:03
im no programmer,

but couldnt you do somthing on the items actions like, on left click run script, if leftmousebutton then do {what ever you want}. I dunno just trying to help.

DTFM  ;)

-a chicken
Title: Re:How do I script a double click detector?
Post by: Ytterbium on Sat 07/02/2004 16:28:14
Quote from: oversizedchicken on Sat 07/02/2004 12:37:03
im no programmer,

but couldnt you do somthing on the items actions like, on left click run script, if leftmousebutton then do {what ever you want}. I dunno just trying to help.

DTFM  ;)

-a chicken

I know. What about double-left click?
Title: Re:How do I script a double click detector?
Post by: Dorcan on Sat 07/02/2004 19:04:34
There is a new tutorial I've just made  :)

http://www.digitalmindstudio.ch/script.php?langue=en&id=9 (http://www.digitalmindstudio.ch/script.php?langue=en&id=9)
Title: Re:How do I script a double click detector?
Post by: Ytterbium on Sat 07/02/2004 21:31:28
Quote from: Dorcan on Sat 07/02/2004 19:04:34
There is a new tutorial I've just made  :)

http://www.digitalmindstudio.ch/script.php?langue=en&id=9 (http://www.digitalmindstudio.ch/script.php?langue=en&id=9)

I changed it a little...

In repeatedly_execute:

 if  (timerClick>0)   {
   timerClick--;
 if  (timerClick == 0)
     RunInventoryInteraction(game.inv_activated, 4);
 }


In on_mouse_click:
else if (button==LEFTINV) { //Selecting an inventory item
  timerClick = 0;
  SetActiveInventory(game.inv_activated);
  EnableCursorMode(4);
  SetCursorMode(4);
  }
else if (timerClick == 0)    {
     dblClick = 0;
     timerClick = dblClickSpeed;
   }
else   {
     timerClick = 0;
     dblClick = 1;
     RunInventoryInteraction(game.inv_activated, 4);  
}



This doesn't seem to work. For now I'll just make LEFTINV check if the cursor mode is Use Inv, but I'd much rather have a double click do it.
Title: Re:How do I script a double click detector?
Post by: Chicky on Sun 08/02/2004 00:03:17
i jus dont wannna sound stupid,

what i mean is have it run script on left click, the script would be if leftmousebutton then (do whatever). So in theory your pressing it two times.

maybe anywayz

-a chicken
Title: Re:How do I script a double click detector?
Post by: Kweepa on Sun 08/02/2004 11:45:09
osc,
Your idea is a simple one. Unfortunately too simple :)
The script would run the moment the left mouse button was clicked, and you'd then have to wait in the script for the second click.

Dorcan's code (unmodified) works for room interactions (thanks Dorcan!) but not for inventory interactions.

I think you'd have to create your own Inventory GUI to allow double clicks on the inventory objects through on_interface_click - that's how I'd do it anyway: by emulating the behaviour of the Inventory GUI object with buttons.

You might want to download some of the GUI templates for ideas and pointers.

[EDIT] The "Handle inventory clicks in script" option in General Settings doesn't seem to help.