Ok, well ever played CMI?
In some rooms you could double click at a door (the cursor changed shape over that hotpsot) and you entered the room instantly.
I tried to do something with timers but it can't work.
I don't have any troubles changing the cursor, so don't bother helping me with that. I just have a problem with making a double click.
Feel free to make a code using Timer module.
Basically, if clicked over eligable hotspot start counter, if another click on same hotspot (or within a certain radius of the first click's location) perform double click action; any other click or counter expires, cancel double-click.
Here's a tested and working example for the left mouse button:
#define DCDELAY 7
function left_click(bool single) {
if (single) {
// single-click code
ProcessClick(mouse.x, mouse.y, mouse.Mode );
}
else {
// double-click code
Display("Double-click detected!");
}
}
int lastclick, mx, my;
#sectionstart repeatedly_execute // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
// put anything you want to happen every game cycle here
if (lastclick>0 && lastclick<=DCDELAY) lastclick++;
else if (lastclick>DCDELAY) {
lastclick=0;
left_click(true);
}
}
#sectionend repeatedly_execute // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart on_mouse_click // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(MouseButton button) {
// called when a mouse button is clicked. button is either LEFT or RIGHT
if (IsGamePaused() == 1) {
// Game is paused, so do nothing (ie. don't allow mouse click)
}
else if (button == eMouseLeft) {
if (lastclick && mouse.x==mx && mouse.y==my) {
lastclick=0;
left_click(false);
}
else {
lastclick=1;
mx=mouse.x;
my=mouse.y;
}
}
else { // right-click, so cycle cursor
mouse.SelectNextMode();
}
}
#sectionend on_mouse_click // DO NOT EDIT OR REMOVE THIS LINE
The only downside: it takes DCDELAY frames before a single click is processed.
There is mone problem guys. I'm using CMI gui. So when I left click a counter starts and after some secs my GUI opens. :-*
I'll post the code so you can try in another way.
That code works fine for me but how can I activate it in room script? - I am using LW BASS v.2.0 template - after double click on exit hotspot character has to change room - what i have to type in interact hotspot function? ;/
The easiest way is to use a custom cursor mode. I used Usermode1 and renamed it to "ChRoom".
Then I used this for the double click code: else {
// double-click code
ProcessClick(mx, my, eModeChRoom);
}
Now all you need to do is add an interaction for the new mode to the exit's hotspot, and put the .ChangeRoom() command inside.
Here's my working integration of the double-click code and the BASS click handler script: http://pastebin.com/G273xUgn
Thank you kindly Khris - it works like a charm :)