Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //////////////////////////////////////
  2. //                                  //
  3. //  MouseHeld is a library designed //
  4. //  to allow tracking of what mouse //
  5. //  buttons  are  being  held  down //
  6. //                                  //
  7. //////////////////////////////////////
  8.  
  9. // mouse button macros
  10.  
  11. #define MOUSE_LEFT  1   // left click
  12. #define MOUSE_RIGHT 2   // right click
  13. #define MOUSE_MIDLE 4   // middle click
  14.  
  15. client
  16.     var
  17.         mouses_down = 0     //variable for what keys are being held down
  18.  
  19.  
  20.     // bitflags to track holding down mouse buttons.
  21.     // uncomment the //world << mouses_down to see.
  22.  
  23.     // MouseDown() tells us they're being held down
  24.     // then we turn on their respective bitflags
  25.     MouseDown(atom/object,location,control,params)
  26.         var/list/pref = params2list(params)
  27.         if("left" in pref)
  28.             mouses_down |= MOUSE_LEFT
  29.         if("right" in pref)
  30.             mouses_down |= MOUSE_RIGHT
  31.         if("middle" in pref)
  32.             mouses_down |= MOUSE_MIDLE
  33.  
  34.         //world << mouses_down
  35.  
  36.         ..()
  37.  
  38.     // MouseUp() tells us they are no longer being held down.
  39.     // then we turn off their respective bitflags
  40.     MouseUp(object,location,control,params)
  41.         var/list/pref = params2list(params)
  42.         if("left" in pref)
  43.             mouses_down &= ~MOUSE_LEFT
  44.         if("right" in pref)
  45.             mouses_down &= ~MOUSE_RIGHT
  46.         if("middle" in pref)
  47.             mouses_down &= ~MOUSE_MIDLE
  48.  
  49.         //world << mouses_down
  50.  
  51.         ..()
  52.  
  53.  
  54. #undef MOUSE_LEFT
  55. #undef MOUSE_RIGHT
  56. #undef MOUSE_MIDLE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement