ID:195024
 
Quick and easy tracking of which of the three mouse buttons are being held down.

This can alternatively downloaded as a library here.

//Title: Mouse Button Tracking
//Credit to: F0lak


// mouse button macros

#define MOUSE_LEFT 1 // left click
#define MOUSE_RIGHT 2 // right click
#define MOUSE_MIDDLE 4 // middle click

client
var
mouses_down = 0 //variable for what keys are being held down


// bitflags to track holding down mouse buttons.
// uncomment the //world << mouses_down to see.

// MouseDown() tells us they're being held down
// then we turn on their respective bitflags
MouseDown(atom/object,location,control,params)
var/list/pref = params2list(params)
if("left" in pref)
mouses_down |= MOUSE_LEFT
if("right" in pref)
mouses_down |= MOUSE_RIGHT
if("middle" in pref)
mouses_down |= MOUSE_MIDDLE

//world << mouses_down // uncomment for output

..()

// MouseUp() tells us they are no longer being held down.
// then we turn off their respective bitflags
MouseUp(object,location,control,params)
var/list/pref = params2list(params)
if("left" in pref)
mouses_down &= ~MOUSE_LEFT
if("right" in pref)
mouses_down &= ~MOUSE_RIGHT
if("middle" in pref)
mouses_down &= ~MOUSE_MIDDLE

//world << mouses_down // uncomment for output

..()