Mouse Movement

by Woo
Move by holding right-click.
Mouse Movement
A BYOND library
By Tyruswoo "Woo"


Move by holding right-click. When the player holds the right mouse button, they will move towards the location of the right mouse press. When they let go of the right mouse button, they will no longer move.

If you want left click to do something, then see the example code using either the Click() proc or the MouseDown() proc.

Update notes:
  • v.2.0: Now movement is pixel specific, moving you as close as possible to exactly where you clicked. Thanks to Zagros5000 for the suggestion that led to this improvement.
  • v.2.1: When the client leaves, now the cursor object is deleted as well. Just a little cleanup to keep the code tidy.
If you have any suggestions for mouse movement features or improvements, please leave a comment in this library's discussion forum.

Terms: If you use one or more of my libraries in your game, please credit me (as Woo or Tyruswoo) and leave a link back to one of the following: my website, my BYOND site, my YouTube channel, or the webpage of the library you used. Optionally, you could also give me a free subscription to your game, if you like!

Visit to check out my other work in game design!

Tyruswoo Official Site

Join the Tyruswoo BYOND community!
Tyruswoo BYOND YouTube Tyruswoo BYOND Patreon
Tyruswoo BYOND Site Tyruswoo BYOND Discord Chat
Only you can build your dreams.

I can't reach here using the mouse

I haven't figured out a good solution for that, yet. The walk_to proc works until the player barely steps inside the turf (by even a few pixels), and then after that it considers the movement successful. Since walk_to no longer works when we have crossed the target, we'd have to detect when the player has crossed the target, and then make the player continue to move until exactly on top of the target. I don't have a simple solution for that, yet.

If you have the edge of the map teleport you to another map, or have walls, this isn't too noticeable. However, I'd like to figure out a solution. Let me know if you have any suggestions.
maybe move an object saved to the player around that has a bound size of like 1x1 or 2x2 and place it under the cursor
var/list/parameters = params2list(params)
var/icon_x = text2num(parameters["icon-x"])
var/icon_y = text2num(parameters["icon-y"])

and just have them walk to it
In response to YURIRAMOS
I can't reach here using the mouse

Mouse Movement v 2.0 fixes this issue. Now movement goes to exactly where you clicked. Thanks to Zagros5000 for the suggestion that led to this fix.