Script : Hold Mouse Click and Double Click

Started by Kikutaâ„¢, Fri 10/12/2004 14:44:28

Previous topic - Next topic

Kikutaâ„¢

Hi

I am having troubles scripting how to make the double click work and i cant script a "hold click" function.

I have looked everwhere for a function that could make my life easy but i cant find it :P
So, i was hoping that you guys could help me to script that .

thanks :)

Bernie

Hi there! First off, you'll have to do that in repeatedly execute.

Holding button down:

if (IsButtonDown(LEFT)==1) {stuff}

The double click:

- Create a variable.
- When the left button is down and the variable is 0, set it to 10 or something (depends on game speed).
- Subtract one from that variable if it's bigger than 0.
- If the mouse button is triggered while the variable is greater than 0, trigger the desired action.

That did the trick for me. Lemme know if you can work it out, otherwise I'll just type up the code.

Kikutaâ„¢

Thanks!
I cant beleive i miss the "IsButtonDown because i've searched the intere help looking for that.

And thanks again for the duble click question.
I've did something like that, but it was not working as i liked. I made a counter and the secound time the player clicked the left button, it would activate the script.. anyway, thanks again ;)

Bernie

Well, there's many ways to script something like that. :)
If you run into any problems, let me know.

Kikutaâ„¢

thanks, your too kind :D

I cant seem to do the double click script. I've already tried but it doesnt seem to work.
It works, but very badly! Can u show me how u did it, please ?

Bernie

#5
Okay, here it is... put an int dclick above repeatedly execute, then copy/paste this code:

if (IsInterfaceEnabled()==1) {

Ã,  if (IsButtonDown(LEFT)==1) {
Ã,  Ã,  if (dclick >2)
Ã,  Ã,  Ã,  if (dclick <16) {{DisplaySpeech(GetPlayerCharacter(),"Doubleklikkers!");dclick=0;}}}

Ã,  if (dclick ==1) {DisplaySpeech(GetPlayerCharacter(),"Oneklikkers!");dclick=0;}

Ã,  if (dclick > 0) {dclick=dclick-1;}Ã,  Ã,  Ã,  Ã, 

Ã,  if (IsButtonDown(LEFT)==1) {dclick=16;}
}

You'll have to tinker around with the dclick value depending on your game speed. If the double click time is to short, replace the sixteens with higher values.

----------------------------------------------------------------

Another, maybe better way is doing this:

top of global script:
int dclick;

mouse_click:
if (button==LEFT){ if (dclick>1) {DisplaySpeech(GetPlayerCharacter(),"Doubleklikked!");dclick=1;}}
if (button==LEFT){ if (dclick==0) {dclick=16;}}

repeatedly execute:
if (dclick > 0) {dclick=dclick-1;}

It's shorter and works better but is spread across several global functions.

Kikutaâ„¢


Bernie

Actually, you probably should use the second one as it doesn't interfere with the text you click away if you have skip speech set to mouse click.

SMF spam blocked by CleanTalk